Chef is playing a game with his childhood friend. He gave his friend a list of N numbers named $a_1, a_2 ....  a_N$ (Note: All numbers are unique). Adjust the numbers in the following order:
$(i)$ swap every alternate number with it's succeeding number (If N is odd, do not swap the last number i.e. $a_N$ ).
$(ii)$ add %3 of every number to itself.
$(iii)$ swap the ith number and the (N-i-1) th number.
After this, Chef will give a number to his friend and he has to give the nearest greater and smaller number to it.
If there is no greater or lesser number, put -1.
Help his friend to find the two numbers.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains a single line of input, an integers $N$. 
- Next line contains $N$ integers separated by a space. 
- Next line contains a number to be found, $M$. 

-----Output:-----
For each test case, output in a single line answer given the immediate smaller and greater number separated by a space.

-----Constraints-----
- $1 \leq T \leq 1000$
- $3 \leq N \leq 10^5$
- $1 \leq N_i \leq 10^9$
- $1 \leq M \leq 10^9$

-----Sample Input:-----
1
10
5 15 1 66 55 32 40 22 34 11
38

-----Sample Output:-----
35 41

-----Explaination:-----
Step 1: 15 5 66 1 32 55 22 40 11 34
Step 2: 15 7 66 2 34 56 23 41 13 35
Step 3: 35  13 41 23 56 34 2 66 7 15
35 is the number lesser than 38 and 41 is the number greater than 38 in the given set of numbers.

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	for _ in range(1, n, 2):
		(a[_], a[_ - 1]) = (a[_ - 1], a[_])
	for _ in range(n):
		a[_] += a[_] % 3
	(l, h) = (-1, 9999999999)
	for _ in range(n):
		if a[_] > l and a[_] < x:
			l = a[_]
		if a[_] < h and a[_] > x:
			h = a[_]
	print(l, end=' ')
	if h == 9999999999:
		print(-1)
	else:
		print(h)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = int(input())
	s = 999999999
	l = 999999999
	an = -1
	pj = -1
	for i in range(n):
		arr[i] += arr[i] % 3
		if arr[i] > m and arr[i] - m < l:
			an = arr[i]
			l = arr[i] - m
		if arr[i] < m and m - arr[i] < s:
			pj = arr[i]
			s = m - arr[i]
	print(pj, an)


for _ in range(int(input().strip())):
	n = int(input().strip())
	list1 = list(map(int, input().strip().split()))[:n]
	m = int(input().strip())
	for i in range(n):
		list1[i] = list1[i] + list1[i] % 3
	l1 = []
	l2 = []
	list2 = sorted(list1)
	for i in range(n - 1, 0, -1):
		if list2[i] > m:
			l1.append(list2[i])
	for i in range(n):
		if list2[i] < m:
			l2.append(list2[i])
	if len(l1) > 0 and len(l2) > 0:
		print(max(l2), min(l1))
	elif len(l1) <= 0 and len(l2) > 0:
		print(max(l2), '-1')
	elif len(l1) > 0 and len(l2) <= 0:
		print('-1', min(l1))
	else:
		print('-1', '-1')


