CPython lite logoProblemsContests

G2. Timosh and Number Theory #2 Upsolve

Timosh enjoys inventing problems related to number theory. One day, he claimed to have come up with a difficult challenge. According to the challenge, you are given queries where for each query:

  • Numbers a,b,x,y are given and your task is to find integers L,R such that, in the interval [L,R], the count of numbers divisible by a is x, and the count of numbers divisible by b is y.

Input

The first line contains the number of queries, q(1q105).

Each of the next q lines contains a query with a,b,x,y(1a,b,x,y109).

Output

For each query, if the interval exists, output two numbers 1LR21018.

The solution is guaranteed to exist.

If there are multiple solutions, output any of them.


Sample input 1

2
2 3 5 3
2 3 6 3

Sample output 1

1 10
4 14