You are given an array A of length N. 

The *interesting value* of a subarray is defined as the product of the maximum and minimum elements of the subarray.

Find the minimum and maximum *interesting value* over all subarrays for the given array.

Note: A subarray is obtained by deletion of several (possibly zero) elements from the beginning of the array and several (possibly zero) elements from the end of the array.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- The first line of each test case contains an integer N - the length of the array A.
- The second line of each test case contains N space-separated integers A_{1},A_{2},\ldots,A_{N}.

------ Output Format ------ 

For each test case, output two space-separated integers on a new line the minimum and maximum *interesting value* over all subarrays for the given array.

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10^{5}$
$-10^{9} ≤ A_{i} ≤ 10^{9}$
- The sum of $N$ over all test cases won't exceed $3 \cdot 10^{5}$.

----- Sample Input 1 ------ 
2
2
2 2
3
5 0 9

----- Sample Output 1 ------ 
4 4
0 81
----- explanation 1 ------ 
Test case $1$: The minimum *interesting value* possible is $4$. A subarray with *interesting value* equal to $4$ is $[2,2]$. Here, both minimum and maximum elements of the subarray are $2$. It can be proven that no subarray of the array has *interesting value* less than $4$.  
The maximum *interesting value* possible is $4$. A subarray with *interesting value* equal to $4$ is $[2,2]$. Here, both minimum and maximum elements of the subarray are $2$. It can be proven that no subarray of the array has *interesting value* greater than $4$.

Test case $2$: The minimum *interesting value* possible is $0$. A subarray with *interesting value* equal to $0$ is $[5, 0, 9]$. Here, minimum element is $0$ and maximum element is $9$. It can be proven that no subarray of the array has *interesting value* less than $0$.  
The maximum *interesting value* possible is $81$. A subarray with *interesting value* equal to $81$ is $[9]$. Here, both minimum and maximum elements of the subarray are $9$. It can be proven that no subarray of the array has *interesting value* more than $81$.

Difficulty: EASY

Solutions:
t = int(input())
while t > 0:
	x = int(input())
	a = list(map(int, input().split()))[:x]
	(b, c, d, e) = (a[0], a[0], abs(a[0]), abs(a[0]))
	for i in a:
		if i < b:
			b = i
		elif i > c:
			c = i
		d = min(d, abs(i))
		e = max(e, abs(i))
	print(min(b * c, d * d), e * e)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	(p, n, z) = (set(), set(), 0)
	for i in a:
		if i > 0:
			p.add(i)
		elif i < 0:
			n.add(i)
		else:
			z = 1
	pos = set()
	if z:
		pos.add(0)
	if p:
		(a, b) = (max(p), min(p))
		pos.add(a * a)
		pos.add(b * b)
	if n:
		(a, b) = (max(n), min(n))
		pos.add(a * a)
		pos.add(b * b)
	if p and n:
		(a, b) = (max(p), min(n))
		pos.add(a * b)
	print(min(pos), max(pos))


for i in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 1:
		ma = mi = arr[0] ** 2
		print(mi, ma)
	else:
		if min(arr) >= 0 and max(arr) >= 0:
			mi = min(arr) ** 2
			ma = max(arr) ** 2
		elif min(arr) < 0 and max(arr) >= 0:
			if abs(min(arr)) >= max(arr):
				ma = min(arr) ** 2
			else:
				ma = max(arr) ** 2
			mi = max(arr) * min(arr)
		else:
			mi = max(arr) ** 2
			ma = min(arr) ** 2
		print(mi, ma)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mini = 10 ** 9
	maxi = -10 ** 9
	for i in range(n):
		mini = min(mini, l[i])
		maxi = max(maxi, l[i])
	if mini < 0 and maxi < 0:
		max_ans = mini * mini
		min_ans = maxi * maxi
	elif mini < 0 and maxi >= 0:
		min_ans = maxi * mini
		if mini * -1 > maxi:
			max_ans = mini * mini
		else:
			max_ans = maxi * maxi
	else:
		min_ans = mini * maxi
		max_ans = maxi * maxi
	print(min_ans, max_ans)


t = int(input())
for t in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	a1 = max(arr)
	a2 = min(arr)
	mi = a2 * a2
	ma = a1 * a1
	mix = a1 * a2
	print(str(min(mix, min(mi, ma))) + ' ' + str(max(mix, max(mi, ma))))


