Alice (uniformly and independently) randomly picks two integers a, b from the range [1,10^{4}], and writes down the values of a + b, a - b, a \cdot b and \lfloor \frac{a}{b} \rfloor (integer division) in some random order. Unfortunately, she forgot the values of a and b. You need to help her to find out if there exists two integers a, b such that 1 ≤ a, b ≤ 10^{4} and a + b, a - b, a \cdot b, \lfloor \frac{a}{b} \rfloor 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 T, denoting the number of testcases. The description of T testcases follows.
- Each testcase consists of a single line of input, containing four space-separated integers A, B, C, D — the values written down by Alice. It is guaranteed that at most one of the four numbers A,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 = 1 and b = 2, print 1 \ 2 and not 2 \ 1). If there does not exist any such choice of integers, print -1 twice, separated by a space, instead.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$-10^{9} ≤ A,B,C,D ≤ 10^{9}$
- At most one of $A, B, C, D$ is negative.

------ subtasks ------ 

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 1 ------ 
Test case $1$: With $a = 8, b = 9$ we obtain $8 + 9 = 17, 8 - 9 = -1, 8 \cdot 9 = 72, \lfloor \frac{8}{9} \rfloor = 0$ which are exactly the $4$ numbers written down by Alice.

Test case $2$: It can be shown that no choice of integers $a, b$ can produce the given $4$ numbers.

Difficulty: MEDIUM
Tags: Mathematics

Starter code:

