PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000098. Tìm hai số có tích chia hết – bản khó (Divisible Numbers, Hard Version)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm hai số có tích chia hết – bản khó (Divisible Numbers, Hard Version)

Divisible Numbers (hard version)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given four positive integers a,b,c,da,b,c,d with a<ca<c and b<db<d, find integers x,yx,y such that a<x≤ca<x\le c, b<y≤db<y\le d, and the product xyxy is divisible by abab. Print any valid pair, or -1 -1 if no pair exists.

Input

One line contains a,b,c,da,b,c,d in this order.

Output

Print xx and yy separated by a space, or -1 -1 if no solution exists.

Subtasks

  • Subtask 1 (20 points): 1≤a<c≤1041\le a<c\le 10^4; 1≤b<d≤1041\le b<d\le 10^4.
  • Subtask 2 (30 points): 1≤a<c≤1071\le a<c\le 10^7; 1≤b<d≤1071\le b<d\le 10^7.
  • Subtask 3 (50 points): 1≤a<c≤1091\le a<c\le 10^9; 1≤b<d≤1091\le b<d\le 10^9.

Examples

Input

3 4 5 7

Output

4 6

Explanation

The pair x=4x=4, y=6y=6 satisfies 3<4≤53<4\le5 and 4<6≤74<6\le7. Moreover xy=24xy=24 is divisible by ab=12ab=12. Thus 4 6 is a valid answer, although other answers may exist.