K = int(input())
for i in range(K):
	N = int(input())
	A = list(map(int, input().split()))
	p = min(A)
	q = max(A)
	if p >= 0 and q >= 0:
		output = [p ** 2, q ** 2]
	elif p < 0 and q >= 0:
		lst = [p ** 2, q ** 2, p * q]
		output = [min(lst), max(lst)]
	else:
		output = [q ** 2, p ** 2]
	print(*output)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(min(min(min(a) ** 2, max(a) ** 2), min(a) * max(a)), end=' ')
	print(max(min(a) ** 2, max(a) ** 2))


t = int(input())
for i in range(t):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	if arr[0] >= 0:
		minimum = arr[0] * arr[0]
		maximum = arr[-1] * arr[-1]
	elif arr[-1] < 0:
		minimum = arr[-1] * arr[-1]
		maximum = arr[0] * arr[0]
	else:
		minimum = arr[0] * arr[-1]
		maximum = max(arr[0] * arr[0], arr[-1] * arr[-1])
	print(minimum, maximum)


for test_ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	a.sort()
	max_a = max(a[0] ** 2, a[-1] ** 2)
	min_a = min(a[0] ** 2, a[0] * a[-1])
	for i in range(n):
		min_a = min(min_a, a[i] ** 2)
	print(min_a, max_a)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mnn = arr[0]
	mxx = arr[-1]
	mxe = max(arr[0] ** 2, arr[-1] ** 2)
	if mnn < 0 and mxx > 0:
		mne = mnn * mxx
	else:
		for i in range(n):
			mne = min(arr[0] ** 2, arr[i] ** 2)
	print(mne, mxe)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pmax = a[0]
	pmin = a[0]
	nmax = a[0]
	nmin = a[0]
	for i in a:
		if i >= 0:
			if i > pmax:
				pmax = i
			if i < pmin:
				pmin = i
		else:
			if i > nmax:
				nmax = i
			if i < nmin:
				nmin = i
		a = [pmin * pmin, pmax * pmax, nmin * nmin, nmax * nmax, pmax * nmin]
	print(min(a), max(a))


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	mn = min(a)
	print(min(mn * mn, mx * mx, mn * mx), max(mn * mn, mx * mx))


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	mx_el = max(lst)
	mn_el = min(lst)
	mx = max(mx_el * mx_el, mn_el * mn_el)
	mn = min(mx_el * mx_el, mn_el * mn_el)
	if mn_el < 0 and mx_el >= 0:
		mn = mn_el * mx_el
		if -1 * mn_el > mx_el:
			mx = mn_el * mn_el
	print(mn, mx)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mi = min(l)
	ma = max(l)
	print(min(ma * ma, mi * mi, mi * ma), max(ma * ma, mi * mi))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(mn, mx) = (min(arr), max(arr))
	print(min(mn * mn, mn * mx, mx * mx), max(mn * mn, mx * mx))


q = int(input())
while q:
	n = int(input())
	l = list(map(int, input().split()))[:n]
	if n == 1:
		print(l[0], l[0])
	elif n == 2:
		m = l[0] * l[1]
		print(m, m)
	else:
		mine = 1e+18
		maxe = -1e+18
		l.sort()
		maxe = max(l[0] * l[0], l[n - 1] * l[n - 1])
		if l[0] < 0 and l[n - 1] > 0:
			mine = l[0] * l[n - 1]
		else:
			for i in range(n):
				mine = min(mine, l[i] * l[i])
		print(mine, maxe)
	q -= 1


t = int(input())
for i in range(t):
	n = int(input())
	tmp = list(map(int, input().split()))
	if min(tmp) >= 0:
		print(min(tmp) ** 2, max(tmp) ** 2)
	elif min(tmp) < 0 and max(tmp) > 0:
		if abs(max(tmp)) > abs(min(tmp)):
			print(min(tmp) * max(tmp), max(tmp) ** 2)
		else:
			print(min(tmp) * max(tmp), min(tmp) ** 2)
	else:
		print(max(tmp) ** 2, min(tmp) ** 2)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	M = max(l)
	if m >= 0:
		Min = m * m
		Max = M * M
	elif m < 0 and M > 0:
		Min = m * M
		if M * M >= m * m:
			Max = M * M
		else:
			Max = m * m
	else:
		Min = M * M
		Max = m * m
	print(Min, Max)