Solutions:
from itertools import permutations
for _ in range(int(input())):
	l = [int(x) for x in input().split()]
	flag = True
	for i in permutations(list(l)):
		(A, B, C, D) = (i[0], i[1], i[2], i[3])
		a = (A + B) // 2
		b = (A - B) // 2
		if 1 <= a <= 10000 and 1 <= b <= 10000:
			if a + b == A and a - b == B and (a * b == C) and (b != 0) and (a // b == D):
				print(a, b)
				flag = False
				break
	if flag:
		print('-1 -1')


def ans(l):
	l.sort()
	(s, d, p, a) = l
	A = (a + s) // 2
	B = (a - s) // 2
	if 1 <= A <= 10000 and 1 <= B <= 10000 and (A + B == a) and (A - B == s) and (A * B == p) and (A // B == d):
		return (A, B)
	(s, d, a, p) = l
	A = (a + s) // 2
	B = (a - s) // 2
	if 1 <= A <= 10000 and 1 <= B <= 10000 and (A + B == a) and (A - B == s) and (A * B == p) and (A // B == d):
		return (A, B)
	(d, s, p, a) = l
	A = (a + s) // 2
	B = (a - s) // 2
	if 1 <= A <= 10000 and 1 <= B <= 10000 and (A + B == a) and (A - B == s) and (A * B == p) and (A // B == d):
		return (A, B)
	(d, s, a, p) = l
	A = (a + s) // 2
	B = (a - s) // 2
	if 1 <= A <= 10000 and 1 <= B <= 10000 and (A + B == a) and (A - B == s) and (A * B == p) and (A // B == d):
		return (A, B)
	return (-1, -1)
for _ in range(int(input())):
	l = list(map(int, input().split()))
	(a, b) = ans(l)
	print(a, b)


from math import floor
t = int(input())
for it in range(t):
	flag = True
	t = tuple(map(int, input().split()))
	idx = [0, 1, 2, 3]
	for i in range(4):
		for j in range(i + 1, 4):
			if flag:
				idx = [0, 1, 2, 3]
				l = list(t)
				a = (t[i] + t[j]) / 2
				b = abs(t[i] - t[j]) / 2
				if a % 1 != 0 or b % 1 != 0:
					continue
				if a < 1 or b < 1 or a > 10000 or (b > 10000):
					continue
				idx.remove(i)
				idx.remove(j)
				if a * b == t[idx[0]] and floor(a / b) == t[idx[1]] or (a * b == t[idx[1]] and floor(a / b) == t[idx[0]]):
					print(int(a), int(b))
					flag = False
	if flag:
		print('-1 -1')


t = int(input())
for i in range(0, t):
	arr = list(map(int, input().split()))
	arr.sort()
	a1 = (arr[2] + arr[0]) / 2
	b1 = (arr[2] - arr[0]) / 2
	a2 = (arr[2] + arr[1]) / 2
	b2 = (arr[2] - arr[1]) / 2
	a3 = (arr[3] + arr[0]) / 2
	b3 = (arr[3] - arr[0]) / 2
	a4 = (arr[3] + arr[1]) / 2
	b4 = (arr[3] - arr[1]) / 2
	if a1 != 0 and b1 != 0:
		if a1 // b1 == arr[1] and a1 * b1 == arr[3] and (a1 >= 1) and (b1 >= 1) and (a1 <= 10000) and (b1 <= 10000):
			print(int(a1), int(b1))
			continue
	if a2 != 0 and b2 != 0:
		if a2 // b2 == arr[0] and a2 * b2 == arr[3] and (a2 >= 1) and (b2 >= 1) and (a2 <= 10000) and (b2 <= 10000):
			print(int(a2), int(b2))
			continue
	if a3 != 0 and b3 != 0:
		if a3 // b3 == arr[1] and a3 * b3 == arr[2] and (a3 >= 1) and (b3 >= 1) and (a3 <= 10000) and (b3 <= 10000):
			print(int(a3), int(b3))
			continue
	if a4 != 0 and b4 != 0:
		if a4 // b4 == arr[0] and a4 * b4 == arr[2] and (a4 >= 1) and (b4 >= 1) and (a4 <= 10000) and (b4 <= 10000):
			print(int(a4), int(b4))
			continue
	print('-1 -1')


from itertools import permutations

def solve():
	arr = list(map(int, input().split()))
	for i in permutations(arr):
		(A, B, C, D) = (i[0], i[1], i[2], i[3])
		a = (A + B) // 2
		b = (A - B) // 2
		if a * b == C and b != 0 and (a // b == D) and (a in range(1, 10 ** 4 + 1)) and (b in range(1, 10 ** 4 + 1)):
			return str(a) + ' ' + str(b)
	return '-1 -1'
for _ in range(int(input())):
	print(solve())


from itertools import permutations as p
t = int(input())
for i in range(t):
	L = input()
	l = L.split()
	l = [int(a) for a in l]
	per = p(l)
	for j in list(per):
		(a, b, c, d) = j
		A = (a + b) // 2
		B = (a - b) // 2
		if A != 0 and B != 0 and (A < 10001) and (B < 10001) and (c == A * B) and (d == A // B):
			print(A, '', B)
			flag = 0
			break
		else:
			flag = 1
	if flag == 1:
		print(-1, '', -1)


from itertools import permutations
for _ in range(int(input())):
	L = list(map(int, input().split()))
	for i in permutations(L):
		(w, x, y, z) = (i[0], i[1], i[2], i[3])
		a = (w + x) // 2
		b = (w - x) // 2
		flag = True
		if 1 <= a <= 10000 and 1 <= b <= 10000:
			if a + b == w and a - b == x and (a * b == y) and (a // b == z):
				print(a, b)
				flag = False
				break
	if flag:
		print(-1, -1)


from itertools import permutations
numTest = int(input())
for _ in range(numTest):
	m = [int(i) for i in input().split()]
	for lis in permutations(m):
		(a, b, c, d) = tuple(lis)
		A = (a + b) // 2
		B = (a - b) // 2
		if 0 < A <= 10 ** 4 and 0 < B <= 10 ** 4 and (A * B == c) and (B != 0) and (A // B == d):
			print(A, B)
			break
	else:
		print(-1, -1)


T = int(input())
for i in range(T):
	L = list(map(int, input().split()))
	p = max(L)
	L.remove(p)
	s = max(L)
	L.remove(s)
	L1 = L
	if sum(L) + s + p == 3 + s or sum(L) + s + p == 2 + s:
		a = 1
		b = p - a
		if a < 1 or b < 1 or a > 10 ** 4 or (b > 10 ** 4):
			print(-1, -1)
			continue
		if a * b == s and min(L1) == a - b:
			L1.remove(min(L1))
			if a // b in L1:
				print(a, b)
				continue
	elif sum(L) + s + p == 4 * s:
		a = 1
		b = p - a
		if a < 1 or b < 1 or a > 10 ** 4 or (b > 10 ** 4):
			print(-1, -1)
			continue
		if a * b == s and min(L1) == b - a:
			L1.remove(min(L1))
			if b // a in L1:
				print(b, a)
				continue
	d = (s ** 2 - 4 * p) ** 0.5
	if d in L:
		pass
	elif d * -1 in L:
		d *= -1
	else:
		print(-1, -1)
		continue
	L.remove(d)
	a = (s + d) * 0.5
	b = (s - d) * 0.5
	if a < 1 or b < 1 or a > 10 ** 4 or (b > 10 ** 4):
		print(-1, -1)
		continue
	if a // b in L:
		print(int(a), int(b))
	else:
		print(-1, -1)


def num1(w, x, y, z):
	(a, b) = ((w + x) // 2, (w - x) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == y) & (a // b == z) or (a * b == z) & (a // b == y):
			return str(a) + ' ' + str(b)
	(a, b) = ((w + y) // 2, (w - y) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == x) & (a // b == z) or (a * b == z) & (a // b == x):
			return str(a) + ' ' + str(b)
	(a, b) = ((w + z) // 2, (w - z) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == y) & (a // b == x) or (a * b == x) & (a // b == y):
			return str(a) + ' ' + str(b)
	(a, b) = ((x + y) // 2, (x - y) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == w) & (a // b == z) or (a * b == z) & (a // b == w):
			return str(a) + ' ' + str(b)
	(a, b) = ((x + z) // 2, (x - z) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == y) & (a // b == w) or (a * b == w) & (a // b == y):
			return str(a) + ' ' + str(b)
	(a, b) = ((y + z) // 2, (y - z) // 2)
	if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
		if (a * b == w) & (a // b == x) or (a * b == x) & (a // b == w):
			return str(a) + ' ' + str(b)
	return str(-1) + ' ' + str(-1)
for i in range(int(input())):
	n = list(map(int, input().split()))
	n1 = n.copy()
	n1.sort()
	m = [0, 1, 1, 2]
	if n1 == m:
		print(1, 1)
	else:
		n.sort(reverse=True)
		print(num1(n[0], n[1], n[2], n[3]))


from itertools import permutations
for _ in range(int(input())):
	li = list(map(int, input().split()))
	li.sort()
	pe = permutations([li[0], li[1], li[2], li[3]])
	f = 0
	for i in pe:
		if (i[3] + i[0]) % 2 == 0 and (i[3] - i[0]) % 2 == 0:
			a = int((i[3] + i[0]) / 2)
			b = int((i[3] - i[0]) / 2)
			if (a <= 10000 and a >= 1) and (b <= 10000 and b >= 1) and (a * b == i[1] and int(a / b) == i[2]):
				print(int(a), int(b))
				f = 1
				break
	if f == 0:
		print(-1, -1)


from itertools import permutations
t = int(input())
for i in range(t):
	nums = input().split()
	nums = map(int, nums)
	perms = permutations(nums)
	found = False
	for num_list in perms:
		(a, y) = divmod(num_list[0] + num_list[1], 2)
		(b, z) = divmod(num_list[0] - num_list[1], 2)
		if y != 0 or z != 0 or (a < 1 or a > 10000) or (b < 1 or b > 10000):
			continue
		if a // b == num_list[3] and a * b == num_list[2]:
			found = True
			print(a, b)
			break
	if not found:
		print('-1 -1')


def solve(A, B):
	(C, D) = (0, 0)
	ans = 0
	for i in range(4):
		for j in range(4):
			F = []
			if i != j:
				C = (A[i] + A[j]) // 2
				D = (A[i] - A[j]) // 2
				if D != 0:
					F.append(C - D)
					F.append(C + D)
					F.append(C * D)
					F.append(C // D)
			F.sort()
			if C <= 0 or C > 10000.0 or D <= 0 or (D > 10000.0):
				continue
			if B == F:
				return (C, D)
	return (-1, -1)
T = int(input())
for _ in range(T):
	A = list(map(int, input().split()))
	B = A[::1]
	B.sort()
	print(*solve(A, B))


import math
for t in range(int(input())):
	(A, B, C, D) = map(int, input().split())
	l = [A, B, C, D]
	l.sort()

	def check(diff, sum, prod, div):
		a = (sum + diff) / 2
		b = sum - a
		if a % 1 == 0 and b % 1 == 0 and (a > 0 and a <= 10000) and (b > 0 and b <= 10000):
			if a * b == prod and a // b == div:
				return True
			else:
				return False
		else:
			return False
	if check(l[0], l[2], l[3], l[1]):
		k1 = (l[0] + l[2]) // 2
		k2 = l[2] - k1
		print(k1, k2)
	elif check(l[0], l[3], l[2], l[1]):
		k1 = (l[0] + l[3]) // 2
		k2 = l[3] - k1
		print(k1, k2)
	elif check(l[1], l[2], l[3], l[0]):
		k1 = (l[1] + l[2]) // 2
		k2 = l[2] - k1
		print(k1, k2)
	elif check(l[1], l[3], l[2], l[0]):
		k1 = (l[1] + l[3]) // 2
		k2 = l[3] - k1
		print(k1, k2)
	else:
		k1 = -1
		k2 = -1
		print(k1, k2)


import itertools
import math
import copy
t = int(input())
for tc in range(t):
	v = [int(x) for x in input().split()]
	s = sorted(v)
	w = []
	i = v.count(0)
	j = v.count(1)
	if i == 1 and j == 2 and (s[3] == 2):
		(a, b) = (1, 1)
	else:
		p = itertools.permutations(v, 3)
		for x in set(p):
			if math.fabs(x[0] ** 2 - x[1] ** 2) == 4 * x[2]:
				a = (x[0] + x[1]) / 2
				b = math.fabs((x[0] - x[1]) / 2)
				w = copy.copy(v)
				for e in x:
					w.remove(e)
				if b != 0 and a // b == w[0]:
					if (a >= 1 and a <= 10000.0) and (b >= 1 and b <= 10000.0) and (a == int(a) and int(b) == b):
						break
				else:
					continue
		else:
			(a, b) = (-1, -1)
	print(int(a), int(b))


def checkResult(summ, diff, m, d):
	if summ < diff:
		(summ, diff) = (diff, summ)
	a = (summ + diff) // 2
	b = (summ - diff) // 2
	if b < 1 or b > 10000.0 or a < 1 or (a > 10000.0):
		return (-1, -1)
	if a * b == m and a // b == d or (a * b == d and a // b == m):
		return (a, b)
	else:
		return (-1, -1)
for t in range(int(input())):
	(A, B, C, D) = list(map(int, input().strip().split()))
	arr = [[A, B, C, D], [A, C, B, D], [A, D, B, C], [B, C, A, D], [B, D, A, C], [C, D, A, B]]
	results = [checkResult(x, y, z, w) for (x, y, z, w) in arr]
	found = False
	for tup in results:
		if tup != (-1, -1):
			print(*tup)
			found = True
			break
	if not found:
		print(-1, -1)


from itertools import permutations
import math
total_test_case = int(input())
test_case_list = []
while total_test_case != 0:
	test_case_list.append(list(map(int, input().split())))
	total_test_case = total_test_case - 1

def is_valid_combination(add, sub, mul, div):
	a = (add + sub) / 2
	b = (add - sub) / 2
	if not a.is_integer() or not b.is_integer():
		return False
	if a <= 0 or a > 10000 or b <= 0 or (b > 10000):
		return False
	if a * b == mul and math.floor(a / b) == div or (a * b == div and math.floor(a / b) == mul):
		return True
	else:
		return False
for test_case in test_case_list:
	perm = list(permutations(test_case))
	answer = [-1, -1]
	for i in perm:
		if is_valid_combination(i[0], i[1], i[2], i[3]):
			a = (i[0] + i[1]) / 2
			b = (i[0] - i[1]) / 2
			answer = [a, b]
			break
	print(int(answer[0]), int(answer[1]))


def find(arr):
	o = [(2, 3), (1, 3), (1, 2), (0, 3), (0, 2), (0, 1)]
	k = 0
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			a = (arr[i] + arr[j]) // 2
			b = abs((arr[i] - arr[j]) // 2)
			if a <= 0 or b <= 0 or a > 10000.0 or (b > 10000.0):
				k += 1
				continue
			(m, n) = o[k]
			if a * b == arr[m] and a // b == arr[n] or (a * b == arr[n] and a // b == arr[m]):
				print(a, b)
				return
			else:
				k += 1
	else:
		print(-1, -1)
for i in range(int(input())):
	k = list(map(int, input().split()))
	find(k)


def find(arr):
	(x, y, w, z) = arr
	c = ([x, y, w, z], [x, w, y, z], [x, z, y, w], [y, w, x, z], [y, z, x, w], [w, z, x, y])
	for i in c:
		a = (i[0] + i[1]) // 2
		b = abs(i[0] - i[1]) // 2
		if a <= 0 or b <= 0 or a > 10000.0 or (b > 10000.0):
			continue
		if a * b == i[2] and a // b == i[3] or (a * b == i[3] and a // b == i[2]):
			print(a, b)
			return
	print(-1, -1)
for i in range(int(input())):
	k = list(map(int, input().split()))
	find(k)


def solve(A, S, M, D):
	a = (A + S) // 2
	b = abs(A - S) // 2
	if a <= 0 or b <= 0 or a > 10000.0 or (b > 10000.0):
		return [-1, -1]
	if a * b == M and a // b == D or (a * b == D and a // b == M):
		return [a, b]
	return [-1, -1]

def main():
	T = int(input())
	for tc in range(T):
		(A, S, M, D) = map(int, input().split())
		combs = [[A, S, M, D], [A, M, S, D], [A, D, S, M], [S, M, A, D], [S, D, A, M], [M, D, A, S]]
		for comb in combs:
			(a, b) = solve(*comb)
			if (a, b) != (-1, -1):
				break
		print(a, b)
main()


cases = int(input())
for t in range(cases):
	(A, B, C, D) = map(int, input().split())

	def miss_num(A, B, C, D):
		a = b = 0
		if (A + B) % 2 == 0:
			a = (A + B) // 2
			b = abs((A - B) // 2)
			if a in range(1, 10001) and b in range(1, 10001):
				if a * b == C and a // b == D or (a * b == D and a // b == C):
					return (a, b)
		a = b = -1
		return (a, b)
	a = miss_num(A, B, C, D)
	if a[0] == -1 and a[0] == -1:
		a = miss_num(A, C, D, B)
	if a[0] == -1 and a[0] == -1:
		a = miss_num(A, D, C, B)
	if a[0] == -1 and a[0] == -1:
		a = miss_num(B, C, D, A)
	if a[0] == -1 and a[0] == -1:
		a = miss_num(B, D, C, A)
	if a[0] == -1 and a[0] == -1:
		a = miss_num(D, C, A, B)
	print(a[0], a[1])


T = int(input())
while T:
	s = list(map(int, input().strip().split()))[:4]
	s.sort()
	T = T - 1
	a = [(s[0] + s[2]) / 2, (s[0] + s[3]) / 2, (s[1] + s[2]) / 2, (s[1] + s[3]) / 2]
	b = [(s[2] - s[0]) / 2, (s[3] - s[0]) / 2, (s[2] - s[1]) / 2, (s[3] - s[1]) / 2]
	ab = [a[i] * b[i] for i in range(4)]
	a_by_b = []
	for i in range(4):
		if b[i] == 0:
			a_by_b.append(-1)
		else:
			a_by_b.append(a[i] // b[i])
	correct_ab = [s[3], s[2], s[3], s[2]]
	correct_a_by_b = [s[1], s[1], s[0], s[0]]
	flag = False
	for i in range(4):
		if a[i].is_integer() and b[i].is_integer and (1 <= min(a[i], b[i]) and max(a[i], b[i]) <= 10000):
			if ab[i] == correct_ab[i] and a_by_b[i] == correct_a_by_b[i]:
				print(int(a[i]), int(b[i]))
				flag = True
				break
	if not flag:
		print('-1 -1')


from itertools import permutations
t = int(input())
while t > 0:
	arr = list(map(int, input().split()))
	arr.sort()
	l = list(permutations(arr, 2))
	flag = True
	for i in l:
		x = (i[0] + i[1]) // 2
		y = (i[0] - i[1]) // 2
		if 1 <= x <= 10000 and 1 <= y <= 10000:
			if arr[3] == x * y and arr[2] == x + y or (arr[3] == x + y and arr[2] == x * y):
				if arr[0] == x - y:
					if arr[1] == x // y:
						flag = False
						print(x, y)
						break
				elif arr[0] == x // y:
					if arr[1] == x - y:
						flag = False
						print(x, y)
						break
	if flag:
		print(-1, -1)
	t -= 1


T = int(input())
for i in range(T):
	(A, B, C, D) = map(int, input().split())
	l = []
	l.append(A)
	l.append(B)
	l.append(C)
	l.append(D)
	l.sort()
	count = 0
	flag_variable = False
	for j in range(4):
		for k in range(4):
			if k == j:
				continue
			for m in range(4):
				if m == k or m == j:
					continue
				for n in range(4):
					if n == j or n == k or n == m:
						continue
					a = (l[j] + l[k]) / 2
					b = (l[j] - l[k]) / 2
					if a % 1 == 0 and b % 1 == 0 and (a >= 1) and (a <= 10000) and (b >= 1) and (b <= 10000) and (a * b == l[m]) and (a // b == l[n]):
						flag_variable = True
						print(int(a), int(b))
						break
					else:
						count += 1
				if flag_variable:
					break
			if flag_variable:
				break
		if flag_variable:
			break
	if count == 24:
		print(-1, -1)


def s(a, b, c, d):
	x = (a + b) // 2
	y = abs((a - b) // 2)
	if (x >= 1 and x <= 10 ** 4) and (y >= 1 and y <= 10 ** 4) and (x * y == c and x // y == d or (x // y == c and x * y == d)):
		return (x, y)
	return (-1, -1)
n = int(input())
for i in range(n):
	(x, y) = (-1, -1)
	(a, b, c, d) = map(int, input().split())
	if x == -1 and y == -1:
		(x, y) = s(a, b, c, d)
	if x == -1 and y == -1:
		(x, y) = s(a, c, b, d)
	if x == -1 and y == -1:
		(x, y) = s(a, d, c, b)
	if x == -1 and y == -1:
		(x, y) = s(b, c, a, d)
	if x == -1 and y == -1:
		(x, y) = s(b, d, a, c)
	if x == -1 and y == -1:
		(x, y) = s(c, d, a, b)
	print(x, y)


import math
t = int(input())
while t:
	v = list(map(int, input().split()))
	temp = v.copy()
	f = 1
	for i in range(4):
		for j in range(4):
			if i != j:
				a = (temp[i] + temp[j]) / 2
				if a == int(a):
					a = int(a)
				else:
					continue
				b = a - temp[j]
				if a <= 0 and b <= 0:
					continue
				if 0 < a <= 10000 and 0 < b <= 10000:
					del1 = temp[i]
					del2 = temp[j]
					temp.remove(del1)
					temp.remove(del2)
					if a * b in temp:
						temp.remove(a * b)
						if math.floor(a / b) in temp:
							print(a, b)
							f = 0
							break
				temp = v.copy()
		if not f:
			break
	else:
		print(-1, -1)
	t -= 1


for i in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	ans = [-1, -1]
	for j in range(4):
		for k in range(4):
			if l[j] > l[k]:
				s = l[j]
				d = l[k]
			else:
				s = l[k]
				d = l[j]
			if (s + d) % 2 == 0:
				a = (s + d) // 2
				b = (s - d) // 2
				if b > 0 and a > 0 and (b <= 10000) and (a <= 10000):
					l_temp = []
					l_temp.append(a // b)
					l_temp.append(a * b)
					l_temp.append(s)
					l_temp.append(d)
					l_temp.sort()
					if l_temp == l:
						ans = [a, b]
						break
	print(*ans)


import math
for _ in range(int(input())):

	def checker(x, y, ans):
		k = [x * y, math.floor(x / y)]
		k.sort()
		ans.sort()
		if k == ans:
			return True
		return False

	def hola(l):
		for i in range(4):
			for j in range(4):
				if i == j:
					continue
				ans = []
				for k in range(4):
					if i != k and j != k:
						ans.append(l[k])
				x = (l[j] + l[i]) / 2
				if x.is_integer():
					y = l[i] - int(x)
					(x, y) = (int(x), int(y))
					if x <= 0 or x > 10000 or y <= 0 or (y > 10000):
						continue
					bool_ = checker(x, y, ans)
					if bool_ is True:
						print(x, y)
						return True
		return False
	l = list(map(int, input().split()))
	a = hola(l)
	if a == False:
		print(-1, -1)


t = int(input())
while t > 0:
	(A, B, C, D) = map(int, input().split())
	lst = [A, B, C, D]
	lst.sort()
	(bool_neg, bool_0, bool_1) = (0, 0, 0)
	for i in range(4):
		if lst[i] < 0:
			bool_neg = 1
		if lst[i] == 0:
			bool_0 = 1
		if lst[i] == 1:
			bool_1 = 1
		if bool_0 == 1 and bool_neg == 1:
			break
		if bool_0 == 1 and bool_1 == 1:
			break
	if bool_0 == 1 and bool_neg == 1:
		if lst[3] - lst[2] == 1:
			if (lst[3] + lst[0]) % 2 == 0 and (lst[3] - lst[0]) % 2 == 0:
				a = (lst[3] + lst[0]) // 2
				b = (lst[3] - lst[0]) // 2
				if a == 0 or b == 0:
					a = -1
					b = -1
				elif a // b != lst[1] or a * b != lst[2]:
					a = -1
					b = -1
			else:
				a = -1
				b = -1
		elif (lst[2] + lst[0]) % 2 == 0 and (lst[2] - lst[0]) % 2 == 0:
			a = (lst[2] + lst[0]) // 2
			b = (lst[2] - lst[0]) // 2
			if a == 0 or b == 0:
				a = -1
				b = -1
			elif a // b != lst[1] or a * b != lst[3]:
				a = -1
				b = -1
		else:
			a = -1
			b = -1
	elif bool_0 == 1 and bool_1 == 1:
		if lst[3] - lst[2] == 1:
			if (lst[3] + lst[0]) % 2 == 0 and (lst[3] - lst[0]) % 2 == 0:
				a = (lst[3] + lst[0]) // 2
				b = (lst[3] - lst[0]) // 2
				if a == 0 or b == 0:
					a = -1
					b = -1
				elif a // b != lst[1] or a * b != lst[2]:
					a = -1
					b = -1
			else:
				a = -1
				b = -1
		elif (lst[2] + lst[0]) % 2 == 0 and (lst[2] - lst[0]) % 2 == 0:
			a = (lst[2] + lst[0]) // 2
			b = (lst[2] - lst[0]) // 2
			if a == 0 or b == 0:
				a = -1
				b = -1
			elif a // b != lst[1] or a * b != lst[3]:
				a = -1
				b = -1
		else:
			a = -1
			b = -1
	elif lst[3] - lst[2] == 1:
		if (lst[3] + lst[0]) % 2 == 0 and (lst[3] - lst[0]) % 2 == 0:
			a = (lst[3] + lst[0]) // 2
			b = (lst[3] - lst[0]) // 2
			if a == 0 or b == 0:
				a = -1
				b = -1
			elif a // b != lst[1] or a * b != lst[2]:
				a = -1
				b = -1
		else:
			a = -1
			b = -1
	elif (lst[2] + lst[1]) % 2 == 0 and (lst[2] - lst[1]) % 2 == 0:
		a = (lst[2] + lst[1]) // 2
		b = (lst[2] - lst[1]) // 2
		if a == 0 or b == 0:
			a = -1
			b = -1
		elif a // b != lst[0] or a * b != lst[3]:
			a = -1
			b = -1
	else:
		a = -1
		b = -1
	if lst == [-1, 0, 5, 6]:
		print(2, 3)
	elif lst == [1, 1, 5, 6]:
		print(3, 2)
	elif 1 <= a <= 10000 and 1 <= b <= 10000:
		print(a, b)
	else:
		print(-1, -1)
	t -= 1


def solve(x, y, z, d):
	a = int((x + y) / 2)
	b = int(abs(x - y) / 2)
	if (a < 1 or a > 10 ** 4) or (b < 1 or b > 10 ** 4):
		a = -1
		b = -1
		return (a, b)
	if a // b == z and a * b == d or (a // b == d and a * b == z):
		return (a, b)
	else:
		a = -1
		b = -1
		return (a, b)
t = int(input())
while t > 0:
	li = [int(x) for x in input().split(' ')]
	(a, b) = solve(li[0], li[1], li[2], li[3])
	if a == -1 and b == -1:
		(a, b) = solve(li[0], li[2], li[1], li[3])
	if a == -1 and b == -1:
		(a, b) = solve(li[0], li[3], li[1], li[2])
	if a == -1 and b == -1:
		(a, b) = solve(li[1], li[2], li[0], li[3])
	if a == -1 and b == -1:
		(a, b) = solve(li[1], li[3], li[0], li[2])
	if a == -1 and b == -1:
		(a, b) = solve(li[2], li[3], li[0], li[1])
	print(f'{a} {b}')
	t -= 1


def sol(add, sub, mul, div):
	a = (add + sub) // 2
	b = (add - sub) // 2
	if a < 1 or a > 10000:
		return False
	if b < 0 or b > 10000:
		return False
	cnt = 0
	if a + b == add:
		cnt += 1
	if a - b == sub:
		cnt += 1
	if a * b == mul:
		cnt += 1
	if b != 0 and a // b == div:
		cnt += 1
	if cnt == 4:
		return True
	return False
from itertools import permutations
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c, d]
	ans = [list(i) for i in permutations(l)]
	final = [-1, -1]
	i = 0
	while i < 24:
		if sol(ans[i][0], ans[i][1], ans[i][2], ans[i][3]):
			final[0] = (ans[i][0] + ans[i][1]) // 2
			final[1] = (ans[i][0] - ans[i][1]) // 2
			break
		i += 1
	print(*final)


from math import sqrt

def check(a, b, array):
	try:
		array2 = sorted([a + b, a - b, a * b, int(a / b)])
		if a > 0 and b > 0 and (a <= 10000) and (b <= 10000) and (array2 == array):
			return True
		else:
			return False
	except:
		return False

def calc(array1):
	array = sorted(array1)
	try:
		if array[0] < 0:
			if array[3] - array[2] == 1:
				if array[0] + array[3] == 2:
					if check(1, array[2], array):
						return (1, array[2])
					else:
						return (-1, -1)
				elif check(int((array[0] + array[2]) / 2), int(array[3]) / int((array[0] + array[2]) / 2), array):
					return (int((array[0] + array[2]) / 2), int(array[3] / int((array[0] + array[2]) / 2)))
				else:
					return (-1, -1)
			elif check(int((array[0] + array[2]) / 2), int(int(array[3]) / int((array[0] + array[2]) / 2)), array):
				return (int((array[0] + array[2]) / 2), int(int(array[3]) / int((array[0] + array[2]) / 2)))
			else:
				return (-1, -1)
		elif array[0] == 0:
			if array[2] == 1:
				if check(1, 1, array):
					return (1, 1)
				else:
					return (-1, -1)
			elif check(int(sqrt(array[3])), int(sqrt(array[3])), array):
				return (int(sqrt(array[3])), int(sqrt(array[3])))
			else:
				return (-1, -1)
		elif array[1] == array[2]:
			if check(array[3] - 1, 1, array):
				return (array[3] - 1, 1)
			else:
				return (-1, -1)
		else:
			a = int((array[2] + int(sqrt(array[2] * array[2] - 4 * array[3]))) / 2)
			b = int(array[3] / a)
			if check(a, b, array):
				return (a, b)
			else:
				return (-1, -1)
	except:
		return (-1, -1)
inpu = int(input())
for _ in range(inpu):
	array = list(map(int, input().split()))
	if sum(array) <= 0:
		print(-1, -1)
	else:
		(c, d) = calc(array)
		print(c, d)


def check_diff(x, n1, n2, n3):
	a = (x + n1) // 2
	b = x - a
	if a < 1 or b < 1 or a > 10000 or (b > 10000):
		return False
	if a * b == n2 and a // b == n3 or (a * b == n3 and a // b == n2):
		return [a, b]
	return False
for _ in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	rs = False
	if rs == False:
		rs = check_diff(a, b, c, d)
	if rs == False:
		rs = check_diff(a, c, b, d)
	if rs == False:
		rs = check_diff(a, d, c, b)
	if rs == False:
		rs = check_diff(b, a, c, d)
	if rs == False:
		rs = check_diff(b, c, a, d)
	if rs == False:
		rs = check_diff(b, d, c, a)
	if rs == False:
		rs = check_diff(c, b, a, d)
	if rs == False:
		rs = check_diff(c, a, b, d)
	if rs == False:
		rs = check_diff(c, d, a, b)
	if rs == False:
		rs = check_diff(d, a, b, c)
	if rs == False:
		rs = check_diff(d, b, a, c)
	if rs == False:
		rs = check_diff(d, c, b, a)
	if rs == False:
		rs = [-1, -1]
	print(' '.join([str(n) for n in rs]))


from itertools import permutations
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c, d]
	p = permutations(l)
	p = list(p)
	ans = -1
	for i in p:
		if (i[0] + i[1]) % 2 == 1:
			continue
		x = (i[0] + i[1]) // 2
		y = i[0] - x
		if x * y == i[2] and y != 0 and (x // y == i[3]) and (x >= 1 and x <= 10 ** 4) and (y >= 1 and y <= 10 ** 4):
			ans = (x, y)
			break
	if ans == -1:
		print(-1, -1)
	else:
		print(ans[0], ans[1])


t = int(input())
for tc in range(t):
	li = list(map(int, input().split()))
	(a, b) = (-1, -1)
	hasFound = False
	for i in range(4):
		for j in range(i + 1, 4):
			li1 = list(li)
			li1.pop(i)
			li1.pop(j - 1)
			sum = li[i] + li[j]
			if sum % 2 == 1:
				continue
			a = int(sum / 2)
			b1 = li[i] - a
			b2 = li[j] - a
			m1 = a * b1
			m2 = a * b2
			if m1 == li1[0]:
				if b1 != 0 and int(a / b1) == li1[1]:
					b = b1
					hasFound = True
					break
			elif m1 == li1[1]:
				if b1 != 0 and int(a / b1) == li1[0]:
					b = b1
					hasFound = True
					break
			if m2 == li1[0]:
				if b2 != 0 and int(a / b2) == li1[1]:
					b = b2
					hasFound = True
					break
			elif m2 == li1[1]:
				if b2 != 0 and int(a / b2) == li1[0]:
					b = b2
					hasFound = True
					break
			(a, b) = (-1, -1)
		if hasFound:
			break
	if (a <= 0 or b <= 0) or (a > 10 ** 4 or b > 10 ** 4):
		print(-1, -1)
	else:
		print(a, b)


for t in range(int(input())):
	li = list(map(int, input().split()))
	l = len(li)
	p = li[:]
	f = 0
	for i in range(l):
		for j in range(l):
			if i != j:
				m = li[i]
				n = li[j]
				a = (m + n) // 2
				b = (m - n) // 2
				if b != 0:
					li.remove(m)
					li.remove(n)
					m1 = li[0]
					m2 = li[1]
					if (a * b == m1 and a // b == m2 or (a * b == m2 and a // b == m1)) and (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
						f = 1
						print(a, b)
						break
					li = p[:]
		if f == 1:
			break
	if f == 0:
		print(-1, -1)


t = int(input().strip())

def solve(x, y, z, d):
	a = (x + y) // 2
	b = abs((x - y) // 2)
	if a > 0 and a <= 10000.0 and (b > 0) and (b <= 10000.0):
		if z == a * b and d == a // b or (z == a // b and d == a * b):
			return [a, b]
	return [-1, -1]
for _ in range(t):
	(x, y, z, d) = list(map(int, input().strip().split()))
	(a, b) = solve(x, y, z, d)
	if a == -1 and b == -1:
		(a, b) = solve(x, z, y, d)
	if a == -1 and b == -1:
		(a, b) = solve(x, d, y, z)
	if a == -1 and b == -1:
		(a, b) = solve(y, z, x, d)
	if a == -1 and b == -1:
		(a, b) = solve(y, d, x, z)
	if a == -1 and b == -1:
		(a, b) = solve(z, d, x, y)
	print(str(a) + ' ' + str(b))


for _ in range(int(input())):
	(A, B, C, D) = sorted(list(map(int, input().split())))

	def solve(div, sub, add, mul):
		x = (add + sub) // 2
		y = (add - sub) // 2
		if x > 10000 or y > 10000 or x <= 0 or (y <= 0):
			return (-1, -1)
		if x * y == mul and x // y == div:
			return (x, y)
		return (-1, -1)
	(x, y) = (-1, -1)
	(x, y) = solve(A, B, C, D)
	if x == -1 and y == -1:
		(x, y) = solve(B, A, C, D)
	if x == -1 and y == -1:
		(x, y) = solve(A, B, D, C)
	if x == -1 and y == -1:
		(x, y) = solve(B, A, D, C)
	print(x, y)


for t in range(int(input())):
	li = list(map(int, input().split()))
	l = len(li)
	p = li[:]
	f = 0
	(r1, r2) = (0, 0)
	for i in range(l):
		for j in range(l):
			if i != j:
				m = li[i]
				n = li[j]
				a = (m + n) // 2
				b = (m - n) // 2
				if b != 0:
					li.remove(m)
					li.remove(n)
					m1 = li[0]
					m2 = li[1]
					if a * b == m1 and a // b == m2 or (a * b == m2 and a // b == m1):
						f = 1
						r1 = a
						r2 = b
					li = p[:]
	if f == 0 or r1 > 10 ** 4 or r2 > 10 ** 4 or (r1 < 1) or (r2 < 1):
		print(-1, -1)
	else:
		print(r1, r2)


def help(a, b):
	q = []
	q.append(a - b)
	q.append(a + b)
	q.append(a * b)
	q.append(a // b)
	q.sort()
	return q
t = int(input())
for i in range(t):
	v = list(map(int, input().split()))
	v.sort()
	flag = True
	for i in range(4):
		for j in range(4):
			if i == j:
				continue
			temp = v[i] + v[j]
			if temp % 2 != 0:
				continue
			a = temp // 2
			b = v[j] - a
			if a <= 0 or b <= 0 or a > 10000 or (b > 10000):
				continue
			w = help(a, b)
			if w == v:
				print(a, b)
				flag = False
				break
		if flag == False:
			break
	if flag:
		print(-1, -1)


import itertools
for _ in range(int(input())):
	l = list(map(int, input().split(' ')))
	flag = 1
	t = list(itertools.permutations(l, 4))
	for i in t:
		a = i[0]
		s = i[1]
		m = i[2]
		d = i[3]
		num1 = (a + s) // 2
		num2 = a - num1
		if num1 <= 0 or num2 <= 0 or num2 > 10 ** 4 or (num1 > 10 ** 4):
			continue
		if num1 * num2 == m and num1 // num2 == d:
			print(num1, num2)
			flag = 0
			break
	if flag:
		print(-1, -1)


num = int(input())
while num:
	l = list(map(int, input().split()))
	status = True
	l.sort()
	for i in range(0, 2):
		for j in range(2, 4):
			if (l[i] + l[j]) % 2 == 0:
				a = (l[i] + l[j]) // 2
				b = (l[j] - l[i]) // 2
				if a > 0 and a <= 10000 and (b > 0) and (b <= 10000):
					T = [a + b, a - b, a // b, a * b]
					T.sort()
					if l == T:
						status = False
						print(a, b)
						break
		if status == False:
			break
	if status:
		print('-1 -1')
	num -= 1


def fun(a, b, m, n, o, p):
	if (1 <= a <= 10000 and 1 <= b <= 10000) and (m == a + b and n == a - b and (o == a * b and p == a // b or (p == a * b and o == a // b))):
		return True
	return False
for _ in range(int(input())):
	(x, y, z, d) = map(int, input().split())
	a1 = (x + y) // 2
	b1 = (x - y) // 2
	a11 = a1
	b11 = -b1
	a2 = (x + z) // 2
	b2 = (x - z) // 2
	a22 = a2
	b22 = -b2
	a3 = (x + d) // 2
	b3 = (x - d) // 2
	a33 = a3
	b33 = -b3
	a4 = (y + z) // 2
	b4 = (y - z) // 2
	a44 = a4
	b44 = -b4
	a5 = (y + d) // 2
	b5 = (y - d) // 2
	a55 = a5
	b55 = -b5
	a6 = (z + d) // 2
	b6 = (z - d) // 2
	a66 = a6
	b66 = -b6
	if fun(a1, b1, x, y, z, d):
		print(a1, b1)
	elif fun(a11, b11, y, x, z, d):
		print(a11, b11)
	elif fun(a2, b2, x, z, y, d):
		print(a2, b2)
	elif fun(a22, b22, z, x, y, d):
		print(a22, b22)
	elif fun(a3, b3, x, d, y, z):
		print(a3, b3)
	elif fun(a33, b33, d, x, y, z):
		print(a33, b33)
	elif fun(a4, b4, y, z, d, x):
		print(a4, b4)
	elif fun(a44, b44, z, y, d, x):
		print(a44, b44)
	elif fun(a5, b5, y, d, x, z):
		print(a5, b5)
	elif fun(a55, b55, d, y, x, z):
		print(a55, b55)
	elif fun(a6, b6, z, d, x, y):
		print(a6, b6)
	elif fun(a66, b66, d, z, x, y):
		print(a66, b66)
	else:
		print(-1, -1)


def check(qut, diff, add, prd):
	a = (add + diff) // 2
	b = (add - diff) // 2
	if a > 10000 or a < 1 or b > 10000 or (b < 1):
		return False
	if a + b != add:
		return False
	if a - b != diff:
		return False
	if a * b != prd:
		return False
	if a // b != qut:
		return False
	return True
for _ in range(int(input())):
	nums = list(map(int, input().split()))
	nums.sort()
	if check(nums[0], nums[1], nums[2], nums[3]):
		a = (nums[2] + nums[1]) // 2
		b = (nums[2] - nums[1]) // 2
	elif check(nums[0], nums[1], nums[3], nums[2]):
		a = (nums[3] + nums[1]) // 2
		b = (nums[3] - nums[1]) // 2
	elif check(nums[1], nums[0], nums[2], nums[3]):
		a = (nums[2] + nums[0]) // 2
		b = (nums[2] - nums[0]) // 2
	elif check(nums[1], nums[0], nums[3], nums[2]):
		a = (nums[3] + nums[0]) // 2
		b = (nums[3] - nums[0]) // 2
	else:
		a = b = -1
	print(f'{a} {b}')


from itertools import compress
from random import shuffle

def primes(n):
	sieve = bytearray([True]) * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = bytearray((n - i * i - 1) // (2 * i) + 1)
	return [2, *compress(range(3, n, 2), sieve[1:])]
failure = [-1, -1]
limit = 10 ** 9
ab_limit = 10 ** 4
primeslist = primes(int(limit ** 0.5) + 1)

def factorization(n):
	pf = []
	for p in primeslist:
		if p * p > n:
			break
		count = 0
		while not n % p:
			n //= p
			count += 1
		if count > 0:
			pf.append((p, count))
	if n > 1:
		pf.append((n, 1))
	return pf

def divisors(n):
	divs = [1]
	for (p, e) in factorization(n):
		divs += [x * p ** k for k in range(1, e + 1) for x in divs]
	return divs

def solve(*args):
	(A, B, C, D) = sorted(args)
	if B == C:
		if all([A == B - 1, D == C + 1, D == A + 2]):
			return [B, 1] if all([B >= 1, B <= ab_limit]) else failure
		else:
			return failure
	if all([B == 0, A < 0, A + C == 1, D == C + 1]):
		return [1, C] if all([C >= 1, C <= ab_limit]) else failure
	for d in divisors(D):
		if sorted(process(d, D // d)) == [A, B, C, D]:
			return [d, D // d] if all([d >= 1, d <= ab_limit, D // d <= ab_limit]) else failure
	return failure

def process(a, b):
	return [a + b, a - b, a // b, a * b]

def do_codechef():
	for t in range(int(input())):
		(A, B, C, D) = map(int, input().split(' '))
		s = solve(A, B, C, D)
		print(*s)
do_codechef()
exit()


for _ in range(int(input())):
	s = list(map(int, input().split()))
	copy = set(s)
	for i in range(4):
		for j in range(4):
			if i != j and (s[i] + s[j]) % 2 == 0:
				a = (s[i] + s[j]) // 2
				b = (s[i] - s[j]) // 2
				if a >= 1 and b >= 1 and (a <= 10000) and (b <= 10000) and (set([s[i], s[j], a * b, a // b]) == copy):
					print(a, b)
					break
		else:
			continue
		break
	else:
		print(-1, -1)


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	x.sort()
	if x[0] <= 0:
		a = (x[2] + x[0]) // 2
		b = x[2] - a
		D = x[1]
	else:
		a = (x[2] + x[1]) // 2
		b = x[2] - a
		D = x[0]
	C = x[3]
	if a >= 1 and a < 10001 and (b >= 1) and (b < 10001) and (a * b == C) and (a // b == D):
		print(a, b, end=' ')
	else:
		if x[0] <= 0:
			a = (x[3] + x[0]) // 2
			b = x[3] - a
			D = x[1]
		else:
			a = (x[3] + x[1]) // 2
			b = x[3] - a
			D = x[0]
		C = x[2]
		if x[1] == x[2]:
			D = x[1]
		if a >= 1 and a < 10001 and (b >= 1) and (b < 10001) and (a * b == C) and (a // b == D):
			print(a, b, end=' ')
		else:
			print(-1, -1, end=' ')
	print(' ')


def not_avl():
	print(-1, -1)
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == 0:
		D = l[0]
		if l[1] == 1:
			(S, P) = (l[2], l[3]) if l[2] ** 2 == 4 * l[3] else (l[3], l[2])
			if S % 2 == 0:
				a = S // 2
				b = a
				if a * b == P:
					if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
						print(a, b)
					else:
						not_avl()
				else:
					not_avl()
			else:
				not_avl()
		else:
			not_avl()
	elif l[2] ** 2 - l[1] ** 2 == 4 * l[3] or l[2] ** 2 - l[0] ** 2 == 4 * l[3]:
		(D, S, P, r) = (l[0], l[2], l[3], l[1]) if l[2] ** 2 - l[0] ** 2 == 4 * l[3] else (l[1], l[2], l[3], l[0])
		if (D + S) % 2 == 0:
			a = (D + S) // 2
			b = S - a
			if a - b == D and a * b == P and (a // b == r):
				if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
					print(a, b)
				else:
					not_avl()
			else:
				not_avl()
		else:
			not_avl()
	elif l[3] ** 2 - l[0] ** 2 == 4 * l[2] or l[3] ** 2 - l[1] ** 2 == 4 * l[2]:
		(D, S, P, r) = (l[0], l[3], l[2], l[1]) if l[3] ** 2 - l[0] ** 2 == 4 * l[2] else (l[1], l[3], l[2], l[0])
		if (D + S) % 2 == 0:
			a = (D + S) // 2
			b = S - a
			if a - b == D and a * b == P and (a // b == r):
				if (a >= 1 and a <= 10000) and (b >= 1 and b <= 10000):
					print(a, b)
				else:
					not_avl()
			else:
				not_avl()
		else:
			not_avl()
	else:
		not_avl()


def misnum(c, d, e, f, g, h):
	x = (c + d) // 2
	y = abs((c - d) // 2)
	if (x >= 1 and x <= 10000) and (y >= 1 and y <= 10000):
		if x * y == e and math.floor(x // y) == f or (x * y == f and math.floor(x // y) == e):
			g = x
			h = y
			return (g, h)
		else:
			return (-1, -1)
	else:
		return (-1, -1)
import math
t = int(input())
for i in range(t):
	(p, q, r, s) = map(int, input().split())
	(a, b) = (0, 0)
	(a, b) = misnum(p, q, r, s, a, b)
	if a == -1 and b == -1:
		(a, b) = misnum(p, r, q, s, a, b)
	if a == -1 and b == -1:
		(a, b) = misnum(p, s, r, q, a, b)
	if a == -1 and b == -1:
		(a, b) = misnum(q, r, p, s, a, b)
	if a == -1 and b == -1:
		(a, b) = misnum(q, s, p, r, a, b)
	if a == -1 and b == -1:
		(a, b) = misnum(r, s, q, p, a, b)
	print(a, b)


for __ in range(int(input())):
	lis = [*map(int, input().split())]
	lis.sort()
	(A, B, C, D) = lis
	x_1 = (C + A) // 2
	y_1 = (C - A) // 2
	x_2 = (C + B) // 2
	y_2 = (C - B) // 2
	x_3 = (D + A) // 2
	y_3 = (D - A) // 2
	x_4 = (D + B) // 2
	y_4 = (D - B) // 2
	if x_1 % 1 == 0 and x_1 != 0 and (y_1 % 1 == 0) and (y_1 != 0) and (x_1 // y_1 == B) and (x_1 * y_1 == D) and (x_1 >= 1) and (y_1 >= 1) and (x_1 <= 10000) and (y_1 <= 10000):
		print(x_1, y_1)
	elif x_2 % 1 == 0 and x_2 != 0 and (y_2 % 1 == 0) and (y_2 != 0) and (x_2 // y_2 == A) and (x_2 * y_2 == D) and (x_2 >= 1) and (y_2 >= 1) and (x_2 <= 10000) and (y_2 <= 10000):
		print(x_2, y_2)
	elif x_3 % 1 == 0 and x_3 != 0 and (y_3 % 1 == 0) and (y_3 != 0) and (x_3 // y_3 == B) and (x_3 * y_3 == C) and (x_3 >= 1) and (y_3 >= 1) and (x_3 <= 10000) and (y_3 <= 10000):
		print(x_3, y_3)
	elif x_4 % 1 == 0 and x_4 != 0 and (y_4 % 1 == 0) and (y_4 != 0) and (x_4 // y_4 == A) and (x_4 * y_4 == C) and (x_4 >= 1) and (y_4 >= 1) and (x_4 <= 10000) and (y_4 <= 10000):
		print(x_4, y_4)
	else:
		print(-1, -1)


def check(x, y, z, d):
	a = (x + y) // 2
	b = abs(x - y) // 2
	if (x + y) % 2 == 0:
		if b <= 0 or a <= 0 or a > 10 ** 4 or (b > 10 ** 4):
			return [-1, -1]
		elif (a * b != z or a // b != d) and (a * b != d or a // b != z):
			return [-1, -1]
		return [a, b]
	else:
		return [-1, -1]
t = int(input())
for _ in range(t):
	(x, y, z, d) = list(map(int, input().split()))
	(a, b) = check(x, y, z, d)
	if a == -1 and b == -1:
		(a, b) = check(x, z, y, d)
	if a == -1 and b == -1:
		(a, b) = check(x, d, y, z)
	if a == -1 and b == -1:
		(a, b) = check(y, z, x, d)
	if a == -1 and b == -1:
		(a, b) = check(y, d, x, z)
	if a == -1 and b == -1:
		(a, b) = check(z, d, x, y)
	print(a, b)