n = int(input())
for i in range(0, n):
	o = int(input())
	p = input().rstrip().split(' ')
	x = int(input())
	for j in range(0, len(p) - 1, 2):
		A = int(p[j])
		B = int(p[j + 1])
		p[j] = B + B % 3
		p[j + 1] = A + A % 3
	if len(p) % 2 == 1:
		p[len(p) - 1] = int(p[len(p) - 1]) + int(p[len(p) - 1]) % 3
	p.sort(key=int)
	ans1 = -1
	ans2 = -1
	I = 0
	J = len(p) - 1
	while I <= J:
		m = (I + J) // 2
		if int(p[m]) >= x:
			J = m - 1
		else:
			ans1 = int(p[m])
			I = m + 1
	I = 0
	J = len(p) - 1
	while I <= J:
		m = (I + J) // 2
		if int(p[m]) <= x:
			I = m + 1
		else:
			ans2 = int(p[m])
			J = m - 1
	print(ans1, ans2)


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	m = int(input())
	p = -1
	q = -1
	for x in arr:
		x += x % 3
		if x < m:
			if p == -1 or x > p:
				p = x
		elif x > m:
			if q == -1 or x < q:
				q = x
	print(p, ' ', q)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	m = int(input())
	x = n // 2
	u = 0
	te = -1
	while x:
		te = A[u]
		A[u] = A[u + 1]
		A[u + 1] = te
		u += 2
		x -= 1
	for j in range(n):
		A[j] += A[j] % 3
	for j in range(n):
		u = j
		v = n - j - 1
		te = A[u]
		A[u] = A[v]
		A[v] = te
	mi = -1
	ma = -1
	A.sort()
	for j in range(n):
		if A[j] > m:
			ma = A[j]
			break
	A = A[::-1]
	for j in range(n):
		if A[j] < m:
			mi = A[j]
			break
	print(mi, ma)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = int(input())
	mi = -1
	ma = float('inf')
	for i in l:
		val = i + i % 3
		if val < x:
			mi = max(mi, val)
		elif val > x:
			ma = min(ma, val)
	if ma == float('inf'):
		ma = -1
	print(mi, ma)


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		x = int(input())
		b = list(map(lambda x: x + x % 3, a))
		b.sort()
		c1 = 0
		for lar in b:
			if lar > x:
				large = lar
				c1 = 1
				break
		if c1 == 0:
			large = -1
		b.sort(reverse=True)
		c2 = 0
		for sma in b:
			if sma < x:
				small = sma
				c2 = 1
				break
		if c2 == 0:
			small = -1
		print(small, large)
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = int(input())
	lmin = []
	lmax = []
	for i in range(n):
		num = l[i]
		l[i] += num % 3
	if n % 2 == 0:
		for i in range(n - 1):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
	else:
		for i in range(n - 2):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
	for i in range(int(n / 2)):
		(l[i], l[n - 1 - i]) = (l[n - 1 - i], l[i])
	for i in range(len(l)):
		if l[i] < m:
			lmin.append(l[i])
		elif l[i] > m:
			lmax.append(l[i])
	if len(lmin) == 0:
		a = -1
	else:
		a = max(lmin)
	if len(lmax) == 0:
		b = -1
	else:
		b = min(lmax)
	print(a, b)


import bisect
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	m = int(input())
	for i in range(n):
		mod = lst[i] % 3
		lst[i] = lst[i] + mod
	lst = sorted(lst)
	id = bisect.bisect(lst, m)
	if id == 0:
		if lst[0] > m:
			g = lst[0]
		else:
			g = lst[1]
		s = -1
	elif id == n:
		if lst[n - 1] < m:
			s = lst[n - 1]
		else:
			s = lst[n - 2]
		g = -1
	else:
		s = lst[id - 1]
		if s == m:
			if id - 2 < 0:
				s = -1
			else:
				s = lst[id - 2]
		g = lst[id]
		if g == m:
			if id + 1 > n - 1:
				g = -1
			else:
				g = lst[id + 1]
	print(s, g)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		l[i] += l[i] % 3
	x = int(input())
	a = -1
	b = -1
	for i in l:
		if i > x:
			if b == -1:
				b = i
			else:
				b = min(b, i)
		if i < x:
			if a == -1:
				a = i
			else:
				a = max(a, i)
	print(a, b)


import bisect
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	m = int(input())
	for i in range(n):
		mod = arr[i] % 3
		arr[i] = arr[i] + mod
	arr = sorted(arr)
	idx = bisect.bisect(arr, m)
	if idx == 0:
		if arr[0] > m:
			g = arr[0]
		else:
			g = arr[1]
		s = -1
	elif idx == n:
		if arr[n - 1] < m:
			s = arr[n - 1]
		else:
			s = arr[n - 2]
		g = -1
	else:
		s = arr[idx - 1]
		if s == m:
			if idx - 2 < 0:
				s = -1
			else:
				s = arr[idx - 2]
		g = arr[idx]
		if g == m:
			if idx + 1 > n - 1:
				g = -1
			else:
				g = arr[idx + 1]
	print(s, g)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	m = int(input())
	i = 0
	j = 1
	while j < n:
		(arr[i], arr[j]) = (arr[j], arr[i])
		i = i + 2
		j = j + 2
	for i in range(n):
		arr[i] = arr[i] + arr[i] % 3
	for i in range(n // 2):
		(arr[i], arr[n - i - 1]) = (arr[n - i - 1], arr[i])
	l = -1
	g = 10 ** 10
	for i in range(n):
		if arr[i] < m:
			l = max(l, arr[i])
		if arr[i] > m:
			g = min(g, arr[i])
	if g == 10 ** 10:
		g = -1
	print(l, g)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	for i in range(0, n - n % 2, 2):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
	for i in range(n):
		a[i] += a[i] % 3
	a.reverse()
	c1 = float('-inf')
	for i in range(n):
		if x > a[i] > c1:
			c1 = a[i]
	c2 = float('inf')
	for i in range(n):
		if x < a[i] < c2:
			c2 = a[i]
	if c1 == float('-inf'):
		c1 = -1
	if c2 == float('inf'):
		c2 = -1
	print(c1, c2)