def mergeSort(A):
	if len(A) > 1:
		m = len(A) // 2
		L = A[:m]
		R = A[m:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] <= R[j]:
				A[k] = L[i]
				i += 1
			else:
				A[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			A[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			A[k] = R[j]
			j += 1
			k += 1
T = int(input())
while T > 0:
	N = int(input())
	A = list(map(int, input().split()))[:N]
	mergeSort(A)
	m = A[0]
	M = A[N - 1]
	if m >= 0:
		Min = m * m
		Max = M * M
	elif m < 0 and M > 0:
		Min = m * M
		if M * M >= m * m:
			Max = M * M
		else:
			Max = m * m
	else:
		Max = m * m
		Min = M * M
	print(Min, Max)
	T -= 1


def process(array):
	max_a = max(array)
	min_a = min(array)
	max_ip = max(max_a * max_a, min_a * min_a)
	min_ip = min(min_a * max_a, min_a * min_a, max_a * max_a)
	print('%d %d' % (min_ip, max_ip))
	return
n = int(input())
for i in range(0, n):
	length = int(input())
	array = list(map(int, input().split()))
	process(array)


t = int(input())
for i in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mn = arr[0]
	mm = arr[-1]
	(mm2, mn2) = (0, 0)
	if mn < 0 and mm < 0:
		mm2 = mn * mn
		mn2 = mm * mm
	elif mn < 0 and mm > 0:
		mn2 = mn * mm
		if abs(mn) > abs(mm):
			mm2 = mn * mn
		else:
			mm2 = mm * mm
	elif mm >= 0 and mn >= 0:
		mm2 = mm * mm
		mn2 = mn * mn
	print(mn2, mm2)


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	min_num = nums[0]
	max_num = nums[-1]
	(mini, maxi) = (0, 0)
	if min_num < 0 and max_num < 0:
		mini = max_num * max_num
		maxi = min_num * min_num
	elif min_num < 0 and max_num > 0:
		mini = min_num * max_num
		if abs(min_num) > abs(max_num):
			maxi = min_num * min_num
		else:
			maxi = max_num * max_num
	elif min_num >= 0 and max_num >= 0:
		mini = min_num * min_num
		maxi = max_num * max_num
	print(mini, maxi)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	minn = 1000000000
	maxx = -1000000000
	for i in range(n):
		c = a[i]
		if c > maxx:
			maxx = c
		if c < minn:
			minn = c
	if minn < 0 and maxx < 0:
		print(maxx ** 2, minn ** 2)
	elif minn < 0 and maxx == 0:
		print(0, minn ** 2)
	elif minn < 0 and maxx > 0:
		b = max(minn ** 2, maxx ** 2, abs(minn * maxx))
		print(minn * maxx, b)
	elif minn == 0 and maxx == 0:
		print(0, 0)
	elif minn == 0 and maxx > 0:
		print(0, maxx ** 2)
	else:
		print(minn ** 2, maxx ** 2)


T = int(input())
for tc in range(T):
	N = int(input())
	A = list(map(int, input().split(' ')))
	min_A = min(A)
	if min_A >= 0:
		print(str(min_A ** 2) + ' ' + str(max(A) ** 2))
	else:
		max_A = max(A)
		maxx = max(max_A ** 2, min_A ** 2)
		if max(A) >= 0:
			print(str(min_A * max_A) + ' ' + str(maxx))
		else:
			print(str(max_A ** 2) + ' ' + str(min_A ** 2))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] < 0 and a[n - 1] < 0:
		print(a[n - 1] ** 2, a[0] ** 2)
	elif a[0] > 0 and a[n - 1] > 0:
		print(a[0] ** 2, a[n - 1] ** 2)
	elif a[0] <= 0 and a[n - 1] >= 0:
		if abs(a[0]) > a[n - 1]:
			print(a[n - 1] * a[0], a[0] ** 2)
		else:
			print(a[n - 1] * a[0], a[n - 1] ** 2)
	else:
		print(0, 0)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	if l[0] <= 0 and l[n - 1] >= 0:
		if -1 * l[0] > l[n - 1]:
			print(l[0] * l[n - 1], l[0] ** 2)
		else:
			print(l[0] * l[n - 1], l[n - 1] ** 2)
	elif l[0] > 0 and l[n - 1] > 0:
		print(l[0] ** 2, l[n - 1] ** 2)
	elif l[0] < 0 and l[n - 1] < 0:
		print(l[n - 1] ** 2, l[0] ** 2)
	else:
		print(0, 0)


tc = int(input())
for i in range(tc):
	n = int(input())
	if n == 1:
		A = [int(input())]
	else:
		A = list(map(int, input().split(' ')))
	(mina, maxa) = (+float('inf'), -float('inf'))
	for ele in A:
		mina = min(mina, ele)
		maxa = max(maxa, ele)
	if mina > maxa:
		print(maxa ** 2, mina ** 2)
	elif mina < 0 and maxa > 0:
		print(mina * maxa, max(maxa ** 2, mina ** 2))
	elif mina < 0 and maxa == 0:
		print(0, mina ** 2)
	elif maxa < 0:
		print(maxa ** 2, mina ** 2)
	else:
		print(mina ** 2, maxa ** 2)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()][:n]
	l.sort()
	print(min(l[0] * l[0], l[0] * l[n - 1], l[n - 1] * l[n - 1]), max(l[0] * l[0], l[0] * l[n - 1], l[n - 1] * l[n - 1]))


