# Missing Numbers Codechef Solution | MARCH LONG CHALLENGE Share:

Missing Numbers Codechef Solution

Alice (uniformly and independently) randomly picks two integers a,ba,b from the range [1,104][1,104], and writes down the values of a+ba+b, a−ba−b, a⋅ba⋅b and ⌊ab⌋⌊ab⌋ (integer division) in some random order. Unfortunately, she forgot the values of aa and bb. You need to help her to find out if there exists two integers a,ba,b such that 1≤a,b≤1041≤a,b≤104 and a+ba+b, a−ba−b, a⋅ba⋅b, ⌊ab⌋⌊ab⌋ are the numbers she has written down.

If a solution exists, it is guaranteed to be unique.

### Input Format

• The first line of input contains a single integer TT, denoting the number of testcases. The description of TT testcases follows.
• Each testcase consists of a single line of input, containing four space-separated integers A,B,C,DA,B,C,D — the values written down by Alice. It is guaranteed that at most one of the four numbers A,B,C,DA,B,C,D will be negative.

### Output Format

• For each testcase, output in a single line, separated by a space, the two numbers Alice has chosen in order (i.e, if the solution is a=1a=1 and b=2b=2, print 1 21 2 and not 2 12 1). If there does not exist any such choice of integers, print −1−1 twice, separated by a space, instead.

### Constraints

• 1≤T≤1051≤T≤105
• −109≤A,B,C,D≤109−109≤A,B,C,D≤109
• At most one of A,B,C,DA,B,C,D is negative.

Subtask #1 (100 points): Original constraints

### Sample Input 1

``````2
-1 72 0 17
1 4 5 6
``````

### Sample Output 1

``````8 9
-1 -1
``````

### Explanation

Test case 11: With a=8,b=9a=8,b=9 we obtain 8+9=17,8−9=−1,8⋅9=72,⌊89⌋=08+9=17,8−9=−1,8⋅9=72,⌊89⌋=0 which are exactly the 44 numbers written down by Alice.

Test case 22: It can be shown that no choice of integers a,ba,b can produce the given 44 numbers.