for _ in range(int(input())):
	N = int(input())
	lst = list(map(int, input().split()))
	min_val = min(lst)
	max_val = max(lst)
	print(min(min_val * min_val, min_val * max_val, max_val * max_val), max(min_val * min_val, max_val * max_val))


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	maxV = A[-1] * A[-1]
	if A[0] < 0:
		minV = A[0] * A[-1]
		if A[-1] < 0:
			maxV = A[0] * A[0]
			minV = A[-1] * A[-1]
		elif -A[0] > A[-1]:
			maxV = A[0] * A[0]
	else:
		minV = A[0] * A[0]
	print(minV, maxV)


cases = int(input())
for i in range(0, cases):
	N = int(input())
	intList = [int(x) for x in input().split()]
	maxi = max(intList)
	mini = min(intList)
	maximum = 0
	minimum = 0
	maximum = max(abs(mini), abs(maxi)) ** 2
	if mini * maxi > 0:
		minimum = min(abs(mini), abs(maxi)) ** 2
	else:
		minimum = mini * maxi
	print(str(minimum), str(maximum))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	minInterest = min(min(a) ** 2, max(a) ** 2, min(a) * max(a))
	maxInterest = max(min(a) ** 2, max(a) ** 2)
	print(minInterest, maxInterest)
	t -= 1


T = int(input())
for _ in range(T):
	N = int(input())
	T = list(map(int, input().split()))
	S = sorted(T)
	A = list(map(abs, T))
	M = max(A)
	maximum = M * M
	if S[0] >= 0 or S[-1] <= 0:
		m = min(A)
		minimum = m * m
	else:
		minimum = S[0] * S[-1]
	print(minimum, maximum)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	m = max(a)
	n = min(a)
	k = int(abs(n))
	if k > m:
		prod1 = n * n
	else:
		prod1 = m * m
	if n < 0 and m > 0:
		prod2 = n * m
	elif n >= 0:
		prod2 = n * n
	else:
		prod2 = m * m
	print(prod2, prod1)


a = int(input())
for i in range(a):
	c = int(input())
	b = list(map(int, input().split()))
	b.sort()
	m = b[0] * b[-1]
	for i in range(len(b)):
		if b[i] < 0:
			b[i] = abs(b[i])
	b.sort()
	if m < 0:
		print(m, b[-1] ** 2)
	else:
		print(b[0] ** 2, b[-1] ** 2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	g = max(l)
	print(min(m ** 2, g ** 2, m * g), max(m ** 2, g ** 2, m * g))


t = int(input())
for index in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	containsNegative = 0
	containsPositive = 0
	if min(data) < 0:
		containsNegative = 1
	if max(data) > 0:
		containsPositive = 1
	if containsNegative == 0:
		print(min(data) ** 2, max(data) ** 2)
	elif containsPositive == 0:
		print(max(data) ** 2, min(data) ** 2)
	else:
		print(min(data) * max(data), max(min(data) ** 2, max(data) ** 2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(min(a[0] * a[0], a[-1] * a[-1], a[0] * a[-1]), max(a[0] * a[0], a[-1] * a[-1]))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	mn = min(l)
	mx = max(l)
	print(min(mn ** 2, mn * mx, mx ** 2), max(mx ** 2, mn * mx, mn ** 2))


for i in range(int(input())):
	N = int(input())
	lst = list(map(int, input().split()))
	m1 = min(lst)
	m2 = max(lst)
	if m1 <= 0 and m2 >= 0:
		print(m1 * m2, end=' ')
		if m1 * m1 > m2 * m2:
			print(m1 * m1)
		else:
			print(m2 * m2)
	elif m1 < 0 and m2 < 0:
		print(m2 * m2, end=' ')
		print(m1 * m1)
	else:
		print(m1 * m1, end=' ')
		print(m2 * m2)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	minimum = l[0]
	maximum = l[-1]
	print(min(minimum * maximum, minimum * minimum, maximum * maximum), max(minimum * minimum, minimum * maximum, maximum * maximum))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = min(l)
	b = max(l)
	if a <= 0 and b > 0:
		print(a * b, max(a * a, b * b))
	elif a <= 0 and b <= 0:
		print(b * b, a * a)
	else:
		print(a * a, b * b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	a = min(l)
	b = max(l)
	for i in l:
		if i < 0:
			f += 1
	if f >= 1 and f < len(l):
		n = 0
		for i in l:
			if i < 0 and -i > n:
				n = -i
			elif n <= i:
				n = i
		print(a * b, n * n)
	elif f == 0:
		print(a ** 2, b ** 2)
	else:
		print(b ** 2, a ** 2)


tests = int(input())
for t in range(tests):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	min_val = 0
	max_val = 0
	if abs(A[0]) > abs(A[-1]):
		max_val = A[0] * A[0]
	else:
		max_val = A[-1] * A[-1]
	if A[0] > 0 and A[-1] > 0:
		min_val = A[0] * A[0]
	elif A[0] < 0 and A[-1] < 0:
		min_val = A[-1] * A[-1]
	elif A[0] < 0 and A[-1] > 0:
		min_val = A[0] * A[-1]
	print(min_val, max_val)


T = int(input())
for _ in range(T):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	maximun = 0
	minimun = 0
	mx = max(a)
	mn = min(a)
	if mx >= 0 and mn >= 0:
		maximun = mx * mx
		minimun = mn * mn
	elif mx >= 0 and mn < 0:
		minPositive = mx
		for i in a:
			if i > 0 and i < minPositive:
				minPositive = i
		minimun = min(mn * minPositive, mx * mn)
		mx = max(abs(mn), mx)
		maximun = mx * mx
	else:
		maximun = mn * mn
		minimun = mx * mx
	print(minimun, end=' ')
	print(maximun)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = min(l)
	b = max(l)
	print(min(a ** 2, b ** 2, a * b), max(a ** 2, b ** 2))


n = int(input())
for i in range(n):
	s = int(input())
	l = list(map(int, input().split()))[:s]
	print(min(min(l) ** 2, min(l) * max(l), max(l) ** 2), max(max(l) ** 2, min(l) ** 2))


for _ in range(int(input())):
	n = int(input())
	lt = list(map(int, input().split()))
	mn = min(min(lt) ** 2, max(lt) ** 2, min(lt) * max(lt))
	mx = max(min(lt) ** 2, max(lt) ** 2)
	print(mn, mx)


for i in range(int(input())):
	num = int(input())
	l = list(map(int, input().split()))
	print(min(min(l) ** 2, min(l) * max(l), max(l) ** 2), end=' ')
	print(max(max(l) ** 2, min(l) ** 2))


t = int(input())
for i in range(t):
	s = int(input())
	n = list(map(int, input().split()))
	mini = min(n)
	maxi = max(n)
	c = min(mini ** 2, mini * maxi, maxi ** 2)
	d = max(maxi ** 2, mini ** 2)
	print(c, d)


test = int(input())
for i in range(test):
	size = int(input())
	nums = list(map(int, input().split()))
	mini = min(nums)
	maxi = max(nums)
	a = min(mini ** 2, mini * maxi, maxi ** 2)
	b = max(maxi ** 2, mini ** 2)
	print(a, b)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	mini = l[0]
	maxi = l[0]
	for j in l:
		if mini > j:
			mini = j
		if maxi < j:
			maxi = j
	a = min(mini ** 2, maxi ** 2, mini * maxi)
	b = max(mini ** 2, maxi ** 2)
	print(a, b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 1
	mx = 1
	if l[n - 1] < 0:
		mx = l[0] * l[0]
		mi = l[n - 1] * l[n - 1]
	elif l[0] > 0:
		mi = l[0] * l[0]
		mx = l[n - 1] * l[n - 1]
	else:
		mi = l[0] * l[n - 1]
		mx = max(l[0] * l[0], l[n - 1] * l[n - 1])
	print(mi, mx)


T = int(input())
for i in range(T):
	N = int(input())
	array = list(map(int, input().split()))
	all_positive = True
	count = 0
	for i in array:
		if i < 0:
			all_positive = False
			count += 1
	if all_positive:
		print(f'{min(array) ** 2} {max(array) ** 2}')
	elif not all_positive and count == len(array):
		print(f'{max(array) ** 2} {min(array) ** 2}')
	else:
		print(f'{min(array) * max(array)} {max(max(array) ** 2, min(array) ** 2)}')


for i in range(int(input())):
	n = input()
	a = list(map(int, input().split()))
	mn = min(a)
	mx = max(a)
	print(min(mn * mn, mn * mx, mx * mx), max(mn * mn, mx * mx))