You are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \dots, b_m$. 

Choose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$. 

For example, if $A = [2, 1, 7]$ and $B = [1, 3, 4]$, we can choose $1$ from $A$ and $4$ from $B$, as number $5 = 1 + 4$ doesn't belong to $A$ and doesn't belong to $B$. However, we can't choose $2$ from $A$ and $1$ from $B$, as $3 = 2 + 1$ belongs to $B$.

It can be shown that such a pair exists. If there are multiple answers, print any.

Choose and print any such two numbers.


-----Input-----

The first line contains one integer $n$ ($1\le n \le 100$) — the number of elements of $A$.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 200$) — the elements of $A$.

The third line contains one integer $m$ ($1\le m \le 100$) — the number of elements of $B$.

The fourth line contains $m$ different integers $b_1, b_2, \dots, b_m$ ($1 \le b_i \le 200$) — the elements of $B$.

It can be shown that the answer always exists.


-----Output-----

Output two numbers $a$ and $b$ such that $a$ belongs to $A$, $b$ belongs to $B$, but $a+b$ doesn't belong to nor $A$ neither $B$.

If there are multiple answers, print any.


-----Examples-----
Input
1
20
2
10 20

Output
20 20
Input
3
3 2 2
5
1 5 7 7 9

Output
3 1

Input
4
1 3 5 7
4
7 5 3 1

Output
1 1



-----Note-----

In the first example, we can choose $20$ from array $[20]$ and $20$ from array $[10, 20]$. Number $40 = 20 + 20$ doesn't belong to any of those arrays. However, it is possible to choose $10$ from the second array too.

In the second example, we can choose $3$ from array $[3, 2, 2]$ and $1$ from array $[1, 5, 7, 7, 9]$. Number $4 = 3 + 1$ doesn't belong to any of those arrays.

In the third example, we can choose $1$ from array $[1, 3, 5, 7]$ and $1$ from array $[7, 5, 3, 1]$. Number $2 = 1 + 1$ doesn't belong to any of those arrays.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics


Solutions:
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = a + b
for i in range(len(a)):
	for j in range(len(b)):
		x = a[i] + b[j]
		if x not in c:
			print(a[i], b[j])
			exit(0)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			break
print(str(i) + ' ' + str(j))


n = int(input())
arr1 = [int(i) for i in input().split()]
k = int(input())
arr2 = [int(i) for i in input().split()]
print(max(arr1), max(arr2))


import sys
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = int(input())
l2 = list(map(int, input().split()))
l2.sort()
l2 = l2[::-1]
for i in l:
	for j in l2:
		if i + j not in l:
			print(i, j)
			sys.exit(0)


n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
b = list(map(int, input().strip().split()))
s = [0 for i in range(500)]
for i in a:
	s[i] += 1
for j in b:
	s[j] += 1
done = False
for i in a:
	for j in b:
		if s[i + j] == 0:
			print(i, j)
			done = True
		if done == True:
			break
	if done == True:
		break


n = input()
arr = list(map(int, input().split()))
m = input()
brr = list(map(int, input().split()))
arr.sort()
brr.sort()
print(arr[-1], brr[-1])


n = int(input())
a = list(map(int, input().split()))
aa = set(a)
m = int(input())
b = list(map(int, input().split()))
bb = set(b)
for v in aa:
	for w in bb:
		next = v + w
		if next not in aa and next not in bb:
			print(v, w)
			exit()


import sys
input = lambda : sys.stdin.readline().strip()
n = int(input())
m1 = max(list(map(int, input().split())))
n = int(input())
m2 = max(list(map(int, input().split())))
print(m1, m2)


input()
A = max(map(int, input().split()))
input()
B = max(map(int, input().split()))
print(A, B)


num1 = int(input())
li_1 = input()
list_1 = []
lists_1 = li_1.split()
for i in range(num1):
	list_1.append(int(lists_1[i]))
num2 = int(input())
li_2 = input()
list_2 = []
lists_2 = li_2.split()
for i in range(num2):
	list_2.append(int(lists_2[i]))
list_1.sort()
list_2.sort()
print(list_1[num1 - 1], list_2[num2 - 1])


n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
b = list(map(int, input().strip().split()))
c = max(a)
d = max(b)
print(c, d, sep=' ')


n = int(input())
List_n = list(map(int, input().split()))
del List_n[n:]
m = int(input())
List_m = list(map(int, input().split()))
del List_m[m:]
res = ''
for x in List_n:
	for y in List_m:
		if x + y not in List_n and x + y not in List_m:
			print(x, ' ', y)
			res = 'yes'
			break
	if res == 'yes':
		break


input()
a = [int(x) for x in input().split()]
input()
b = [int(x) for x in input().split()]
print(max(a), max(b))


from sys import *
n = int(stdin.readline())
A = list(map(int, stdin.readline().split()))
m = int(stdin.readline())
B = list(map(int, stdin.readline().split()))
stdout.write(str(max(A)) + ' ' + str(max(B)))


n = int(input())
x = max(list(map(int, input().split())))
n = int(input())
print(x, max(list(map(int, input().split()))))


import sys
la = int(input())
a = list(map(int, input().split()))
lb = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		s = i + j
		if s not in a and s not in b:
			print(i, j)
			sys.exit()


n = int(input())
A = list(map(int, input().split()))
(m, k) = (int(input()), 0)
B = list(map(int, input().split()))
for i in A:
	for j in B:
		x = i + j
		if x not in A and x not in B:
			print(i, j, end=' ')
			k += 1
			break
		else:
			continue
	if k == 1:
		break


na = int(input())
a = list(map(int, input().split()))
da = {}
for i in a:
	da[i] = 0
nb = int(input())
b = list(map(int, input().split()))
db = {}
for i in b:
	db[i] = 0
z = 1
for i in range(na):
	for j in range(nb):
		su = a[i] + b[j]
		try:
			l1 = da[su]
		except KeyError:
			try:
				l2 = db[su]
			except KeyError:
				print(a[i], b[j])
				z = 0
				break
		if z == 0:
			break
	if z == 0:
		break


p = int(input().strip())
a = [int(x) for x in input().split()]
q = int(input().strip())
b = [int(x) for x in input().split()]
print(max(a), end=' ')
print(max(b))


n = int(input())
a = map(int, input().split())
a = list(a)
m = int(input())
b = map(int, input().split())
b = list(b)
c = 0
for i in range(len(a)):
	if c == 1:
		break
	else:
		for j in range(len(b)):
			p = a[i] + b[j]
			if p in a or p in b:
				continue
			else:
				c = c + 1
				print(a[i], b[j])
				break


def main():
	n = int(input())
	a = input().split(' ')
	m = int(input())
	b = input().split(' ')
	a = [int(x) for x in a]
	b = [int(x) for x in b]
	for x in a:
		for y in b:
			r = x + y
			if r not in a and r not in b:
				print(x, y)
				return
main()


import sys
line = sys.stdin.readline()
line2 = sys.stdin.readline()
line3 = sys.stdin.readline()
line4 = sys.stdin.readline()
for i in line2:
	c = line2.split()
	c = list(map(int, c))
for i in line4:
	c2 = line4.split()
	c2 = list(map(int, c2))
ver = False
for i in range(int(line)):
	for j in range(int(line3)):
		pos = c[i] + c2[j]
		if pos in c or pos in c2:
			pass
		else:
			print(c[i], c2[j])
			ver = True
			break
	if ver:
		break


import math
import statistics
n = int(input())
a = list((int(i) for i in input().split()))
m = int(input())
b = list((int(i) for i in input().split()))
aa = sorted(a)
bb = sorted(b)
print('{} {}'.format(aa[-1], bb[-1]))


input()
l1 = input().split(' ')
input()
l2 = input().split(' ')
find = False
for i in range(len(l1)):
	for j in range(len(l2)):
		x = int(l1[i]) + int(l2[j])
		if str(x) not in l1 and str(x) not in l2:
			print(l1[i], l2[j])
			find = True
			break
	if find:
		break


n = int(input())
lst1 = list(map(int, input().split()))
b = int(input())
lst2 = list(map(int, input().split()))
print(max(lst1), max(lst2))


n = int(input())
arr1 = list(map(int, input().split()))
s1 = set(arr1)
m = int(input())
arr2 = list(map(int, input().split()))
s2 = set(arr2)
for val1 in arr1:
	for val2 in arr2:
		tmp = val1 + val2
		if tmp not in s1 and tmp not in s2:
			print(val1, val2)
			exit()


a = int(input())
z = map(int, input().split())
b = int(input())
r = map(int, input().split())
r = list(r)
z = list(z)
z.sort()
r.sort()
print(z[-1], r[-1])


def gns():
	return list(map(int, input().split()))
n = int(input())
ns = gns()
ns = set(ns)
m = int(input())
ms = gns()
ms = set(ms)
for nn in ns:
	for mm in ms:
		x = nn + mm
		if x not in ns and x not in ms:
			print(nn, mm)
			quit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(a + b)
f = 0
for x in range(n):
	for y in range(m):
		if a[x] + b[y] not in c:
			print(a[x], b[y])
			f = 1
			break
	if f == 1:
		break


n = int(input())
p = list(map(int, input().split()))
m = int(input())
l = list(map(int, input().split()))
a = max(p)
b = max(l)
print(a, b)


a = int(input())
arr = [int(x) for x in input().split()]
b = int(input())
brr = [int(x) for x in input().split()]
ans = 0
bns = 0
for i in arr:
	for j in brr:
		if ans and bns:
			break
		d = j + i
		if d not in arr and d not in brr:
			ans = i
			bns = j
print(str(ans) + ' ' + str(bns))


from sys import stdin, stdout
n = int(stdin.readline())
a = list(map(int, input().split()))
m = int(stdin.readline())
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
status = True
for i in range(n):
	for j in range(m):
		if a[i] + b[j] in a or a[i] + b[j] in b:
			continue
		else:
			stdout.write(str(a[i]))
			stdout.write(' ')
			stdout.write(str(b[j]))
			print()
			status = False
			break
	if status == False:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = True
for i in range(n):
	for j in range(m):
		s = a[i] + b[j]
		if s in a or s in b:
			continue
		else:
			flag = False
			print(a[i], b[j])
			break
	if flag == False:
		break


n = int(input())
a1 = [int(x) for x in input().split(' ')]
m = int(input())
a2 = [int(x) for x in input().split(' ')]
print(max(a1), max(a2))


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(1):
	input()
	a = [int(x) for x in input().split()]
	input()
	b = [int(x) for x in input().split()]
	print(max(a), max(b))


n = int(input())
a = list(map(int, input().split()))[:n]
m = int(input())
b = list(map(int, input().split()))[:m]
t = 0
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
		else:
			continue
		break
	else:
		continue
	break


_ = input()
a = max(map(int, input().split()))
_ = input()
b = max(map(int, input().split()))
print(a, b)


n = int(input())
o = list(map(int, input().split()))
m = int(input())
p = list(map(int, input().split()))
print(max(o), max(p))


n = int(input())
a = max(map(int, input().split()))
m = int(input())
b = max(map(int, input().split()))
print(a, b)


n = int(input())
x = list(map(int, input().split()))
m = int(input())
y = list(map(int, input().split()))
print(max(x), max(y))


input()
a = [*map(int, input().split())]
input()
b = list(map(int, input().split()))
for i in range(len(a)):
	for j in range(len(b)):
		(x, y) = (a[i], b[j])
		if not x + y in a and (not x + y in b):
			print(x, y)
			exit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
mxOne = a[0]
mxTwo = b[0]
for i in range(1, n):
	mxOne = max(mxOne, a[i])
for i in range(1, m):
	mxTwo = max(mxTwo, b[i])
print(mxOne, mxTwo)


sizeA = int(input())
listA = map(int, input().split())
listA = list(listA)
sizeB = int(input())
listB = map(int, input().split())
listB = list(listB)
no1 = 0
no2 = 0
found = False
for i in range(0, sizeA):
	for j in range(0, sizeB):
		number = listA[i] + listB[j]
		if number not in listA and number not in listB:
			found = True
			no1 = listA[i]
			no2 = listB[j]
			break
	if found:
		break
print(str(no1) + ' ' + str(no2))


size1 = int(input())
ar1 = list(map(int, input().split(' ')))
size2 = int(input())
ar2 = list(map(int, input().split(' ')))
ar1.sort()
ar2.sort()
print(ar1[size1 - 1], ar2[size2 - 1])


na = int(input())
la = list(map(int, input().split()))
nb = int(input())
lb = list(map(int, input().split()))
print(max(la), end=' ')
print(max(lb))


input()
print(max(map(int, input().split())), end=' ')
input()
print(max(map(int, input().split())))


n1 = int(input())
l1 = list(map(int, input().split()))
n2 = int(input())
l2 = list(map(int, input().split()))
ans = 0
fans = 0
fElement = 0
sElement = 0
for i in range(n1):
	for j in range(n2):
		ans = l1[i] + l2[j]
		if ans not in l1 and ans not in l2:
			fans = ans
			fElement = l1[i]
			sElement = l2[j]
			break
	if fans == ans:
		break
print(fElement, sElement)


n = int(input())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
d = a + b
i = 0
j = 0
while i < n:
	if k > 1:
		while j < k:
			if a[i] + b[j] not in d:
				print(a[i], b[j])
				j = k
				i = n
			elif a[i] + b[j] in d:
				j += 1
	elif k == 1:
		if a[i] + b[0] not in d:
			print(a[i], b[0])
			i = n
		elif a[i] + b[0] in d:
			i += 1


a = int(input())
b = [int(b) for b in input().split()]
c = int(input())
d = [int(d) for d in input().split()]
(r, f) = (0, 0)
while r < a:
	s = 0
	while s < c:
		e = b[r] + d[s]
		if e in b or e in d:
			s = s + 1
			continue
		else:
			print(b[r], d[s])
			f = f + 1
			break
		s = s + 1
	if f == 1:
		break
	r = r + 1


n = int(input())
L = [int(x) for x in input().split()]
n2 = int(input())
L2 = [int(x) for x in input().split()]
print(max(L), ' ', max(L2))


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
done = 0
for i in range(n):
	for j in range(m):
		ele = a[i] + b[j]
		if ele not in a and ele not in b:
			print(a[i], b[j])
			done = 1
			break
		if done:
			break
	if done:
		break


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
for i in A:
	for j in B:
		s = i + j
		if s not in A and s not in B:
			print(i, j)
			exit()


n = int(input())
l = list(map(int, input().split()))
k = int(input())
w = list(map(int, input().split()))
c = 0
for i in range(n):
	for j in range(k):
		r = l[i] + w[j]
		if r not in l and r not in w:
			print(l[i], w[j])
			c += 1
			break
	if c == 1:
		break


NarrA = int(input())
elementsA = input()

def split(size, elements):
	temp = list()
	s = elements.split()
	for i in range(size):
		s[i] = temp.append(int(s[i]))
	return temp
arrA = split(NarrA, elementsA)
NarrB = int(input())
elementsB = input()
arrB = split(NarrB, elementsB)

def calculate(a, b):
	for i in a:
		for j in b:
			result = i + j
			if not result in a and (not result in b):
				return str(i) + ' ' + str(j)
print(calculate(arrA, arrB))


i = lambda : max(map(int, input().split()))
print(i() * 0 + i(), i() * 0 + i())


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
print('{} {}'.format(a[0], b[0]))


n = int(input())
A = [int(x) for x in input().split()]
m = int(input())
B = [int(x) for x in input().split()]
max1 = max(A)
max2 = max(B)
print(max1, max2)


n = int(input())
a = map(int, input().split())
m = int(input())
b = map(int, input().split())
p = -1
q = -1
for i in a:
	if i > p:
		p = i
for i in b:
	if i > q:
		q = i
print(f'{p} {q}')


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
c = 0
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, end=' ')
			print(j)
			c = 1
			break
	if c == 1:
		break


n1 = int(input())
l1 = map(int, input().split(' '))
n2 = int(input())
l2 = map(int, input().split(' '))
m = l1.__next__()
n = l2.__next__()
for i in l1:
	if m < i:
		m = i
for j in l2:
	if n < j:
		n = j
print(m, n)


n = int(input())
arr = [int(x) for x in input().split()]
n1 = int(input())
arr1 = [int(x) for x in input().split()]
ans = []
for i in range(n):
	for j in range(n1):
		a = arr[i] + arr1[j]
		if a not in arr and a not in arr1:
			ans.append([str(arr[i]), str(arr1[j])])
if len(ans) != 0:
	print(' '.join(ans[0]))
else:
	print(0, 0)


n = int(input())
a = [int(s) for s in input().split()]
m = int(input())
b = [int(s) for s in input().split()]
k = i = j = 0
while k == 0 and i < n:
	while k == 0 and j < m:
		if a.count(a[i] + b[j]) == 0 and b.count(a[i] + b[j]) == 0:
			print(a[i], b[j])
			k += 1
		j += 1
	i += 1
	j = 0


exec("input()\nprint(max(map(int,input().split())),end=' ')\n" * 2)


import itertools
n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))
if sorted(a) == sorted(b):
	print(a[0], b[0])
else:
	result = [str(x) + ' ' + str(y) for x in a for y in b if x + y not in a and x + y not in b]
	print(result[0])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
print(max(arr), max(arr2))


na = int(input())
a = list(map(int, input().split()))
nb = int(input())
b = list(map(int, input().split()))
r = 0
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			r = str(a[i]) + ' ' + str(b[j])
			break
	if r != 0:
		break
print(r)


input()
a = [int(i) for i in input().split()]
input()
b = [int(i) for i in input().split()]
print(max(a), max(b))


a = set()
b = set()
n = int(input())
x = [a.add(int(i)) for i in input().split(' ')]
m = int(input())
x = [b.add(int(i)) for i in input().split(' ')]

def loop(a, b):
	for i in a:
		for j in b:
			if not i + j in a and (not i + j in b):
				return (i, j)
(i, j) = loop(a, b)
print('%d %d' % (i, j))


n = int(input())
a = map(int, input().split())
m = int(input())
b = map(int, input().split())
A = list(a)
B = list(b)
print(max(A), max(B))


n = int(input())
a = [int(i) for i in input().split()]
a = max(a)
m = int(input())
b = [int(j) for j in input().split()]
b = max(b)
print(str(a) + ' ' + str(b))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = 0
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a:
			if a[i] + b[j] not in b:
				print(a[i], b[j])
				flag = 1
				break
	if flag == 1:
		break


d = [0] * 201
input()
a = list(map(int, input().split()))
for i in a:
	d[i] = 1
input()
b = list(map(int, input().split()))
flag = False
for i in b:
	d[i] = 1
for i in a:
	for j in b:
		if i + j > 200 or d[i + j] != 1:
			print(i, j)
			flag = True
			break
	if flag:
		break


na = int(input())
la = []
x = input()
for i in x.split():
	la.append(int(i))
nb = int(input())
y = input()
lb = []
for i in y.split():
	lb.append(int(i))
l = []
for a in la:
	for b in lb:
		if a + b not in la + lb:
			l.append((a, b))
for x in l[0]:
	print(x, end=' ')


n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
b = sorted(list(map(int, input().split())))
print(a[-1], b[-1])


from sys import stdin, stdout
import math
import copy
N = int(input())
arr = [int(x) for x in stdin.readline().split()]
N2 = int(input())
arr2 = [int(x) for x in stdin.readline().split()]
for num in arr:
	for num2 in arr2:
		if num + num2 not in arr and num + num2 not in arr2:
			print(num, num2)
			quit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
m1 = set()
m2 = set()
for i in a:
	m1.add(i)
for i in b:
	m2.add(i)
for i in range(n):
	for j in range(m):
		temp = a[i] + b[j]
		if temp not in m1 and temp not in m2:
			print(a[i], b[j])
			exit(0)


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
s = 0
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			s = 1
			break
	if s == 1:
		break


no_of_elements_of_a = int(input())
a = [int(num) for num in input().split(' ', no_of_elements_of_a - 1)]
no_of_elements_of_b = int(input())
b = [int(num) for num in input().split(' ', no_of_elements_of_b - 1)]

def checker():
	ans = []
	for i in range(len(a)):
		for j in range(len(b)):
			sum = a[i] + b[j]
			if sum not in a and sum not in b:
				ans.append(a[i])
				ans.append(b[j])
				return ans
answer = []
answer = checker()
print(answer[0], answer[1])


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l1 = list(map(int, input().split(' ')))
m = int(input())
l2 = list(map(int, input().split(' ')))
print(max(l1), max(l2))


a = int(input())
A = input() + ' '
b = int(input())
B = input() + ' '
maxA = 0
maxB = 0
str_num = ''
for letter in A:
	if letter != ' ':
		str_num = str_num + letter
	else:
		if int(str_num) >= maxA:
			maxA = int(str_num)
		str_num = ''
str_num = ''
for letter in B:
	if letter != ' ':
		str_num = str_num + letter
	else:
		if int(str_num) >= maxB:
			maxB = int(str_num)
		str_num = ''
print(str(maxA) + ' ' + str(maxB))


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
for i in l1:
	for j in l2:
		x = i + j
		if x not in l1 and x not in l2:
			print(i, end=' ')
			print(j)
			exit()


f = int(input())
s = input()
n = [int(s) for s in s.split()]
r = int(input())
s = input()
q = [int(s) for s in s.split()]
a = 0
for i in range(f):
	for j in range(r):
		t = n[i] + q[j]
		if t not in n:
			if t not in q:
				if a == 0:
					a += 1
					print(n[i], q[j])
					break


A = []
numofa = int(input())
A = input().split()
B = []
numofb = int(input())
B = input().split()
for i in A:
	for j in B:
		temp = int(i) + int(j)
		if not str(temp) in A and (not str(temp) in B):
			print(i, j)
			exit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
found = False
for i in a:
	for j in b:
		temp = i + j
		if temp not in a and temp not in b:
			print(i, j)
			found = True
			break
	if found:
		break


n = int(input())
A = [*map(int, input().split())]
m = int(input())
B = [*map(int, input().split())]
A.sort()
B.sort()
print(A[-1], B[-1])


n = int(input())
a = sorted([int(x) for x in input().split()])
m = int(input())
b = sorted([int(x) for x in input().split()])
print(a[-1], b[-1])


from sys import stdin
_input = stdin.readline
(_max, _int) = (max, int)

def solution():
	a = _int(_input())
	arr = _max([_int(i) for i in _input().split()])
	b = _int(_input())
	arr_b = _max([_int(i) for i in _input().split()])
	print(arr, arr_b)
solution()


num1 = int(input())
arr1 = list(map(int, input().split()))
num2 = int(input())
arr2 = list(map(int, input().split()))
max1 = max(arr1)
max2 = max(arr2)
print(str(max1) + ' ' + str(max2))


check = False
x = input()
x = int(x)
l1 = input()
l1 = l1.split()
l = []
for j in range(x):
	l1[j] = int(l1[j])
y = input()
y = int(y)
l2 = input()
l2 = l2.split()
for j in range(y):
	l2[j] = int(l2[j])
for y in l2:
	l = list(filter(lambda x: not x + y in l1 + l2, l1))
	if len(l) > 0:
		break
print('%d %d' % (l[0], y))


for x in range(2):
	a = int(input())
	b = list(map(int, input().split()))
	print(max(b), end=' ')


def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	m = int(input())
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	print(str(a[n - 1]) + ' ' + str(b[m - 1]))
main()


a = int(input())
l = list(map(int, input().split()))
b = int(input())
m = list(map(int, input().split()))
l.sort()
m.sort()
print(l[-1], m[-1])


n1 = int(input(''))
A = list(map(int, input('').split()))
n2 = int(input(''))
B = list(map(int, input('').split()))
s = []
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			s.append(i)
			s.append(j)
a = s[0]
b = s[1]
print(f'{a} {b}')


n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			exit()


def check(a, b):
	for i in range(len(a)):
		p = a[i]
		for j in range(len(b)):
			q = b[j]
			z = p + q
			if z in a or z in b:
				pass
			else:
				return (p, q)
m = int(input())
a = set(map(int, input().split()))
a = list(a)
n = int(input())
b = set(map(int, input().split()))
b = list(b)
v = check(a, b)
print(*v)


n1 = int(input())
l1 = [int(x) for x in input().split()]
n2 = int(input())
l2 = [int(x) for x in input().split()]
f = 0
for i in l1:
	for j in l2:
		if i + j not in l1 and i + j not in l2:
			print('{} {}'.format(i, j))
			f = 1
			break
	if f == 1:
		break


import math
from sys import stdin, stdout

def L():
	return list(map(int, stdin.readline().split()))

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def main():
	n1 = I()
	l1 = set(L())
	n2 = I()
	l2 = set(L())
	l3 = l1.union(l2)
	boo = 0
	for i in l1:
		for j in l2:
			if i + j not in l3:
				boo = 1
				print(i, j)
				break
		if boo:
			break
main()


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
m = ii()
b = li()
a.sort()
b.sort()
print(a[n - 1], end=' ')
print(b[m - 1])


import random
state = True
array_a = []
array_b = []
arraysize_a = int(input())
input_string = input()
list_a = input_string.split()
count = 0
while count < arraysize_a:
	array_a.append(int(list_a[count]))
	count += 1
arraysize_b = int(input())
input_string2 = input()
list_b = input_string2.split()
count = 0
while count < arraysize_b:
	array_b.append(int(list_b[count]))
	count += 1
while state == True:
	number1 = random.choice(array_a)
	number2 = random.choice(array_b)
	result = number1 + number2
	if result not in array_a and result not in array_b:
		state = False
print(number1, number2)


def arr_inp():
	return [int(x) for x in input().split()]
(n, a, m, b) = (int(input()), arr_inp(), int(input()), arr_inp())
print(max(a), max(b))


a = int(input())
x = list(map(int, input().split()))
b = int(input())
y = list(map(int, input().split()))
print(max(x), max(y))


def checkArray(arr, key):
	a = bool
	for n in arr:
		if n == key:
			a = True
			break
		else:
			a = False
	return a
totalA = int(input())
inputA = input()
a = []
b = []
finalNum = [0, 0]
lenA = len(a)
lenB = len(b)
for n in inputA.split():
	a.append(int(n))
if totalA == len(a):
	totalB = int(input())
	inputB = input()
	for n in inputB.split():
		b.append(int(n))
	if totalB == len(b):
		notFound = True
		while notFound:
			for i in range(len(b)):
				if notFound == False:
					break
				for x in range(len(a)):
					first = a[x]
					second = b[i]
					res = first + second
					if checkArray(a, res) == False and checkArray(b, res) == False:
						finalNum[0] = first
						finalNum[1] = second
						notFound = False
						break
	else:
		print('wrong input')
else:
	print('wrong input')
print(finalNum[0], finalNum[1])


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
ma = 0
mb = 0
for i in a:
	ma = max(ma, i)
for i in b:
	mb = max(mb, i)
print(ma, mb)


n = int(input())
a = [int(i) for i in input().split(' ')]
n = int(input())
b = [int(i) for i in input().split(' ')]
print(sorted(a)[-1], sorted(b)[-1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
found = False
for x in range(0, n):
	for y in range(0, m):
		if A[x] + B[y] not in A and A[x] + B[y] not in B:
			print(str(A[x]) + ' ' + str(B[y]))
			found = True
			break
	if found:
		break


n = int(input())
lista = list(map(int, input().split()))
lista.sort()
da = {}
db = {}
for ele in lista:
	da[ele] = 1
m = int(input())
listb = list(map(int, input().split()))
listb.sort()
answerfound = False
for ele in listb:
	db[ele] = 1
for keya in lista:
	for keyb in listb:
		var = keya + keyb
		if var not in lista and var not in listb:
			print(keya, end=' ')
			print(keyb)
			answerfound = True
			break
	if answerfound:
		break


input()
a = sorted(list(map(int, input().split())))
input()
b = sorted(list(map(int, input().split())))
print(a[-1], b[-1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
for a in A:
	for b in B:
		if a + b not in A and a + b not in B:
			print(a, b)
			exit(0)


a = int(input())
l1 = list(map(int, input().split()))
b = int(input())
l2 = list(map(int, input().split()))
l1.sort()
l2.sort()
print(l1[a - 1], l2[b - 1])


ar_count = int(input())
ar = list(map(int, input().rstrip().split()))
ar_count2 = int(input())
ar2 = list(map(int, input().rstrip().split()))
print(max(ar), max(ar2))


import math, sys
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
n = int(input())
a = li()
m = int(input())
b = li()
f = 0
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			f = 1
			break
	if f == 1:
		break


num1 = int(input())
arr1 = list(map(int, input().split()))
num2 = int(input())
arr2 = list(map(int, input().split()))
arr1.sort()
arr2.sort()
print(arr1[num1 - 1], end=' ')
print(arr2[num2 - 1])


n = int(input())
li = list(map(int, input().split()))
k = int(input())
test = list(map(int, input().split()))
d = li + test
c = 0
i = 0
j = 0
e = 0
if len(li) > len(test):
	d = li
	li = test
	test = d
	e = 1
while i < len(li) and c != 1:
	while j < len(test) and c != 1:
		if li[i] + test[j] not in d:
			if e == 0:
				print(li[i], test[j])
			else:
				print(test[j], li[i])
			c = 1
			break
		j = j + 1
	i = i + 1


while True:
	amount = int(input())
	number = input()
	num1 = [int(val) for val in number.split(' ')]
	amount2 = int(input())
	number2 = input()
	num2 = [int(val2) for val2 in number2.split(' ')]
	if len(num1) == amount and len(num2) == amount2:
		break
total = []
for i in range(len(num1)):
	for j in range(len(num2)):
		answer = num1[i] + num2[j]
		if answer not in num1 and answer not in num2:
			print(num1[i], num2[j])
			quit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = set(a)
d = set(b)
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in c and a[i] + b[j] not in d:
			print(a[i], b[j])
			exit()


a = int(input())
a1 = list(map(int, input().split()))
b = int(input())
b1 = list(map(int, input().split()))
c = a1 + b1
k = 0
for i in a1:
	for j in b1:
		if i + j not in c and k == 0:
			print(i, j)
			k = 1


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
la = []
lb = []
for i in a:
	for j in b:
		if a.count(i + j) == 0 and b.count(i + j) == 0:
			la.append(i)
			lb.append(j)
print(la[0], lb[0])


o = int(input())
p = input().rstrip().split(' ')
a = int(input())
q = input().rstrip().split(' ')
for i in range(0, len(p)):
	A = int(p[i])
	G = 0
	for j in range(0, len(q)):
		if str(A + int(q[j])) not in p and str(A + int(q[j])) not in q:
			print(A, int(q[j]))
			G = 1
			break
	if G == 1:
		break


import sys
n1 = int(sys.stdin.readline())
a = [int(i) for i in sys.stdin.readline().split()]
n2 = int(sys.stdin.readline())
b = [int(i) for i in sys.stdin.readline().split()]
f = 0
for i in a:
	for j in b:
		s = i + j
		if s not in a and s not in b:
			print(i, j)
			f = 1
			break
	if f == 1:
		break


n1 = int(input())
a = [int(x) for x in input().split()]
n2 = int(input())
flag = 0
b = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
print(a[0], b[0])


n = input()
a = list(map(int, input().rstrip().split()))
r = input()
b = list(map(int, input().rstrip().split()))
print(max(a), max(b))


n = int(input())
a1 = []
s = input().split()
for i in s:
	a1.append(int(i))
m = int(input())
a2 = []
s = input().split()
for i in s:
	a2.append(int(i))
print(max(a1), max(a2))


n = int(input())
numbers = [int(i) for i in input().split()]
m = int(input())
numbers2 = [int(i) for i in input().split()]
ans1 = 0
ans2 = 0
for i in numbers:
	for j in numbers2:
		if i + j not in numbers and i + j not in numbers2:
			ans1 = i
			ans2 = j
			break
print(ans1, ans2)


n = int(input())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
d = a + b
for i in a:
	for j in b:
		if not i + j in d:
			print(i, j)
			quit(0)


n = int(input())
arr1 = list(map(int, input().split()))
n = int(input())
arr2 = list(map(int, input().split()))
print(max(arr1), end=' ')
print(max(arr2))


import sys
from collections import OrderedDict
from itertools import groupby, product
Lines = []
for Line in sys.stdin:
	Lines.append(Line.rstrip('\n'))
a = int(Lines[0])
del Lines[0]
A = list(map(int, Lines[0].split()))
del Lines[0]
b = int(Lines[0])
del Lines[0]
B = list(map(int, Lines[0].split()))
del Lines[0]
for (i, j) in list(product(A, B)):
	if i + j not in A and i + j not in B:
		print(i, j)
		exit(0)


from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
print(max(a), max(b))


n = int(input())
max1 = 0
max2 = 0
for i in map(int, input().split()):
	if i > max1:
		max1 = i
m = int(input())
for i in map(int, input().split()):
	if i > max2:
		max2 = i
print(max1, max2)


n = int(input())
a = list(map(int, input().split()))
r = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			exit(0)


nA = int(input())
A = list((int(x) for x in list(str(input()).split(' '))))
nB = int(input())
B = list((int(x) for x in list(str(input()).split(' '))))
print(max(A), max(B))


from sys import stdin
a = stdin.readline()
A = sorted((int(i) for i in stdin.readline().split()))
b = stdin.readline()
B = sorted((int(i) for i in stdin.readline().split()))
print(A[-1], B[-1])


t = int(input())
b = sorted(list(map(int, input().split())))
n = int(input())
c = sorted(list(map(int, input().split())))
print(b[-1], c[-1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
result = False
for i in range(n):
	if result == True:
		break
	for j in range(m):
		temp = a[i] + b[j]
		if temp in a or temp in b:
			continue
		else:
			print(a[i], end=' ')
			print(b[j], end=' ')
			result = True
			break


def convertInt(X, lenX):
	result = list()
	for i in range(int(lenX)):
		result.append(int(X[i]))
	return result

def answer(X, Y):
	for i in X:
		for j in Y:
			temp = i + j
			if not temp in X and (not temp in Y):
				return str(i) + ' ' + str(j)
lenA = input()
A = input()
arrA = convertInt(A.split(), lenA)
lenB = input()
B = input()
arrB = convertInt(B.split(), lenB)
answer = answer(arrA, arrB)
print(answer)


import sys
import re
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
from bisect import bisect_left, bisect_right

def dfs(curr, parent):
	visited[curr] = True
	value[curr] += value[parent]
	for i in mydict[curr]:
		if not visited[i]:
			dfs(i, curr)

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
A = get_array()
A.sort()
m = int(input())
B = get_array()
B.sort()
print(A[-1], B[-1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
flag = 0
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, '\t', j)
			flag = 1
			break
	if flag == 1:
		break


R = lambda : map(int, input().split())
n = int(input())
A = sorted(R())
m = int(input())
B = sorted(R())
print(A[n - 1], B[m - 1])


n = int(input())
l = list(map(int, input().split()))
k = int(input())
m = list(map(int, input().split()))

def choose_2_no(l, m):
	for i in l:
		for j in m:
			if i + j not in l and i + j not in m:
				return [i, j]
for i in choose_2_no(l, m):
	print(i, end=' ')


print(int(input()) * 0 + max(map(int, input().split())), int(input()) * 0 + max(map(int, input().split())))


from sys import stdin
from math import gcd, sqrt, log10, log2

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())
n = ii()
a = li()
m = ii()
b = li()
print(max(a), max(b))


n = int(input())
a = list((int(i) for i in input().split()))
m = int(input())
b = list((int(i) for i in input().split()))
a.sort()
b.sort()
print(a[n - 1], b[m - 1])


def main():
	n = int(input())
	A = []
	A = list(map(int, input().split()))
	A = A[:n]
	m = int(input())
	B = []
	B = list(map(int, input().split()))
	B = B[:m]
	f = False
	for i in A:
		for j in B:
			sum = i + j
			if sum not in A and sum not in B:
				print(i, j)
				f = True
				break
		if f:
			break
main()


n = int(input())
A = input().split()
m = int(input())
B = input().split()
for i in range(n):
	A[i] = int(A[i])
for i in range(m):
	B[i] = int(B[i])
A.sort()
B.sort()
print(int(A[n - 1]), int(B[m - 1]))


n = input()
a = [int(x) for x in input().split()]
m = input()
b = [int(x) for x in input().split()]
print(max(a), max(b))


n1 = int(input())
arr1 = list(map(int, input().split()))
n2 = int(input())
arr2 = list(map(int, input().split()))
for i in range(n1):
	for j in range(n2):
		s = arr1[i] + arr2[j]
		if s not in arr1 and s not in arr2:
			print(arr1[i], arr2[j])
			exit()


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))
k = False
for i in range(0, n):
	if k:
		break
	for j in range(0, m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			k = True
			break


n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
b = list(map(int, input().strip().split()))
s = []
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			s.append(i)
			s.append(j)
			break
print(s[0], s[1])


sizea = int(input())
arra = []
for i in input().split():
	if len(arra) < sizea:
		arra.append(int(i))
sizeb = int(input())
arrb = []
for j in input().split():
	if len(arrb) < sizeb:
		arrb.append(int(j))
flag = 0
for a in arra:
	for b in arrb:
		if a + b not in arra and a + b not in arrb:
			print(a, b)
			flag = 1
			break
	if flag == 1:
		break


n = input()
A = list(map(int, input().split()))
m = input()
B = list(map(int, input().split()))
maxA = max(A)
maxB = max(B)
if maxA + maxB not in A + B:
	print(maxA, maxB)


for _ in range(1):
	x = int(input())
	arr = list(map(int, input().strip().split()))
	y = int(input())
	brr = list(map(int, input().strip().split()))
	arr.sort()
	brr.sort()
	print(arr[x - 1], brr[y - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
lst = []
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			lst.append(a[i])
			lst.append(b[j])
			break
print(lst[0], lst[1])


def main():
	a = int(input())
	elementsA = sorted([int(i) for i in input().split()])
	b = int(input())
	elementsB = sorted([int(i) for i in input().split()])
	for i in range(a):
		for j in range(b):
			if elementsA[i] + elementsB[j] not in elementsA and elementsA[i] + elementsB[j] not in elementsB:
				print(str(elementsA[i]) + ' ' + str(elementsB[j]))
				return 0
main()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
flag = False
x = 0
y = 0
for i in a:
	for j in b:
		x = i + j
		if x not in a and x not in b:
			flag = True
			x = i
			y = j
			break
	if flag == True:
		break
print(x, y)


n = int(input())
Listn = list(map(int, input().split()))
m = int(input())
Listm = list(map(int, input().split()))
print(max(Listn), max(Listm))


kase = 1
for _ in range(kase):
	n = int(input())
	A = [int(x) for x in input().split()]
	m = int(input())
	B = [int(x) for x in input().split()]
	V = A + B
	ans = [(a, b) for a in A for b in B if a + b not in V][0]
	print(ans[0], ans[1])


lenA = int(input())
A = input().split()
lenB = int(input())
B = input().split()
for i in A:
	for j in B:
		a = int(i) + int(j)
		if str(a) not in A and str(a) not in B:
			print(i, j)
			quit()


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
a.sort()
b.sort()
x = a[n - 1] + b[m - 1]
if x not in a and x not in b:
	print(a[n - 1], b[m - 1])


number = int(input())
A = list(map(int, input().split()))
number2 = int(input())
B = list(map(int, input().split()))
A.sort()
B.sort()
print(A[-1], B[-1])


n = int(input())
a = [int(w) for w in input().split()]
m = int(input())
b = [int(w) for w in input().split()]
a.sort()
b.sort()
x = a[n - 1]
y = b[m - 1]
print(x, y)


_ = int(input())
arr1 = [int(num) for num in input().split()]
_ = int(input())
arr2 = [int(num) for num in input().split()]
print(max(arr1), max(arr2))


n = int(input())
a = input()
n2 = int(input())
b = input()
a = [int(x) for x in a.split()]
a = sorted(a)
A = a[-1]
b = [int(x) for x in b.split()]
b = sorted(b)
B = b[-1]
print(A, B)


def sum(x, y):
	for i in x:
		for j in y:
			if i + j not in x and i + j not in y:
				return (i, j)
s = int(input())
x = list(map(int, input().split()))
t = int(input())
y = list(map(int, input().split()))
A = sum(x, y)
for i in A:
	print(i, end=' ')


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
A.sort()
B.sort()
print(A[a - 1], B[b - 1])


n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
print(max(ln), max(lm))


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
flag = 0
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			x = i
			y = j
			flag = 1
			break
	if flag == 1:
		break
if flag:
	print(x, y)
else:
	print(-1)


a = int(input())
b = input().split()
maxb = 0
for i in range(a):
	if int(b[i]) > maxb:
		maxb = int(b[i])
c = int(input())
v = input().split()
maxv = 0
for i in range(c):
	if int(v[i]) > maxv:
		maxv = int(v[i])
print(maxb, maxv)


import math
I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
n = I()
a = IL()
m = I()
b = IL()
print(max(a), max(b))


import itertools

def input_ints():
	return list(map(int, input().split()))

def output_list(v):
	print(' '.join((str(x) for x in v)))

def main():
	input()
	a = input_ints()
	input()
	b = input_ints()
	print(max(a), max(b))
main()


n = input()
s1 = list(map(int, input().split()))
n = input()
s2 = list(map(int, input().split()))
for i in s1:
	for j in s2:
		k = i + j
		if k not in s1 and k not in s2:
			print(i, j)
			raise SystemExit


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
sa = set(a)
sb = set(b)
found = False
for i in sa:
	for j in sb:
		if i + j in sa or i + j in b:
			pass
		else:
			print(i, j)
			found = True
			break
	if found:
		break


def find_pair(a, b):
	return (max(a), max(b))
n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
b = list(map(int, input().strip().split()))
print(*find_pair(a, b))


a = int(input())
b = list(map(int, input().split()))
e = int(input())
c = list(map(int, input().split()))
d = max(b)
f = max(c)
print(d, f)


n = int(input())
l1 = input().split()
li1 = [int(i) for i in l1]
m = int(input())
l2 = input().split()
li2 = [int(i) for i in l2]
print(max(li1), max(li2))


na = int(input())
A = list(map(int, input().split(' ')))
nb = int(input())
B = list(map(int, input().split(' ')))
print(max(A), max(B))


A = []
B = []
a = 0
b = 0
input()
A += input().split()
input()
B += input().split()
while True:
	try:
		while str(int(A[a]) + int(B[b])) in A or str(int(A[a]) + int(B[b])) in B:
			if len(A) < len(B):
				try:
					b += 1
				except IndexError:
					a += 1
					b = 0
			else:
				try:
					a += 1
				except IndexError:
					b += 1
					a = 0
	except IndexError:
		continue
	break
print(A[a], B[b])


n = int(input())
N = list(map(int, input().split()))
m = int(input())
M = list(map(int, input().split()))
N.sort()
M.sort()
flag = 0
for i in range(n):
	for j in range(m):
		if N[i] + M[j] > N[-1] and N[i] + M[j] > M[-1] or (N[i] + M[j] not in N and N[i] + M[j] not in M):
			print(N[i], M[j])
			flag = 1
			break
	if flag == 1:
		break


def check(a, l, b, m):
	for i in l:
		for j in m:
			if i + j not in l and i + j not in m:
				return (i, j)
a = int(input())
l = list(map(int, input().split()))
b = int(input())
m = list(map(int, input().split()))
(c, d) = check(a, l, b, m)
print(c, d)


n = int(input())
a = list(map(int, input().split()))
c = int(input())
m = list(map(int, input().split()))
a.sort()
m.sort()
print(a[n - 1], m[c - 1])


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
from fractions import Fraction

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)
n = ii()
a = li()
m = ii()
b = li()
for i in range(n):
	for j in range(m):
		x = a[i] + b[j]
		if x not in a:
			if x not in b:
				print(a[i], b[j])
				exit()


n = int(input())
l = [int(i) for i in input().split()]
m = int(input())
l1 = [int(i) for i in input().split()]
if n < m:
	for i in range(0, len(l)):
		for j in range(0, len(l1)):
			if l[i] + l1[j] not in l and l[i] + l1[j] not in l1:
				print(l[i], l1[j])
				c = 1
				break
		if c == 1:
			break
else:
	for i in range(0, len(l1)):
		for j in range(0, len(l)):
			if l1[i] + l[j] not in l and l1[i] + l[j] not in l1:
				print(l[j], l1[i])
				c = 1
				break
		if c == 1:
			break


n = int(input())
z = max(list(map(int, input().split())))
m = int(input())
x = max(list(map(int, input().split())))
print(z, x, end='')


n = int(input())
a = [int(num) for num in input().split()]
m = int(input())
b = [int(num) for num in input().split()]
print(max(a), max(b))


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
flag = 0
for p in a:
	for q in b:
		if int(p + q) not in a and int(p + q) not in b:
			print(p, q)
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
(first, last) = (max(a), max(b))
print(first, last)


n = int(input())
p = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
print(max(p), max(q))


from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().split()))
m = int(stdin.readline().rstrip())
b = list(map(int, stdin.readline().split()))
print(str(max(a)) + ' ' + str(max(b)))


n1 = int(input())
str1 = input()
str1 = str1.split(' ')
list1 = []
for i in range(len(str1)):
	list1.append(int(str1[i]))
n2 = int(input())
str2 = input()
str2 = str2.split(' ')
list2 = []
for i in range(len(str2)):
	list2.append(int(str2[i]))
A = 0
B = 0
finish = 0
for i in range(n1):
	if finish == 1:
		break
	for j in range(n2):
		if finish == 1:
			break
		sum = list1[i] + list2[j]
		match1 = 1
		match2 = 1
		for k in range(n1):
			if list1[k] == sum:
				match1 = 0
				break
		for l in range(n2):
			if list2[l] == sum:
				match2 = 0
				break
		if match1 == match2 == 1:
			A = list1[i]
			B = list2[j]
			finish = 1
print(A, B)


n = int(input())
l = list(map(int, input().split()))
m = int(input())
s = list(map(int, input().split()))
l.sort()
s.sort()
print(l[-1], s[-1])


sizeA = int(input())
elementsA = input()

def split_elements(size, elements):
	temp = list()
	splitresult = elements.split()
	for i in range(size):
		splitresult[i] = temp.append(int(splitresult[i]))
	return temp
A = split_elements(sizeA, elementsA)
sizeB = int(input())
elementsB = input()
B = split_elements(sizeB, elementsB)

def addition(A, B):
	for x in A:
		for y in B:
			temp = x + y
			if not temp in A and (not temp in B):
				return str(x) + ' ' + str(y)
output = addition(A, B)
print(output)


c = int(input())
aData = input()
d = int(input())
bData = input()
A = []
B = []
A = list(aData.split())
B = list(bData.split())
A = [int(i) for i in A]
B = [int(i) for i in B]
flag = 0
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


def main():
	_ = input()
	a = max(list(map(int, input().split())))
	_ = input()
	b = max(list(map(int, input().split())))
	print(a, b)
main()


a = input()
la = map(int, input().split())
b = input()
lb = map(int, input().split())
print(max(la), max(lb))


_ = int(input())
A = list(map(int, input().split()))
_ = int(input())
B = list(map(int, input().split()))
print(str(max(A)) + ' ' + str(max(B)))


x = int(input())
ar = list(map(int, input().split()))[:x]
y = int(input())
b = list(map(int, input().split()))[:y]
m = 0
for i in range(0, x):
	for j in range(0, y):
		k = ar[i] + b[j]
		if ar.count(k) == 0 and b.count(k) == 0:
			print(ar[i], b[j])
			m = m + 1
			break
	if m != 0:
		break


N = int(input())
A = sorted(list(map(int, input().split())))
M = int(input())
B = sorted(list(map(int, input().split())))
print(A[-1], B[-1])


n = int(input())
L = [int(i) for i in input().split()]
m = int(input())
B = [int(i) for i in input().split()]
T = True
for a in L:
	for b in B:
		if a + b not in L and a + b not in B:
			print(a, ' ', b)
			T = False
			break
	if T == False:
		break


m = int(input())
l = list(map(int, input().split()))
n = int(input())
l1 = list(map(int, input().split()))
print(max(l), max(l1))


n = int(input())
a = []
a = list(map(int, input().strip().split()))[:n]
m = int(input())
b = list(map(int, input().strip().split()))[:m]
print(max(a), max(b))


a = int(input())
l = []
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
for x in b:
	for y in d:
		z = x + y
		if z not in b and z not in d:
			t = tuple((x, y))
			l.append(t)
print(str(l[0][0]) + ' ' + str(l[0][1]))


n = int(input())
aa = input()
a = [int(i) for i in aa.split()]
m = int(input())
bb = input()
b = [int(i) for i in bb.split()]
m1 = max(a)
m2 = max(b)
print('{} {}'.format(m1, m2))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
c1 = a[n - 1]
c2 = b[m - 1]
print(c1, c2)


input()
se1 = set(list(map(int, input().split())))
input()
se2 = set(list(map(int, input().split())))
(n1, n2) = (-1, -1)
for el1 in se1:
	for el2 in se2:
		if el1 + el2 not in se1 and el1 + el2 not in se2:
			n1 = el1
			n2 = el2
			break
print(n1, n2, sep=' ')


input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
print(max(a), max(b))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
print(a[len(a) - 1], b[len(b) - 1])


A = input()
B = input()
listC = B.split()
D = input()
E = input()
listD = E.split()
rA = []
rB = []
for i in range(len(listC)):
	rA.append(int(listC[i]))
for i in range(len(listD)):
	rB.append(int(listD[i]))
print(max(rA), max(rB))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
f = 1
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], end=' ')
			print(b[j])
			f = 0
			break
	if f == 0:
		break


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	I()
	l1 = LI()
	I()
	l2 = LI()
	l1.sort()
	l2.sort()
	return str(l1[-1]) + ' ' + str(l2[-1])
print(main())


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
arr1 = list(map(int, input().split()))
x = max(arr)
y = max(arr1)
print(f'{x} {y}')


a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
e = 0
for i in range(a):
	for j in range(c):
		e = 0
		e = b[i] + d[j]
		if e not in b and e not in d:
			print(b[i], d[j])
			e = 1
			break
	if e == 1:
		break


n = int(input())
a = input().split()
m = int(input())
b = input().split()
ma = 0
mb = 0
for i in range(0, max(n, m)):
	if i < n:
		if int(a[i]) > ma:
			ma = int(a[i])
	if i < m:
		if int(b[i]) > mb:
			mb = int(b[i])
print(ma, end=' ')
print(mb)


amax = 0
bmax = 0
a = int(input())
A = input().split()
for i in range(a):
	A[i] = int(A[i])
	if A[i] >= amax:
		amax = A[i]
b = int(input())
B = input().split()
for i in range(b):
	B[i] = int(B[i])
	if B[i] >= bmax:
		bmax = B[i]
print(amax, bmax)


a = int(input())
arr = list(map(int, input().split()))
b = int(input())
brr = list(map(int, input().split()))
print(max(arr), max(brr))


n = int(input())
A = list(map(int, input().split(' ')))
m = int(input())
B = list(map(int, input().split(' ')))
print(max(A), max(B))


a = []
b = []
n = int(input())
i = input()
a = i.split()
for r in range(len(a)):
	a[r] = int(a[r])
m = int(input())
j = input()
b = j.split()
for l in range(len(b)):
	b[l] = int(b[l])
a.sort()
b.sort()
print(a[n - 1], b[m - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
print(max(a), max(list(map(int, input().split()))))


c = []
input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
for i in range(len(a)):
	for j in range(len(b)):
		if not a[i] + b[j] in a and (not a[i] + b[j] in b):
			c.append(a[i])
			c.append(b[j])
			break
	if len(c) > 0:
		break
print(*c)


a = int(input())
a1 = list(map(int, input().split(' ')))
b = int(input())
b2 = list(map(int, input().split(' ')))

def choose2num():
	global m1, m2
	f = False
	for i in range(0, a):
		for j in range(0, b):
			n = a1[i] + b2[j]
			if n not in a1 and n not in b2:
				f = True
				m1 = a1[i]
				m2 = b2[j]
				break
		if f == True:
			break
choose2num()
print(m1, m2)


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
C = []
C.extend(A)
C.extend(B)
for i in A:
	for j in B:
		if i + j not in C:
			ans = [i, j]
print(ans[0], ans[1])


n = int(input())
l = list(map(int, input().split()))
n1 = int(input())
l1 = list(map(int, input().split()))
f = 0
for i in range(n):
	for j in range(n1):
		c = l[i] + l1[j]
		if c not in l and c not in l1:
			print(l[i], end=' ')
			print(l1[j], end=' ')
			f = 1
			break
	if f == 1:
		break


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
f = 0
for i in range(n):
	for j in range(m):
		c = a[i] + b[j]
		if c not in a and c not in b:
			print(a[i], end=' ')
			print(b[j])
			f = 1
			break
	if f == 1:
		break


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
m1 = max(l1)
m2 = max(l2)
if m1 + m2 not in l1 or l2:
	print(m1, m2)


ara1 = []
ara2 = []
n1 = int(input())
ss = input()
for i in ss.split():
	ara1.append(int(i))
n1 = int(input())
ss2 = input()
for i in ss2.split():
	ara2.append(int(i))
print(f'{max(ara1)} {max(ara2)}')


n = input()
ls1 = tuple(map(eval, input().split()))
m = input()
ls2 = tuple(map(eval, input().split()))
print(max(ls1), max(ls2))


from itertools import product
_ = input()
A = set(map(int, input().split()))
_ = input()
B = set(map(int, input().split()))
for (x, y) in list(product(A, B)):
	_sum = x + y
	if _sum not in A and _sum not in B:
		print(x, y)
		break


n1 = int(input())
A = list(map(int, input().split(' ')))
n2 = int(input())
B = list(map(int, input().split(' ')))
A.sort()
B.sort()
print(A[-1], B[-1])


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		x = arr1[i] + arr2[j]
		if not (x in arr1 or x in arr2):
			print(arr1[i], arr2[j])
			exit()


box_A = int(input())
block_A = [int(a) for a in input().split(' ')]
black_A = sorted(block_A)
box_B = int(input())
block_B = [int(b) for b in input().split(' ')]
black_B = sorted(block_B)
Check_Array = black_A + black_B
sum_array = []
for i in range(len(black_A)):
	for j in range(len(black_B)):
		sum_array.append((black_A[i], black_B[j], black_A[i] + black_B[j]))
tup = tuple()
for i in range(len(sum_array)):
	flag = False
	for j in range(len(Check_Array)):
		if sum_array[i][2] == Check_Array[j]:
			flag = True
	if not flag:
		print(str(sum_array[i][0]) + ' ' + str(sum_array[i][1]))
		break


A = int(input())
numsA = input().split(' ')
for i in range(A):
	numsA[i] = int(numsA[i])
B = int(input())
numsB = input().split(' ')
for i in range(B):
	numsB[i] = int(numsB[i])

def check(numsA, numsB):
	for na in numsA:
		for nb in numsB:
			x = na + nb
			if x not in numsA and x not in numsB:
				print(na, end=' ')
				print(nb)
				return
check(numsA, numsB)


def insertionSort(arr):
	for i in range(1, len(arr)):
		key = arr[i]
		j = i - 1
		while j >= 0 and key < arr[j]:
			arr[j + 1] = arr[j]
			j -= 1
		arr[j + 1] = key
a = []
b = []
x = input()
y = input()
o = input()
l = input()
arrayA = y.split(' ')
for i in range(len(arrayA)):
	a.append(int(arrayA[i]))
insertionSort(a)
if len(arrayA) != int(x):
	print('wrong input')
arrayB = l.split(' ')
for i in range(len(arrayB)):
	b.append(int(arrayB[i]))
insertionSort(b)
if len(arrayB) != int(o):
	print('wrong input')
print(a[-1], b[-1])


a = int(input())
arr = list(map(int, input().split()))
b = int(input())
arr1 = list(map(int, input().split()))
arr.sort()
arr1.sort()
print(arr[-1], arr1[-1])


from itertools import product
nA = input()
A = list(map(int, input().split()))
nB = input()
B = list(map(int, input().split()))
C = A + B
for (a, b) in product(A, B):
	c = a + b
	if c not in C:
		print(a, b)
		break


a = int(input())
l = list(map(int, input().split()))
l.sort()
b = int(input())
d = list(map(int, input().split()))
d.sort()
flag = 0
for i in l:
	for j in d:
		if i + j in d or i + j in l:
			pass
		else:
			flag = 1
			print(i, j)
			break
	if flag == 1:
		break


n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
ln.sort()
lm.sort()
print(f'{ln[len(ln) - 1]} {lm[len(lm) - 1]}')


from sys import stdin

def read_ints():
	return list(map(int, stdin.readline().split()))
stdin.readline()
a = read_ints()
stdin.readline()
b = read_ints()
a_max = max(a)
b_max = max(b)
print(a_max, b_max)


a = int(input())
l1 = [int(i) for i in input().split(' ')]
b = int(input())
l2 = [int(i) for i in input().split(' ')]
t = 0
for i in l1:
	for j in l2:
		if i + j not in l1 and i + j not in l2:
			print(i, j)
			t = 1
		if t == 1:
			t = 2
			break
	if t == 2:
		break


A = int(input())
alist = list(map(int, input().split()))
B = int(input())
blist = list(map(int, input().split()))
print(max(alist), max(blist))


def chose(A, B):
	for a in A:
		for b in B:
			if a + b not in A and a + b not in B:
				print(a, b)
				return
n = int(input())
A = list(map(int, input().rstrip().split()))
m = int(input())
B = list(map(int, input().rstrip().split()))
chose(A, B)


a = int(input())
s = [int(i) for i in input().split()]
b = int(input())
v = [int(i) for i in input().split()]
c = []
for i in range(a):
	for j in range(b):
		if s[i] + v[j] not in s and s[i] + v[j] not in v:
			c.append(s[i])
			c.append(v[j])
		else:
			pass
print(c[0], c[1])


def choose(a, b):
	flag = 0
	for i in a:
		for j in b:
			if i + j not in a and i + j not in b:
				flag = 1
				print(i, j)
				break
		if flag:
			break
n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
choose(a, b)


def run(a, b):
	max_a = max(a)
	max_b = max(b)
	print(max_a, max_b)
input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
run(a, b)


n = input()
a = input()
list_a = list(map(int, a.split()))
k = input()
b = input()
list_b = list(map(int, b.split()))

def function(list_a, list_b):
	for numbers in list_a:
		for values in list_b:
			if numbers + values not in list_a and numbers + values not in list_b:
				return str(numbers) + ' ' + str(values)
			else:
				continue
print(function(list_a, list_b))


n = int(input())
A = [int(s) for s in input().split(' ')]
m = int(input())
B = [int(s) for s in input().split(' ')]
a = max(A)
b = max(B)
print(a, b)


n1 = int(input())
l1 = list(map(int, input().split()))
n2 = int(input())
l2 = list(map(int, input().split()))
print(max(l1), max(l2))


N = int(input())
L = list(map(int, input().split()))
M = int(input())
L2 = list(map(int, input().split()))
(L.sort(), L2.sort())
print(L[N - 1], L2[M - 1])


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
ans = False
for i in range(n):
	if ans:
		break
	for j in range(m):
		tot = A[i] + B[j]
		if tot not in A and tot not in B:
			ans = True
			print('%d %d' % (A[i], B[j]))
			break


(X, x) = (int(input()), sorted(list(map(int, input().split())), reverse=True))
(Y, y) = (int(input()), sorted(list(map(int, input().split())), reverse=True))
for i in range(Y):
	k = y[i] + x[i]
	if k in x or k in y:
		continue
	else:
		print(x[i], y[i])
		exit()


def binsearch(x, arr):
	first = 0
	last = len(arr) - 1
	flag = True
	while first <= last and flag:
		mid = (first + last) // 2
		if arr[mid] == x:
			flag = False
			return mid
		elif x < arr[mid]:
			last = mid - 1
		else:
			first = mid + 1
	return -1

def searchprog(arr, array1, array2):
	size1 = len(array1)
	size2 = len(array2)
	for i in range(size1):
		for j in range(size2):
			temp = array1[i] + array2[j]
			if binsearch(temp, arr) == -1:
				return [array1[i], array2[j]]

def main():
	n1 = int(input())
	temp1 = set(map(int, input().rstrip().split()))
	arr1 = sorted(temp1)
	n2 = int(input())
	temp2 = set(map(int, input().rstrip().split()))
	arr2 = sorted(temp2)
	mainarr = sorted(temp1.union(temp2))
	ans = searchprog(mainarr, arr1, arr2)
	print(ans[0], ans[1])
main()


n = int(input())
a = list(map(int, input().split()))
n1 = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


t = int(input())
a = list(map(int, input().split()))
t1 = int(input())
b = list(map(int, input().split()))
flag = 0
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
a = [int(item) for item in input().split()]
m = int(input())
b = [int(item) for item in input().split()]
a.sort()
b.sort()
print(a[-1], b[-1])


n = int(input())
l = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
flag = 1
for i in range(n):
	for j in range(m):
		x = l[i] + q[j]
		if x not in l and x not in q:
			print(l[i], q[j])
			flag = 0
			break
	if flag == 0:
		break


n = int(input())
arr = [int(i) for i in input().split()]
m = int(input())
brr = [int(i) for i in input().split()]
a = max(arr)
b = max(brr)
print(a, b, sep=' ')


inp1 = input()
inpa1 = map(int, input().split())
inp2 = input()
inpa2 = map(int, input().split())
print(max(inpa1), max(inpa2))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for x in a:
	for y in b:
		if x + y not in a and x + y not in b:
			print(x, y)
			exit()


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
a1 = 0
b1 = 0
for i in range(n):
	for j in range(m):
		if A[i] + B[j] not in A and A[i] + B[j] not in B:
			(a1, b1) = (A[i], B[j])
			break
print(a1, b1)


input()
max1 = max([int(i) for i in input().split()])
input()
max2 = max([int(i) for i in input().split()])
print(max1, max2)


n = int(input())
narr = list(map(int, input().split()))
n1 = int(input())
n1arr = list(map(int, input().split()))
ans = ''
for i in narr:
	found = 0
	for j in n1arr:
		p = i + j
		if p not in narr and p not in n1arr:
			found = 1
			ans = str(i) + ' ' + str(j)
			break
	if found:
		break
print(ans)


x = input()
A = input()
setA = A.split()
y = input()
B = input()
setB = B.split()
a = list(map(int, setA))
b = list(map(int, setB))
a.sort(reverse=True)
b.sort(reverse=True)
p = []
p.append(a[0])
p.append(b[0])
print(*p)


input()
a = [int(x) for x in input().split()]
input()
b = [int(x) for x in input().split()]
print(sorted(a)[-1], sorted(b)[-1])


na = int(input())
a = [int(i) for i in input().split()]
nb = int(input())
b = [int(i) for i in input().split()]
print(max(a), max(b))


n = int(input())
c = list(map(int, input().split()))
m = int(input())
d = list(map(int, input().split()))
print(max(c), max(d))


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))
from math import *
a.sort()
b.sort()
print(a[n - 1], b[m - 1])


n = int(input())
list1 = list(map(int, input().split(' ')))
n2 = int(input())
list2 = list(map(int, input().split(' ')))
k = 0
for j in range(n):
	for i in range(n2):
		sum1 = list2[i] + list1[j]
		if sum1 not in list1 and sum1 not in list2:
			print(list1[j], list2[i])
			k += 1
			break
	if k == 1:
		break


I = input
M = lambda : max(map(int, I().split()))
I()
a = M()
I()
print(a, M())


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print(max(a), end=' ')
print(max(b))


n = int(input())
dat = list(map(int, input().split()))
dat.sort()
x = dat[-1]
n = int(input())
dat = list(map(int, input().split()))
dat.sort()
y = dat[-1]
print(x, y)


def findMax(L, l=0, h=0):
	if h == 0:
		h = len(L) - 1
	index = 0
	largest = 0
	for i in range(l, h + 1):
		if L[i] > largest:
			largest = L[i]
			index = i
	return (largest, index)
n = int(input())
L1 = [int(x) for x in input().split()]
m = int(input())
L2 = [int(x) for x in input().split()]
max1 = findMax(L1)[0]
max2 = findMax(L2)[0]
print(str(max1) + ' ' + str(max2))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
value1 = a[0]
value2 = b[0]
for i in a:
	flag = False
	for j in b:
		if i + j not in a and i + j not in b:
			flag = True
			value1 = i
			value2 = j
			break
	if flag:
		break
print(value1, value2)


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
flag = 0
for i in range(len(A)):
	for j in range(len(B)):
		x = A[i] + B[j]
		if x not in A and x not in B:
			print(A[i], B[j])
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
l = set(list(map(int, input().split())))
m = int(input())
a = set(list(map(int, input().split())))
k = 0
for i in l:
	for j in a:
		if i + j not in a and i + j not in l:
			print(i, j)
			k = 1
			break
	if k == 1:
		break


n = int(input())
k = list(map(int, input().split()))
s = int(input())
(p, q) = (0, 0)
m = list(map(int, input().split()))
for i in k:
	for j in m:
		if i + j not in k:
			if i + j not in m:
				p = i
				q = j
				break
print(p, q)


N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
print(max(A), max(B), sep=' ')


from math import *
from itertools import *
from collections import *
from bisect import *
input()
A = [int(x) for x in input().split()]
input()
B = [int(x) for x in input().split()]
print(max(A), max(B))


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b):
	return abs(a[0] - b[0]) + abs(b[1] - a[1])

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def eld(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def fac(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans
n = int(input())
a = arrIN()
m = int(input())
b = arrIN()
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			exit(0)


import math
n = int(input())
ll = list(map(int, input().split()))
m = int(input())
pp = list(map(int, input().split()))
l = sorted(ll, reverse=True)
p = sorted(pp, reverse=True)
print(l[0], p[0])


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getArr():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
N = getInt()
A = getArr()
M = getInt()
B = getArr()
for i in range(N):
	for j in range(M):
		if A[i] + B[j] not in A and A[i] + B[j] not in B:
			exit(print(A[i], B[j]))


a = int(input())
arr = list(map(int, input().split()))
b = int(input())
brr = list(map(int, input().split()))
k = 0
for i in arr:
	for j in brr:
		if not (i + j in arr or i + j in brr):
			a = i
			b = j
			k = 1
			break
	if k == 1:
		break
print(a, b)


def main():
	n = int(input())
	a = set([int(j) for j in input().split()])
	m = int(input())
	b = set([int(j) for j in input().split()])
	for i in a:
		for j in b:
			if i + j not in a and i + j not in b:
				print(i, j)
				return
main()


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
a.sort()
b.sort()
ast = set(a)
bst = set(b)
done = False
for x in a:
	for y in b:
		if x + y not in ast and x + y not in bst:
			print(x, y)
			done = True
			break
	if done:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
flag = False
for i in range(0, len(a)):
	for j in range(0, len(b)):
		if a[i] + b[j] not in a + b:
			print(a[i], b[j])
			flag = True
			break
	if flag:
		break


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
res = False
for i in a:
	for j in b:
		if not i + j in a and (not i + j in b):
			print(i, j)
			res = True
			break
	if res:
		break


def exist(sum, lst):
	for i in range(len(lst)):
		if sum == lst[i]:
			return True
	return False

def main():
	n = int(input())
	lst_A = list(map(int, input().strip().split()))
	m = int(input())
	lst_B = list(map(int, input().strip().split()))
	sum = 0
	flag = False
	res = ''
	for i in range(n):
		for j in range(m):
			sum = lst_A[i] + lst_B[j]
			if exist(sum, lst_A) == False and exist(sum, lst_B) == False:
				flag = True
				res = str(lst_A[i])
				res += ' ' + str(lst_B[j])
				break
		if flag == True:
			break
	print(res)
main()


daude = [input(), [int(i) for i in input().split()], input(), [int(i) for i in input().split()]]
a = daude[1]
b = daude[3]
for num_a in a:
	for num_b in b:
		if num_a + num_b in a or num_a + num_b in b:
			continue
		else:
			print(f'{num_a} {num_b}')
			quit()


elementsInA = int(input())
Aelement = input().split()
listOfA = [int(x) for x in Aelement]
elementsInB = int(input())
Belement = input().split()
listOfB = [int(x) for x in Belement]
listOfB.sort()
listOfA.sort()
print(listOfA[-1], listOfB[-1])


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
arr1.sort()
arr2.sort()
print(arr1[-1], arr2[-1])


a = int(input())
l1 = list(map(int, input().split()))
b = int(input())
l2 = list(map(int, input().split()))
c = 0
for i in range(a):
	for j in range(b):
		if l1[i] + l2[j] not in l1 and l1[i] + l2[j] not in l2:
			print(l1[i], l2[j])
			c = 1
			break
	if c == 1:
		break


q1 = int(input())
arr1 = sorted(list(map(int, input().split())))
q2 = int(input())
arr2 = sorted(list(map(int, input().split())))
print(arr1[q1 - 1], arr2[q2 - 1])


n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
print(f'{max(a)} {max(b)}')


num_n = int(input())
input_a = input()
array_a = input_a.split(' ')
num_m = int(input())
input_b = input()
array_b = input_b.split(' ')
int_array_a = []
for i in array_a:
	int_array_a.append(int(i))
int_array_b = []
for i in array_b:
	int_array_b.append(int(i))
int_array_a = sorted(int_array_a)
int_array_b = sorted(int_array_b)
print(int_array_a[-1], int_array_b[-1])


number1 = int(input())
number11 = list(map(int, input().split(' ')))
number2 = int(input())
number21 = list(map(int, input().split(' ')))

def choosetwonumber():
	global num1, num2
	f = False
	for i in range(0, number1):
		for j in range(0, number2):
			n = number11[i] + number21[j]
			if n not in number11 and n not in number21:
				f = True
				num1 = number11[i]
				num2 = number21[j]
				break
		if f == True:
			break
choosetwonumber()
print(num1, num2)


t = 1
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	b = list(map(int, input().split()))
	print(max(a), max(b))


n = int(input())
a = tuple(map(int, input().split(' ')))
m = int(input())
b = tuple(map(int, input().split(' ')))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(str(i) + ' ' + str(j))
			exit()


n = int(input())
an = list(map(int, input().split()))
m = int(input())
am = list(map(int, input().split()))
check = 0
for i in an:
	for j in am:
		k = i + j
		if k not in an and k not in am:
			check = 1
			print(i, j)
			break
	if check == 1:
		break


n = int(input())
tab = list(map(int, input().split()))
m = int(input())
sec = list(map(int, input().split()))
tab.sort()
sec.sort()
print(tab[-1], sec[-1])


def solve(n, m, a, b):
	d1 = {}
	d2 = {}
	for i in a:
		d1[i] = True
	for i in b:
		d2[i] = True
	for i in range(n):
		for j in range(m):
			s = a[i] + b[j]
			if s not in d1 and s not in d2:
				return str(a[i]) + ' ' + str(b[j])
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print(solve(n, m, a, b))


import sys
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	n = int(input())
	a = get_array()
	m = int(input())
	b = get_array()
	a.sort()
	b.sort()
	print(a[-1], b[-1])
main()


input()
n = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
list1 = [[x, y] for x in n for y in b if x + y not in n and x + y not in b]
print(*list1[0])


t = int(input())
x = [int(q) for q in input().split()]
t1 = int(input())
y = [int(w) for w in input().split()]
print(max(x), max(y))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = 0
d = 0
for i in range(n):
	if a[i] > c:
		c = a[i]
for i in range(m):
	if b[i] > d:
		d = b[i]
print(c, d)


n1 = int(input())
a = list(map(int, input().strip().split(' ')))
n2 = int(input())
a1 = list(map(int, input().strip().split(' ')))
a.sort()
a1.sort()
print(a[n1 - 1], a1[n2 - 1])


n = int(input())
li1 = list(map(int, input().split()))
m = int(input())
li2 = list(map(int, input().split()))
print(max(li1), max(li2))


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
brr = list(map(int, input().split()))
l = []
for i in arr:
	for j in brr:
		if i + j not in arr and i + j not in brr:
			l.append(i)
			l.append(j)
			break
print(l[0], l[1])


n = int(input())
lin = list(map(int, input().split()))
m = int(input())
lim = list(map(int, input().split()))
print(max(lin), max(lim))


a = int(input())
a_items = input().split(' ')
a_items = [int(a_items[i]) for i in range(a)]
a_items.sort()
b = int(input())
b_items = input().split(' ')
b_items = [int(b_items[i]) for i in range(b)]
b_items.sort()
print(a_items[-1], b_items[-1])


from sys import stdin, stdout
x = stdin.read().split('\n')
a = map(int, x[1].split(' '))
b = map(int, x[3].split(' '))
print(max(a), max(b))


sizeA = int(input())
elementsofA = input()
sizeB = int(input())
elementsofB = input()

def split(size, elements):
	temp = []
	splitelement = elements.split()
	for i in range(size):
		splitelement[i] = temp.append(int(splitelement[i]))
	return temp
a = split(sizeA, elementsofA)
b = split(sizeB, elementsofB)

def count(a, b):
	for i in a:
		for j in b:
			result = i + j
			if not result in a and (not result in b):
				return str(i) + ' ' + str(j)
outputs = count(a, b)
print(outputs)


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))

def find(a, b):
	for i in a:
		for j in b:
			if j + i not in a and j + i not in b:
				print(i, ' ', j)
				return
find(a, b)


import sys
n = int(input())
a = set(map(int, input().split()))
m = int(input())
b = set(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			sys.exit(0)


def counting(n, tableN, setN, m, tableM, setM):
	if n < m:
		for i in range(0, n):
			for j in range(0, m):
				if tableN[i] + tableM[j] not in setN and tableN[i] + tableM[j] not in setM:
					return str(tableN[i]) + ' ' + str(tableM[j])
	else:
		for i in range(0, m):
			for j in range(0, n):
				if tableN[j] + tableM[i] not in setN and tableN[j] + tableM[i] not in setM:
					return str(tableN[j]) + ' ' + str(tableM[i])

def create(set):
	table = []
	for heightS in input().split():
		height = int(heightS)
		if height not in set:
			set.add(height)
			table.append(height)
	return (set, table)
nG = int(input())
tableNG = []
setNG = set()
(setNG, tableNG) = create(setNG)
mG = int(input())
tableMG = []
setMG = set()
(setMG, tableMG) = create(setMG)
print(counting(nG, tableNG, setNG, mG, tableMG, setMG))


import sys

def main():
	_ = sys.stdin.readline()
	A = [int(x) for x in sys.stdin.readline().split(' ')]
	_ = sys.stdin.readline()
	B = [int(x) for x in sys.stdin.readline().split(' ')]
	A.sort()
	B.sort()
	print(A[-1], B[-1])
main()


from collections import Counter
import math

def solve():
	a = int(input())
	A = [int(i) for i in input().split()]
	b = int(input())
	B = [int(i) for i in input().split()]
	return (max(A), max(B))
val = solve()
print(val[0], val[1])


an = int(input())
a = [int(i) for i in input().split()]
bn = int(input())
b = [int(i) for i in input().split()]
t = 0
for i in a:
	for j in b:
		if t == 1:
			break
		if i + j not in a and i + j not in b:
			print(i, j)
			t = 1
			break


N1 = int(input())
s1 = map(int, input().split())
N2 = int(input())
s2 = map(int, input().split())
max1 = 0
for s in s1:
	if s > max1:
		max1 = s
max2 = 0
for s in s2:
	if s > max2:
		max2 = s
print(str(max1) + ' ' + str(max2))


k = 0
t = 0
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(n):
	if k < a[i]:
		k = a[i]
for i in range(m):
	if t < b[i]:
		t = b[i]
print(k, ' ', t)


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
f = False
t = []
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			f = True
			t = [a[i], b[j]]
			break
	if f:
		break
print(*t)


def fun(a, la, b, lb):
	a = set(a)
	b = set(b)
	for i in a:
		for j in b:
			if i + j not in a and i + j not in b:
				res = str(i) + ' ' + str(j)
				return res
	return -1
x = int(input())
y = list(map(int, input().split()))
z = int(input())
p = list(map(int, input().split()))
print(fun(y, x, p, z))


n1 = int(input())
arr = list(map(int, input().split()))
n2 = int(input())
brr = list(map(int, input().split()))
arr.sort(reverse=True)
brr.sort()
for i in arr:
	flag = 1
	for j in brr:
		if i + j not in arr and i + j not in brr:
			print(i, '', j)
			flag = 0
			break
	if flag == 0:
		break


n = int(input())
fst = list(map(int, input().split()))
m = int(input())
snd = list(map(int, input().split()))
fst.sort()
snd.sort()
print(fst[n - 1], snd[m - 1], sep=' ')


def find(arr_a, arr_b):
	for ai in arr_a:
		for bi in arr_b:
			aibi = ai + bi
			if aibi not in arr_a and aibi not in arr_b:
				return [ai, bi]

def main():
	_ = input()
	arr_a = list(map(int, input().split()))
	_ = input()
	arr_b = list(map(int, input().split()))
	print(*find(arr_a, arr_b))
main()


import time, math
from sys import stdin, stdout
I = lambda : int(stdin.readline())
In = lambda : map(int, stdin.readline().split())
L = lambda : list(map(int, stdin.readline().split()))
Si = lambda : sorted(list(map(int, stdin.readline().split())))
Sr = lambda : sorted(list(map(int, stdin.readline().split())), reverse=True)
Pi = lambda x, y: stdout.write(str(x) + ' ' + str(y))

def P(x):
	return stdout.write(str(x))

def solve():
	n1 = I()
	l1 = set(L())
	n2 = I()
	l2 = set(L())
	l3 = l1.union(l2)
	boo = 0
	for i in l1:
		for j in l2:
			if i + j not in l3:
				boo = 1
				P(i)
				P(' ')
				P(j)
				break
		if boo:
			break
solve()


def solve(n, A, m, B):
	for i in A:
		for j in B:
			c = i + j
			if c not in A and c not in B:
				return (i, j)

def main():
	n = int(input())
	A = list(map(int, input().split()))
	m = int(input())
	B = list(map(int, input().split()))
	print(*solve(n, A, m, B))
main()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	b = list(map(int, input().split()))
	a_set = set(a)
	b_set = set(b)
	for i in range(n):
		for j in range(m):
			if a[i] + b[j] not in a_set and a[i] + b[j] not in b_set:
				return ' '.join(map(str, (a[i], b[j])))
print(main())


sizeA = int(input())
A = input()
sizeB = int(input())
B = input()
A = A.split(' ')
B = B.split(' ')
listA = []
listB = []
for i in range(sizeA):
	listA.append(int(A[i]))
for i in range(sizeB):
	listB.append(int(B[i]))
listA.sort()
listB.sort()
yes = False
for i in listA:
	for j in listB:
		if i + j not in listA and i + j not in listB and (yes is not True):
			print('{} {}'.format(i, j))
			yes = True


n = int(input())
a = list(map(int, input().rsplit()))
m = int(input())
b = list(map(int, input().rsplit()))
a.sort()
b.sort()
print(a[-1], ' ', b[-1])


from sys import stdin

def main():
	n = int(stdin.readline())
	nums1 = list(map(int, stdin.readline().split()))
	m = int(stdin.readline())
	nums2 = list(map(int, stdin.readline().split()))
	found = False
	for i in range(len(nums1)):
		for j in range(len(nums2)):
			if nums1[i] + nums2[j] not in nums1 and nums1[i] + nums2[j] not in nums2:
				print(str(nums1[i]) + ' ' + str(nums2[j]))
				found = True
				break
		if found:
			break
main()


import sys
input = sys.stdin.readline
from collections import *
n = int(input())
A = list(map(int, input().split()))
sA = set(A)
m = int(input())
B = list(map(int, input().split()))
sB = set(B)
for a in A:
	for b in B:
		if a + b not in sA and a + b not in sB:
			print(a, b)
			exit()


n = int(input())
a = []
c = set()
s = input()
k = s.split(' ')
for f in range(len(k)):
	a.append(int(k[f]))
	c.add(a[f])
m = int(input())
b = []
s = input()
k = s.split(' ')
for f in range(len(k)):
	b.append(int(k[f]))
	c.add(b[f])
for i in range(n):
	f = False
	for j in range(m):
		k = a[i] + b[j]
		if not k in c:
			print(str(a[i]) + ' ' + str(b[j]))
			f = True
			break
	if f:
		break


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
F = 0
for i in range(n):
	for j in range(m):
		if A[i] + B[j] not in A and A[i] + B[j] not in B:
			print(A[i], B[j])
			F = 1
			break
	if F == 1:
		break


def print_pair(a, b):
	print(str(max(a)) + ' ' + str(max(b)))
n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
print_pair(a, b)


a = int(input())
l1 = list(map(int, input().split()))
b = int(input())
l2 = list(map(int, input().split()))
print(max(l1), max(l2))


def p(a, b, n, m):
	for i in range(n):
		for j in range(m):
			c = a[i] + b[j]
			if c not in a and c not in b:
				return (a[i], b[j])
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = p(a, b, n, m)
print(c[0], c[1])


n = int(input())
A = set(map(int, input().split()))
m = n = int(input())
B = set(map(int, input().split()))
ans = 0
cont = False
for i in A:
	for j in B:
		if not i + j in A and (not i + j in B):
			print(i, j)
			cont = True
			break
	if cont:
		break


def choose2num():
	inp1 = int(input())
	global inpa1
	if 1 <= inp1 <= 100:
		inpa1 = map(int, input().split())
	inp2 = int(input())
	global inpa2
	if 1 <= inp2 <= 100:
		inpa2 = map(int, input().split())
	print(max(inpa1), max(inpa2))
choose2num()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j], sep=' ')
			exit()


a = int(input())
A = input().split()
for x in range(a):
	A[x] = int(A[x])
b = int(input())
B = input().split()
for x in range(b):
	B[x] = int(B[x])
num = 0
for n in A:
	for nn in B:
		if num < 2:
			number = n + nn
			if number not in A and number not in B and (num < 1):
				print(n, nn)
				num = num + 1


N = int(input())
n = input().split(' ')
A = {}
for i in range(N):
	n[i] = int(n[i])
	A[n[i]] = 1
M = int(input())
m = input().split(' ')
B = {}
for i in range(M):
	m[i] = int(m[i])
	B[m[i]] = 1
flag = 0
for i in range(N):
	for j in range(M):
		if n[i] + m[j] in A or n[i] + m[j] in B:
			flag = 0
		else:
			print(n[i], m[j])
			flag = 1
			break
	if flag:
		break


I = lambda : max(map(int, input() and input().split()))
print(I(), I())


a = int(input())
c = list(map(int, input().split()))
b = int(input())
d = list(map(int, input().split()))
print(max(c), max(d))


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
biggest1 = 0
for i in range(n):
	if biggest1 < A[i]:
		biggest1 = A[i]
biggest2 = 0
for i in range(m):
	if biggest2 < B[i]:
		biggest2 = B[i]
print(biggest1, biggest2)


n = int(input())
x = list(map(int, input().split()))
m = int(input())
y = list(map(int, input().split()))
a = max(x)
b = max(y)
print(a, b)


n1 = int(input())
l1 = set(map(int, input().split(' ')))
n2 = int(input())
l2 = set(map(int, input().split(' ')))
flag = n1 > n2
if flag:
	(l1, l2) = (l2, l1)
m = l1.__iter__().__next__()
for i in l1:
	if m < i:
		m = i
for j in l2:
	s = m + j
	if not s in l2 and (not s in l1):
		if flag:
			print(j, m)
		else:
			print(m, j)
		break


lenA = int(input())
A = eval('[' + input().replace(' ', ',') + ']')
lenB = int(input())
B = eval('[' + input().replace(' ', ',') + ']')
for a in A:
	for b in B:
		som = a + b
		if som not in A and som not in B:
			print(a, b)
			raise SystemExit


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
t = False
for i in range(n):
	for j in range(m):
		v = a[i] + b[j]
		if v not in a and v not in b:
			print(a[i], b[j])
			t = True
			break
	if t == True:
		break


n = int(input())
A = [int(i) for i in input().split()]
m = int(input())
B = [int(i) for i in input().split()]
k = 0
for i in range(n):
	if k > 0:
		break
	for j in range(m):
		if A[i] + B[j] not in B and A[i] + B[j] not in A:
			k += 1
			print(A[i], B[j])
			break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
if a[-1] > b[-1]:
	print(a[-1], b[0])
else:
	print(a[0], b[-1])


sizeA = int(input())
A = input().strip().split(' ')
A = list(map(lambda x: int(x), A))
A.sort()
sizeB = int(input())
B = input().strip().split(' ')
B = list(map(lambda x: int(x), B))
B.sort()
print('{} {}'.format(A[sizeA - 1], B[sizeB - 1]))


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
(m,) = gi()
ll = gi()
print(max(l), max(ll))


def int_multiple():
	return [int(c) for c in input().split()]

def int_single():
	return int(input())

def str_multiple():
	return [c for c in input().split()]

def str_single():
	return input()
n = int_single()
a = int_multiple()
m = int_single()
b = int_multiple()
s = ''
s += str(max(a)) + ' '
s += str(max(b))
print(s)


m = int(input())
p = []
p = list(map(int, input().split()))
n = int(input())
q = []
q = list(map(int, input().split()))
c = 0
i = 0
while i < m and c == 0:
	j = 0
	while j < n and c == 0:
		s = p[i] + q[j]
		if s not in p and s not in q:
			print(p[i], q[j])
			c = 1
		else:
			j = j + 1
	i = i + 1


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
s1 = a[0]
s2 = b[0]
for i in range(n):
	for j in range(m):
		if not a[i] + b[j] in set(a) and (not a[i] + b[j] in set(b)):
			s1 = a[i]
			s2 = b[j]
print(s1, s2)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
ans = False
for i in a:
	for j in b:
		num = i + j
		if num not in a and num not in b:
			print(i, j)
			ans = True
		if ans == True:
			break
	if ans == True:
		break


def main():
	n1 = input()
	val1 = set((int(v) for v in input().split()))
	n2 = input()
	val2 = set((int(v) for v in input().split()))
	for v1 in val1:
		for v2 in val2:
			if v1 + v2 not in val1 and v1 + v2 not in val2:
				print(v1, v2)
				return
main()


def fun():
	n = int(input())
	l = sorted([int(i) for i in input().split()])
	n = int(input())
	l1 = sorted([int(i) for i in input().split()])
	s = set(l + l1)
	for i in l:
		for j in l1:
			if i + j not in s:
				print(i, j)
				return
fun()


n = int(input())
arr1 = [int(x) for x in input().split(' ')]
m = int(input())
arr2 = [int(x) for x in input().split(' ')]

def solve():
	for x in arr1:
		for y in arr2:
			if x + y not in arr1 and x + y not in arr2:
				return (x, y)
(a, b) = solve()
print(a, b)


n = int(input())
l0 = list(map(int, input().split()))
m = int(input())
l1 = list(map(int, input().split()))
for i in range(n):
	p = 0
	for j in range(m):
		if l0[i] + l1[j] in l0:
			continue
		elif l1[j] + l0[i] in l1:
			continue
		else:
			p = 1
			break
	if p:
		break
print(l0[i], l1[j])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
ans = 0
for a_ in a:
	for b_ in b:
		ans = a_ + b_
		if ans in a or ans in b:
			continue
		else:
			print(a_, b_)
			exit()


n = int(input())
A = [int(i) for i in input().split()]
m = int(input())
B = [int(i) for i in input().split()]
print(max(A), max(B))


n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
l = a + b
l = set(l)
l = list(l)
flag = 0
for i in a:
	for j in b:
		if i + j not in l:
			print(i, j, end=' ')
			flag = 1
			break
	if flag == 1:
		break


import os
import sys
from io import BytesIO, IOBase

def solution(arr, brr, n, m):
	write(max(arr), max(brr))

def main():
	n = r_int()
	arr = r_array()
	m = r_int()
	brr = r_array()
	solution(arr, brr, n, m)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


n = int(input())
l = list(map(int, input().split()))
m = int(input())
o = list(map(int, input().split()))
s = 0
c = 0
for i in range(0, n):
	for j in range(0, m):
		s = l[i] + o[j]
		if s not in l and s not in o:
			c = 1
			print(l[i], o[j])
			break
	if c == 1:
		break


import os

def f(a_arr, b_arr):
	return f'{max(a_arr)} {max(b_arr)}'
if os.environ.get('DEBUG', False):
	print(f'{f([20], [10, 20])} = 20 20')
	print(f'{f([3, 2, 2], [1, 5, 7, 7, 9])} = 3 1')
	print(f'{f([1, 3, 5, 7], [7, 5, 3, 1])} = 1 1')
else:
	n = int(input())
	a_arr = list(map(int, input().split()))
	m = int(input())
	b_arr = list(map(int, input().split()))
	print(f(a_arr, b_arr))


n = int(input())
listt1 = list(map(int, input().split()))
listt1.sort()
m = int(input())
listt2 = list(map(int, input().split()))
listt2.sort()
final = list(set(listt1 + listt2))
t = 0
for i in listt1:
	for j in listt2:
		summ = i + j
		if summ not in final:
			print(i, j)
			t = 1
			break
	if t == 1:
		break


n = int(input())
l1 = [int(i) for i in input().split()]
m = int(input())
l2 = [int(i) for i in input().split()]
b = False
for i in range(n):
	for j in range(m):
		x = l1[i] + l2[j]
		if x not in l1 and x not in l2:
			print(l1[i], l2[j], sep=' ')
			b = True
			break
	if b:
		break


print(*(max(map(int, input() and input().split())) for _ in '12'))


input()
print(sorted(map(int, input().split()))[-1], end=' ')
input()
print(sorted(map(int, input().split()))[-1])


na = int(input())
a = [int(n) for n in input().split()]
nb = int(input())
b = [int(n) for n in input().split()]
m = {}
for i in a:
	m[i] = 0
for i in b:
	m[i] = 0
f = 0
for i in a:
	for j in b:
		if i + j not in m:
			f = 1
			print(i, j)
			break
	if f == 1:
		break


a = []
b = []
n = int(input())
a = [int(x) for x in input().split(' ')]
m = int(input())
b = [int(x) for x in input().split(' ')]
set_a = set()
set_b = set()
for num in a:
	set_a.add(num)
for num in b:
	set_b.add(num)
res_x = -1
res_y = -1
for x in set_a:
	for y in set_b:
		s = x + y
		if s not in set_a and s not in set_b:
			res_x = x
			res_y = y
			break
print('{} {}'.format(res_x, res_y))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A.sort()
B.sort()
print(A[len(A) - 1], B[len(B) - 1])


useless1 = input()
input1 = input()
useless2 = input()
input2 = input()
firstlist = input1.split()
secondlist = input2.split()
counter = 0
for number in firstlist:
	firstlist[counter] = int(number)
	counter = counter + 1
counter = 0
for number in secondlist:
	secondlist[counter] = int(number)
	counter = counter + 1
counter = 0
for number1 in firstlist:
	for number2 in secondlist:
		if number1 + number2 not in firstlist and number1 + number2 not in secondlist:
			break
	if number1 + number2 not in firstlist and number1 + number2 not in secondlist:
		break
number1 = str(number1)
number2 = str(number2)
print(number1 + ' ' + number2)


n = int(input())
A = list(map(int, input().split()))
a = max(A)
m = int(input())
B = list(map(int, input().split()))
b = max(B)
if a + b in A or a + b in B:
	print(min(A) + min(B))
else:
	print(a, b)


import sys
length1 = int(input())
list1 = map(int, input().split())
length2 = int(input())
list2 = map(int, input().split())
list1 = list(sorted(list1))
list2 = list(sorted(list2))
for i in range(length1):
	for j in range(length2):
		if list1[i] + list2[j] not in list1 and list1[i] + list2[j] not in list2:
			print(list1[i], list2[j])
			sys.exit()


def main(a, b):
	index = 0
	while index < len(a):
		x = 0
		while x < len(b):
			if a[index] + b[x] not in a:
				if a[index] + b[x] not in b:
					return [a[index], b[x]]
			x = x + 1
		index = index + 1
n = int(input())
a = list(map(int, input().rstrip().split()))
m = int(input())
b = list(map(int, input().rstrip().split()))
res = main(a, b)
print(*res)


a = int(input())
b = input().split(' ')
b = [int(i) for i in b]
c = int(input())
d = input().split(' ')
d = [int(i) for i in d]
for i in b:
	for j in d:
		if i + j not in b and i + j not in d:
			print(i, end=' ')
			print(j)
			quit()


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
a = [int(x) for x in inp().split()]
a.sort()
n = int(inp())
b = [int(x) for x in inp().split()]
b.sort()
print(a[-1], b[-1])


a = []
b = []
n = int(input())
a.extend(list(map(int, input().split())))
m = int(input())
b.extend(list(map(int, input().split())))
c = set(a).union(set(b))
finish = 'No'
for i in range(m):
	if finish == 'Yes':
		break
	for j in range(n):
		if b[i] + a[j] not in c:
			print(a[j], b[i])
			finish = 'Yes'
			break


na = int(input())
a = list(map(int, input().strip().split(' ')))
nb = int(input())
b = list(map(int, input().strip().split(' ')))
check = False
for i in range(na):
	for j in range(nb):
		if check != 2:
			check = False
			x = a[i] + b[j]
			for i1 in range(na):
				if x == a[i1]:
					check = True
					break
			if check != True:
				for j1 in range(nb):
					if x == b[j1]:
						check = True
						break
		if check == False:
			print(a[i], b[j])
			check = 2


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		tmp = a[i] + b[j]
		if tmp not in a and tmp not in b:
			print(a[i], b[j])
			exit(0)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = []
for i in range(n):
	for j in range(m):
		d = a[i] + b[j]
		if d not in a and d not in b:
			c.append(a[i])
			c.append(b[j])
			break
print(c[0], c[1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
flag = False
numbers = set(A + B)
for a in A:
	for b in B:
		if a + b not in numbers:
			print(a, b)
			flag = True
			break
	if flag:
		break


def check(a, sum):
	ans = 1
	for num in a:
		if sum == num:
			ans = 0
			break
	return ans
n = int(input())
a = list(map(int, input().split()))[:n]
m = int(input())
b = list(map(int, input().split()))[:m]
sum = 0
for i in range(n):
	for j in range(m):
		sum = a[i] + b[j]
		if check(a, sum) != 0 and check(b, sum) != 0:
			ans1 = a[i]
			ans2 = b[j]
			break
		else:
			continue
print(ans1, end=' ')
print(ans2)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		m = I()
		b = LI()
		rr.append(JA([max(a), max(b)], ' '))
	return JA(rr, '\n')
print(main())


n = int(input())
arr1 = map(int, input().split())
m = int(input())
arr2 = map(int, input().split())
c = max(arr1)
d = max(arr2)
print(c, d)


m = int(input())
a = [int(x) for x in input().split()]
n = int(input())
b = [int(x) for x in input().split()]
count = 0
for i in range(len(a)):
	for j in range(len(b)):
		sum = a[i] + b[j]
		if sum not in a and sum not in b:
			print(a[i], b[j])
			count = 1
			break
	if count == 1:
		break


import array as arr
A_list = []
B_list = []
A_count = int(input())
A_arr = []
A_arr = input().split(' ')
B_count = int(input())
B_arr = []
B_arr = input().split(' ')
for i in A_arr:
	A_list.append(int(i))
for i in B_arr:
	B_list.append(int(i))
A = arr.array('i', A_list)
B = arr.array('i', B_list)
res_list = A_list + B_list
if len(A_list) <= len(B_list):
	for i in A_list:
		for j in B_list:
			Sum = i + j
			if Sum not in res_list:
				print(i, j)
				break
		break
else:
	for i in B_list:
		for j in A_list:
			Sum = i + j
			if Sum not in res_list:
				print(j, i)
				break
		break


t = int(input())
A = list(map(int, input().split()))
v = int(input())
B = list(map(int, input().split()))
print(max(A), max(B))


num_A = int(input())
array_A = input().split()
array_A = [int(x) for x in array_A]
num_B = int(input())
array_B = input().split()
array_B = [int(x) for x in array_B]
array_A.sort()
array_B.sort()
max_A = max(array_A)
max_B = max(array_B)
print(max_A, max_B)


def insertionSort(arr):
	for i in range(1, len(arr)):
		key = arr[i]
		j = i - 1
		while j >= 0 and key < arr[j]:
			arr[j + 1] = arr[j]
			j -= 1
		arr[j + 1] = key

def strToInt(arr):
	n = len(arr)
	for i in range(n):
		arr[i] = int(arr[i])
lengthA = int(input())
elementA = input()
elementA = elementA.split()
strToInt(elementA)
insertionSort(elementA)
lengthB = int(input())
elementB = input()
elementB = elementB.split()
strToInt(elementB)
insertionSort(elementB)
print(str(elementA[lengthA - 1]) + ' ' + str(elementB[lengthB - 1]))


x = int(input())
X = list(map(int, input().split()))
y = int(input())
Y = list(map(int, input().split()))
for i in X:
	for j in Y:
		r = i + j
		if r not in Y and r not in X:
			print(i, j)
			exit()


n = int(input())
l1 = input()
l1 = list(map(int, l1.split()))
m = int(input())
l2 = input()
l2 = list(map(int, l2.split()))
t = 0
list3 = []
list4 = []
for i in l1:
	for j in l2:
		if i + j not in l1 and i + j not in l2:
			list3.append(i)
			list3.append(j)
list4 = [list3[0], list3[1]]
for i in list4:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
m = int(input())
s = list(map(int, input().split()))
print(max(l), max(s))


n = int(input())
a = list(map(int, input().split()))
n = int(input())
b = list(map(int, input().split()))
ab = set(a).union(b)
result = None
for i in range(len(a)):
	if result == None:
		for j in range(len(b)):
			if result == None:
				if a[i] + b[j] not in ab:
					result = (a[i], b[j])
					break
print(result[0], result[1])


import sys

def inp():
	return int(input())
n = inp()
a = [int(x) for x in input().split()]
m = inp()
b = [int(x) for x in input().split()]
s = set(a + b)
for x in a:
	for y in b:
		if x + y not in s:
			print(x, y)
			sys.exit(0)


n = int(input())
A = list(map(int, input().split(' ')))
m = int(input())
B = list(map(int, input().split(' ')))
x = str(max(A))
y = str(max(B))
print(x + ' ' + y)


length1 = input()
A = list(map(int, input().split()))
length2 = input()
B = list(map(int, input().split()))
max_A = max(A)
max_B = max(B)
if max_A + max_B not in A + B:
	print(max_A, max_B)


n = int(input())
arr1 = list(map(int, input().strip().split()))
m = int(input())
arr2 = list(map(int, input().strip().split()))
(d1, d2) = ({}, {})
for i in arr1:
	d1[i] = d1.get(i, 0) + 1
for i in arr2:
	d2[i] = d2.get(i, 0) + 1
flag = 0
for i in arr1:
	for j in arr2:
		c = i + j
		if c not in d1 and c not in d2:
			print(i, j)
			flag = 1
			break
	if flag:
		break


a = int(input())
arrayA = [int(x) for x in input().split()]
b = int(input())
arrayB = [int(x) for x in input().split()]
arrayA.sort()
arrayB.sort()
print(str(arrayA[len(arrayA) - 1]) + ' ' + str(arrayB[len(arrayB) - 1]))


q = int(input())
w = list(map(int, input().split()))
e = input()
r = list(map(int, input().split()))
print(max(w), max(r))


n = int(input())
set1 = set(list(map(int, input().strip().split())))
m = int(input())
set2 = set(list(map(int, input().strip().split())))
ismade = False
for i in set1:
	if not ismade:
		for j in set2:
			Sum = i + j
			if (Sum not in set1 and Sum not in set2) and (not ismade):
				print(i, j)
				ismade = True
	else:
		break


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
n = int(input())
a = I()
(m,) = I()
b = I()
a.sort()
b.sort()
print(a[-1], b[-1])


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	A = getlist()
	M = int(input())
	B = getlist()
	A = sorted(A)
	B = sorted(B)
	print(A[-1], B[-1])
main()


def prog():
	n = int(input())
	a = [int(i) for i in input().split()]
	m = int(input())
	b = [int(i) for i in input().split()]
	for i in a:
		for j in b:
			k = i + j
			if k not in a:
				if k not in b:
					print(i, end=' ')
					print(j)
					return
prog()


c = int(input())
C = list(map(int, input().split()))
d = int(input())
D = list(map(int, input().split()))
for i in C:
	for j in D:
		r = i + j
		if r not in C and r not in D:
			print(i, j)
			exit()


n = int(input())
s = input()
l = s.split()
l = [int(i) for i in l]
m = int(input())
q = input()
w = q.split()
w = [int(i) for i in w]
for i in l:
	for t in w:
		if i + t not in l:
			if i + t not in w:
				(a, b) = (i, t)
print(a, b)


t = int(input())
b = list(map(int, input().split()))
n = int(input())
c = list(map(int, input().split()))
b.sort()
c.sort()
print(b[-1], c[-1])


n = int(input())
lst = [int(x) for x in input().split()]
m = int(input())
mst = [int(x) for x in input().split()]
for x in lst:
	flag = False
	for y in mst:
		if x + y not in lst and x + y not in mst:
			print(x, y)
			flag = True
			break
	if flag:
		break


from itertools import product
n = int(input())
entries_A = list(map(int, input().split()))
m = int(input())
entries_B = list(map(int, input().split()))
prodct = list(product(entries_A, entries_B))
sum1 = []
for i in range(len(prodct)):
	sum1.append(sum(prodct[i]))
	if entries_A.__contains__(sum1[i]) == False and entries_B.__contains__(sum1[i]) == False:
		print(prodct[i][0], '', prodct[i][1])
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = 1
for i in a:
	for j in b:
		k = i + j
		if k not in a and k not in b:
			flag = 0
			p = i
			q = j
			break
	if flag == 0:
		print(p, q)
		break


num1 = input()
l1 = list(map(int, input().split()))
num2 = input()
l2 = list(map(int, input().split()))
check = False
for i in range(int(num1)):
	for j in range(int(num2)):
		if l1[i] + l2[j] in l1:
			pass
		elif l1[i] + l2[j] in l2:
			pass
		else:
			print(l1[i], l2[j])
			check = True
			break
	if check:
		break


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
Ai = max(A)
Bi = max(B)
result1 = Ai + Bi
print(Ai, Bi)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
aset = set()
bset = set()
for i in a:
	aset.add(i)
for i in b:
	bset.add(i)
ans = None
flag = False
for i in a:
	if flag:
		break
	for j in b:
		if i + j not in a and i + j not in b:
			ans = [i, j]
			flag = True
			break
print(*ans)


def choosetwonumbers(A, B):
	i = max(A)
	j = max(B)
	return [i, j]
k = input()
A = list(map(int, input().split()))
t = input()
B = list(map(int, input().split()))
separator = ' '
list = choosetwonumbers(A, B)
print(separator.join(map(str, list)))


input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
for elema in a:
	for elemb in b:
		x = elema + elemb
		if x not in a and x not in b:
			print(elema, elemb)
			break
	else:
		continue
	break


SizeA = input()
temp = input()
A = []
B = []
for element in temp.split():
	A.append(int(element))
SizeB = input()
temp = input()
for element in temp.split():
	B.append(int(element))
A.sort()
B.sort()
print(A[-1], B[-1])


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))

def get(A, B):
	for x in A:
		for y in B:
			if x + y not in A and x + y not in B:
				print(x, y)
				return
get(A, B)


x = int(input())
y = list(map(int, input().split()))
a = int(input())
b = list(map(int, input().split()))
f = 0
for i in range(x):
	for j in range(a):
		if b[j] + y[i] not in y and b[j] + y[i] not in b:
			f = 1
			break
	if f == 1:
		print(y[i], b[j])
		break


n = int(input())
lst = list(map(int, input().split()))
m = int(input())
lst2 = list(map(int, input().split()))
lst.sort()
lst2.sort()
print(lst[-1], lst2[-1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = []
for i in range(len(a)):
	for x in range(len(b)):
		if a[i] + b[x] not in a and a[i] + b[x] not in b:
			c.append(a[i])
			c.append(b[x])
print(c[0], c[1])


a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
b.sort()
d.sort()
print(b[a - 1], d[c - 1])


n = int(input())
arr = list(map(int, input().split()))
q = int(input())
arr2 = list(map(int, input().split()))
arr3 = arr + arr2
arr4 = []
for u in range(n):
	for y in range(q):
		arr4.append(arr[u] + arr2[y])
for k in range(len(arr3)):
	for t in range(len(arr4)):
		if arr3[k] == arr4[t]:
			arr4[t] = 0
for w in range(len(arr4)):
	if arr4[w] != 0:
		qw = arr4[w]
for e in range(len(arr)):
	for g in range(len(arr2)):
		if arr[e] + arr2[g] == qw:
			break
print(arr[e], arr2[g])


import sys
import math
from collections import defaultdict
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
n = int(input())
a = intInp()
m = int(input())
b = intInp()
print(max(a), max(b))


n = int(input())
A = [int(x) for x in input().split()]
m = int(input())
B = [int(x) for x in input().split()]
sortA = sorted(A)
sortB = sorted(B)
print(sortA[-1], sortB[-1])


na = int(input())
a = list(map(int, input().split()))
nb = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


count = 0
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		if arr[i] + arr2[j] not in arr and arr[i] + arr2[j] not in arr2:
			print(str(arr[i]) + ' ' + str(arr2[j]))
			count += 1
			break
	if count == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = set(a + b)
for i in range(n):
	p = 0
	for j in range(m):
		k = a[i] + b[j]
		if k not in c:
			p = p + 1
			break
	if p == 1:
		break
if p == 1:
	print(a[i], b[j])


from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	m = int(input())
	b = [int(x) for x in input().split()]
	print(max(a), max(b))


input()
A = [int(i) for i in input().split(' ')]
input()
B = [int(i) for i in input().split(' ')]
flag = False
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(f'{i} {j}')
			flag = True
			break
	if flag:
		break


Asize = input()
Anum = input()
listA = Anum.split()
Bsize = input()
Bnum = input()
listB = Bnum.split()
realA = []
realB = []
for i in range(len(listA)):
	realA.append(int(listA[i]))
for i in range(len(listB)):
	realB.append(int(listB[i]))
print(max(realA), max(realB))


n = input()
l = list(map(int, input().split()))
l.sort()
n = input()
ll = list(map(int, input().split()))
ll.sort()
print(l[-1], ll[-1])


n = int(input())
k = list(map(int, input().split()))
m = int(input())
l = list(map(int, input().split()))
print(max(k), max(l))


def calc():
	print()

def main():
	n: int = int(input())
	A: list = list(map(int, input().split()))
	m: int = int(input())
	B: list = list(map(int, input().split()))
	A.sort()
	B.sort()
	print(A.pop(), B.pop())
main()


n = int(input())
p = set(map(int, input().split()))
m = int(input())
q = set(map(int, input().split()))
p = sorted(p)
q = sorted(q)
print(p[-1], q[-1])


n = int(input())
first_list = list(map(int, input().split()))
m = int(input())
second_list = list(map(int, input().split()))
first_list.sort(reverse=True)
second_list.sort(reverse=True)
print(str(first_list[0]) + ' ' + str(second_list[0]))


maxA = input()
a = input().split(' ')
A = a[:int(maxA)]
maxB = input()
b = input().split(' ')
A = b[:int(maxA)]
done = False
for i in a:
	for j in b:
		x = a.count(str(int(i) + int(j)))
		y = b.count(str(int(i) + int(j)))
		if x == 0 and y == 0:
			print(int(i), int(j))
			done = True
			break
	if done == True:
		break


a_s = int(input())
a = list(map(int, input().split()))
b_s = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, ' ', j)
			exit()


input()
x = max(map(int, input().split()))
input()
y = max(map(int, input().split()))
print(x, y)


n1 = int(input())
l1 = list(map(int, input().split()))
n2 = int(input())
l2 = list(map(int, input().split()))
l1.sort(reverse=True)
l2.sort(reverse=True)
print(l1[0], l2[0])


contador3 = 0
largoA = int(input())
numerosA = input()
a = []
a.append(numerosA.split())
largoB = int(input())
numerosB = input()
b = []
b.append(numerosB.split())
for l in range(len(a[0])):
	a[0][l] = int(a[0][l])
for m in range(len(b[0])):
	b[0][m] = int(b[0][m])
for i in range(len(a[0])):
	for j in range(len(b[0])):
		suma = a[0][i] + b[0][j]
		contador1 = a[0].count(suma)
		contador2 = b[0].count(suma)
		if contador1 > 0 or contador2 > 0:
			contador3 = 1
		else:
			contador3 = 2
			print(a[0][i], '', b[0][j])
			break
	if contador3 == 2:
		break


n = int(input())
a = list(set(map(int, input().split())))
m = int(input())
b = list(set(map(int, input().split())))
print(max(a), max(b))


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))

def solve(a, b, n, m):
	for i in range(0, n):
		for j in range(0, m):
			x = a[i]
			y = b[j]
			s = x + y
			cnt = 0
			for xx in a:
				if xx == s:
					cnt += 1
					break
			for yy in b:
				if yy == s:
					cnt += 1
					break
			if cnt == 0:
				return f'{x} {y}'
print(solve(a, b, n, m))


na = int(input())
a = input()
a = a.split()
nb = int(input())
b = input()
b = b.split()
a2 = []
for item in a:
	a2.append(int(item))
b2 = []
for item in b:
	b2.append(int(item))
finish = False
for i in a2:
	for j in b2:
		if i + j not in a2 and i + j not in b2:
			print(str(i) + ' ' + str(j))
			finish = True
			break
	if finish:
		break


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			break
print(i, j)


input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))

def func(a, b):
	for item in a:
		for item1 in b:
			sum1 = item + item1
			if sum1 not in a and sum1 not in b:
				print(item, item1)
				return
func(a, b)


input()
xs = map(int, input().split())
input()
ys = map(int, input().split())
mx = max(xs)
my = max(ys)
print(mx, my)


def choose_two_numbers(n, a, m, b):
	for i in range(n):
		comp = set()
		for j in range(n):
			if i == j:
				continue
			comp.add(a[j] - a[i])
		for j in range(m):
			comp.add(b[j] - a[i])
		for j in range(m):
			if b[j] not in comp:
				return f'{a[i]} {b[j]}'
n = int(input())
a = [int(e) for e in input().split()]
m = int(input())
b = [int(e) for e in input().split()]
print(choose_two_numbers(n, a, m, b))


n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))

def f(A, B):
	temp1 = max(A)
	temp2 = max(B)
	print(temp1, temp2)
f(a, b)


a = int(input())
j = []
j.append(input())
b = int(input())
j.append(input())
x = j[0]
y = j[1]
x = x.split(' ')
y = y.split(' ')
m = []
n = []
for i in x:
	m.append(int(i))
for i in y:
	n.append(int(i))
c = False
for i in m:
	for j in n:
		if i + j not in m and i + j not in n:
			print(f'{i} {j}')
			c = True
			break
	if c == True:
		break


n = int(input())
a = list(map(int, input().split()))
x = max(a)
n = int(input())
a = list(map(int, input().split()))
y = max(a)
print(x, y)


n = int(input())
l = [int(i) for i in input().split()]
m = int(input())
k = [int(i) for i in input().split()]
go_on = True
for a in range(n):
	for b in range(m):
		if not (l[a] + k[b] in l or l[a] + k[b] in k):
			print(l[a], k[b])
			go_on = False
			break
	if not go_on:
		break


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
a = inlt()
m = inp()
b = inlt()
a.sort()
b.sort()
x = a[n - 1]
y = b[m - 1]
print(x, ' ', y)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
n = int(rd())
a = list(rrd())
m = int(rd())
b = list(rrd())
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			exit(0)


A = int(input())
a = ()
a = list(map(int, input().split()))
B = int(input())
b = ()
b = list(map(int, input().split()))
z = 0
for ia in range(A):
	for ib in range(B):
		if a[ia] + b[ib] not in a and a[ia] + b[ib] not in b and (z == 0):
			print(a[ia], b[ib])
			z = 1


import sys
s = sys.stdin.read()

def splitter(s):
	strings = s.splitlines()
	a = strings[1].split(' ')
	b = strings[3].split(' ')
	return (a, b)

def solution(a, b):
	a = [int(i) for i in a]
	b = [int(i) for i in b]
	a.sort()
	b.sort()
	return f'{a[-1]} {b[-1]}'
(a, b) = splitter(s)
x = solution(a, b)
print(x)


n = int(input())
a = [int(ele) for ele in input().split()]
m = int(input())
b = [int(ele) for ele in input().split()]
max1 = max(a)
max2 = max(b)
print(max1, max2)


q = int(input())
w = list(map(int, input().split()))
e = int(input())
r = list(map(int, input().split()))
for i in w:
	for j in r:
		if not i + j in w and (not i + j in r):
			print(i, j)
			exit()


def ab():
	a = int(input())
	b = list(map(int, input().split()))
	c = int(input())
	d = list(map(int, input().split()))
	for i in range(0, a):
		for j in range(0, c):
			if b[i] + d[j] not in b and b[i] + d[j] not in d:
				print(str(b[i]) + ' ' + str(d[j]))
				return
ab()


from sys import stdin
import heapq

def find_max(n, m, arr):
	pque = [0] * len(arr)
	for i in range(len(arr)):
		pque[i] = -arr[i]
	heapq.heapify(pque)
	ans = 0
	while n > 0:
		cur_max = -heapq.heappop(pque)
		ans += cur_max
		cur_max -= 1
		if cur_max > 0:
			heapq.heappush(pque, -cur_max)
		n -= 1
	return ans

def find_min(n, m, arr):
	pque = arr[:]
	heapq.heapify(pque)
	ans = 0
	while n > 0:
		cur_min = heapq.heappop(pque)
		ans += cur_min
		cur_min -= 1
		if cur_min > 0:
			heapq.heappush(pque, cur_min)
		n -= 1
	return ans

def solution(n, m, arr):
	mn = find_min(n, m, arr)
	mx = find_max(n, m, arr)
	return [mx, mn]
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
m = int(stdin.readline().strip())
barr = list(map(int, stdin.readline().split()))
arr.sort()
barr.sort()
print(arr[-1], barr[-1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
result = []
accept = 0
for i in range(n):
	if accept == 1:
		break
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			accept = 1
			result.append(a[i])
			result.append(b[j])
			print(*result)
			break


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
f = False
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print('{} {}'.format(i, j))
			f = True
			break
	if f == True:
		break


a1 = int(input())
a = [int(i) for i in input().split()]
b1 = int(input())
b = [int(i) for i in input().split()]
k = 0
for i in range(a1):
	for j in range(b1):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			k = 1
			break
	if k == 1:
		break


a = int(input())
A = [int(i) for i in input().split()]
b = int(input())
B = [int(i) for i in input().split()]
print(max(A), max(B))


n = int(input())
(l1, l2) = ([], [])
(a, b) = (0, 0)
l1 = [int(z) for z in input().split()]
for i in l1:
	a = max(a, i)
m = int(input())
l2 = [int(z) for z in input().split()]
for j in l2:
	b = max(b, j)
print(a, end=' ')
print(b)


from collections import defaultdict
d = {}
d = defaultdict(int)
d1 = {}
d1 = defaultdict(int)
n = int(input())
l = list(map(int, input().split()))
n1 = int(input())
l1 = list(map(int, input().split()))
for i in l:
	d[i] += 1
for i in l1:
	d1[i] += 1
c = 0
for i in d:
	for j in d1:
		k = i + j
		if d[k] == 0 and d1[k] == 0:
			print(i, j)
			c = 1
		if c:
			break
	if c:
		break


def so(a, b):
	a.sort()
	b.sort()
	print(a[-1], end=' ')
	print(b[-1], end=' ')
n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
ans = so(a, b)
ans


n = int(input())
s1 = [int(x) for x in input().split()]
m = int(input())
s2 = [int(x) for x in input().split()]
kk = dict()
for i in range(0, len(s1)):
	kk[s1[i]] = 1
for i in range(0, len(s2)):
	kk[s2[i]] = 1
temp = 0
for i in range(n):
	for j in range(m):
		if kk.get(s1[i] + s2[j]) == None:
			print(s1[i], s2[j])
			temp = 1
			break
	if temp == 1:
		break


N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
A.sort()
B.sort()
print(A[N - 1], B[M - 1])


n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
f = 0
for i in ln:
	for j in lm:
		if i + j not in ln and i + j not in lm:
			print(i, j)
			f = 1
			break
	if f == 1:
		break


def calc(X, Y):
	for i in X:
		for j in Y:
			temp = int(i) + int(j)
			if not str(temp) in X and (not str(temp) in Y):
				return (i, j)
A = []
B = []
lenA = int(input())
A = input()
X = A.split()
lenB = int(input())
B = input()
Y = B.split()
(x, y) = calc(X, Y)
print(x, y)


a = [None] * 201
b = [None] * 201
l_a = int(input())
t_a = [int(x) for x in input().split(' ')]
l_b = int(input())
t_b = [int(x) for x in input().split(' ')]
found = False
for x in t_a:
	a[x] = x
for x in t_b:
	b[x] = x
for s in range(0, l_a):
	x = t_a[s]
	for h in range(0, l_b):
		sum = x + t_b[h]
		if sum > 200:
			print(x, t_b[h])
			found = True
			break
		if a[sum] is None and b[sum] is None:
			print(x, t_b[h])
			found = True
			break
	if found:
		break


n = int(input())
l = list(map(int, input().split()))
m = int(input())
l1 = list(map(int, input().split()))
c = 0
for i in l:
	for j in l1:
		if i + j not in l and i + j not in l1:
			print(i, end=' ')
			print(j)
			c = 1
			break
	if c == 1:
		break


n = int(input())
li1 = list(map(int, input().split()))
m = int(input())
li2 = list(map(int, input().split()))
(c, i) = (0, 0)
while c == 0 and i <= n:
	for j in li2:
		if li1[i] + j not in li1 and li1[i] + j not in li2:
			print(li1[i], j)
			c = 1
			break
	i = i + 1


n = int(input())
ai = list(map(int, input().split()))
m = int(input())
bi = list(map(int, input().split()))
ai.sort()
bi.sort()
print(ai[-1], bi[-1])


n = int(input())
s = [int(i) for i in input().split()]
n1 = int(input())
s1 = [int(i) for i in input().split()]
a = 0
for i in range(n):
	for j in range(n1):
		sum = s[i] + s1[j]
		if not sum in s and (not sum in s1):
			print(s[i], s1[j])
			a = 1
			break
	if a == 1:
		break


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
print(f'{A[0]} {B[0]}')


N = int(input())
A = [int(x) for x in input().split()]
M = int(input())
B = [int(x) for x in input().split()]
print(max(A), max(B))


n = int(input())
x = list(map(int, input().split()))
n1 = int(input())
y = list(map(int, input().split()))
for i in x:
	for j in y:
		s = i + j
		if s not in x and s not in y:
			print(i, j)
			exit(0)


a = []
b = []
n = int(input())
[a.append(int(x)) for x in input().split()]
m = int(input())
[b.append(int(y)) for y in input().split()]
c = a + b
d = []
for i in a:
	for j in b:
		d.append([i, j])
for i in d:
	if i[0] + i[1] not in c:
		print(i[0], i[1])
		break


def answer():
	a = input()
	b = max([int(x) for x in input().split()])
	a = input()
	c = max([int(x) for x in input().split()])
	print(b, c)
answer()


n1 = int(input())
arr1 = list(map(int, input().split()))
n2 = int(input())
arr2 = list(map(int, input().split()))
res = []
flag = True
for i in arr1:
	if flag:
		for j in arr2:
			if i + j not in arr1 and i + j not in arr2:
				res.append(i)
				res.append(j)
				flag = False
				break
	else:
		break
for y in res:
	print(y, end=' ')


n = int(input())
n1 = list(map(int, input().split()))
m = int(input())
n2 = list(map(int, input().split()))
print(max(n1), max(n2))


n = int(input())
nlist = set(map(int, input().split()))
m = int(input())
mlist = set(map(int, input().split()))
for n in nlist:
	for m in mlist:
		a = m + n
		if a in nlist or a in mlist:
			continue
		else:
			print(n, m)
			exit(0)


n = int(input())
l = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
print(max(l), max(t))


a = list()
b = list()
n1 = int(input())
a = [int(i) for i in input().split()]
n2 = int(input())
b = [int(i) for i in input().split()]
i = 0
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(str(a[i]) + ' ' + str(b[j]))
			break
	else:
		continue
	break


n = int(input())
s1 = max([int(i) for i in input().split()])
m = int(input())
s2 = max([int(i) for i in input().split()])
print(s1, s2)


def calculate(arr1, arr2):
	for i in arr1:
		for j in arr2:
			res = i + j
			if not res in arr1 and (not res in arr2):
				return (i, j)
lenA = input()
A = [int(x) for x in input().split(' ')]
lenB = input()
B = [int(y) for y in input().split(' ')]
(w, z) = calculate(A, B)
print(w, z)


soma = []
parte1 = []
parte2 = []
an_elements = int(input())
a = input().split()
for i in range(an_elements):
	a[i] = int(a[i])
bn_elements = int(input())
b = input().split()
for i in range(bn_elements):
	b[i] = int(b[i])
for i in a:
	for k in b:
		soma.append(k + i)
		parte1.append(i)
		parte2.append(k)
lensoma = len(soma)
for i in range(lensoma):
	condition1 = soma[i] in a
	condition2 = soma[i] in b
	if condition1 == False and condition2 == False:
		print(parte1[i], parte2[i])
		break


def ii():
	return int(input())

def lmii():
	return list(map(int, input().split()))
sizea = ii()
arraya = lmii()
sizeb = ii()
arrayb = lmii()
d = []
e = []
for i in range(sizea):
	for j in range(sizeb):
		x = arraya[i] + arrayb[j]
		if x not in arraya and x not in arrayb:
			d.append(arraya[i])
			e.append(arrayb[j])
			break
		else:
			continue
print(d[0], e[0])


N = int(input())
A = list(map(int, input().split(' ')))
M = int(input())
B = list(map(int, input().split(' ')))
print(max(A), max(B), end=' ')


def swap(a, i, j):
	temp = a[i]
	a[i] = a[j]
	a[j] = temp
n1 = input()
n1 = int(n1)
a = input().split()
n2 = input()
n2 = int(n2)
b = input().split()
for i in range(n1):
	a[i] = int(a[i])
for i in range(n2):
	b[i] = int(b[i])
for i in range(n1 - 1):
	temp = i
	for j in range(i, n1):
		if a[temp] > a[j]:
			swap(a, temp, j)
			temp = j
	if temp != j:
		swap(a, temp, i)
for i in range(n2 - 1):
	temp = i
	for j in range(i, n2):
		if b[temp] > b[j]:
			swap(b, temp, j)
			temp = j
	if temp != j:
		swap(b, temp, i)
print(a[n1 - 1], b[n2 - 1])


n = int(input())
num_str1 = input().split()
num1 = []
for num in num_str1:
	num1.append(int(num))
m = int(input())
num_str2 = input().split()
num2 = []
for num in num_str2:
	num2.append(int(num))
for i in num1:
	for j in num2:
		sum = i + j
		if sum not in num1 and sum not in num2:
			print(str(i) + ' ' + str(j))
			break
	else:
		continue
	break


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
c = 0
for i in range(n):
	for j in range(m):
		x = l1[i] + l2[j]
		if x not in l1 and x not in l2:
			print(l1[i], l2[j])
			c = 1
			break
	if c == 1:
		break


t = int(input())
H = list(map(int, input().split()))
m = int(input())
V = list(map(int, input().split()))
for i in H:
	for j in V:
		r = i + j
		if r not in H and r not in V:
			print(i, j)
			exit()


def main():
	a_elements = int(input())
	a = [int(x) for x in input().split()]
	max_a = max(a)
	b_elements = int(input())
	b = [int(x) for x in input().split()]
	max_b = max(b)
	print(f'{max_a} {max_b}')
main()


n = int(input())
l = list(map(int, input().split(' ')))
k = int(input())
l2 = list(map(int, input().split(' ')))
print(max(l), max(l2))


m = int(input())
a = [int(x) for x in input().split()]
n = int(input())
b = [int(x) for x in input().split()]

def print_pair(a, b):
	nums = set(a + b)
	for x in a:
		for y in b:
			if x + y not in nums:
				return ' '.join([str(x), str(y)])
	return None
print(print_pair(a, b))


def bin_serach(n, A, strt, len):
	low = strt
	high = len - 1
	while low <= high:
		mid = (low + high) // 2
		if n < A[mid]:
			high = mid - 1
		elif n > A[mid]:
			low = mid + 1
		else:
			return True
	else:
		return False
n = int(input())
A = [int(i) for i in input().split()]
m = int(input())
B = [int(i) for i in input().split()]
A.sort()
B.sort()
for i in range(n):
	for j in range(m):
		sum = A[i] + B[j]
		if not bin_serach(sum, A, i, n) and (not bin_serach(sum, B, j, m)):
			print(A[i], B[j])
			quit()


import sys
n1 = int(input())
q1 = input().split()
n2 = int(input())
q2 = input().split()
for i in range(0, n1):
	q1[i] = int(q1[i])
for i in range(0, n2):
	q2[i] = int(q2[i])
for i in range(0, n1):
	for j in range(0, n2):
		sum = q1[i] + q2[j]
		if sum in q1 or sum in q2:
			m = 1
		else:
			print(q1[i], q2[j])
			sys.exit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print('%d %d\n' % (max(a), max(b)))


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
a = max(arr1)
b = max(arr2)
print(a, b)


def main():
	n = input()
	a = list(map(int, input().split()))
	m = input()
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	print(a[-1], b[-1])
main()


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A.sort()
B.sort()
f = 0
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, j)
			f = 1
			break
	if f == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		if a.count(a[i] + b[j]) == 0 and b.count(a[i] + b[j]) == 0:
			print(a[i], end=' ')
			print(b[j])
			exit()


n = int(input())
a = list(map(int, input().split()))
p = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


import sys
n = int(input())
l = list(map(int, input().split()))
m = int(input())
p = list(map(int, input().split()))
x = l + p
if n > m:
	for i in range(m):
		for j in range(n):
			t = l[j] + p[i]
			if (t in x) == False:
				print(l[j], p[i])
				sys.exit()
			else:
				pass
else:
	for i in range(n):
		for j in range(m):
			t = p[j] + l[i]
			if (t in x) == False:
				print(l[i], p[j])
				sys.exit()
			else:
				pass


from math import *
from sys import *
from collections import defaultdict
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
n = int(stdin.readline())
b = list(map(int, stdin.readline().split()))
print(max(a), max(b))


n = int(input())
l = list(map(int, input().split()))
m = int(input())
d = list(map(int, input().split()))
print(max(l), max(d))


Asize = int(input())
ElementA = input()
Bsize = int(input())
ElementB = input()

def split(size, element):
	splittedarray = []
	Esplit = element.split()
	for i in range(size):
		Esplit[i] = splittedarray.append(int(Esplit[i]))
	return splittedarray

def count(x, y):
	for i in a:
		for j in b:
			value = i + j
			if not value in a and (not value in b):
				return str(i) + ' ' + str(j)
a = split(Asize, ElementA)
b = split(Bsize, ElementB)
print(count(a, b))


Z = input()
z = map(int, input().split())
Y = input()
y = map(int, input().split())
print(max(z), max(y))


def main():
	na = int(input())
	A = set(map(int, input().split()))
	nb = int(input())
	B = set(map(int, input().split()))
	for a in A:
		for b in B:
			s = a + b
			if s not in A and s not in B:
				print('{} {}'.format(a, b))
				return
	pass
import sys
input = sys.stdin.readline
main()


import sys
lines = sys.stdin.readlines()
n = int(lines[0])
a = [int(s) for s in lines[1].strip().split(' ')]
m = int(lines[2])
b = [int(s) for s in lines[3].strip().split(' ')]
for i in a:
	for j in b:
		c = i + j
		if not c in a and (not c in b):
			print(i, j, sep=' ')
			exit(0)


n = int(input())
ipa = input()
a = ipa.split()
for i in range(0, n):
	a[i] = eval(a[i])
m = int(input())
ipb = input()
b = ipb.split()
for i in range(0, m):
	b[i] = eval(b[i])
for i in range(0, n):
	for j in range(0, m):
		test = a[i] + b[j]
		if a.count(test) == 0 and b.count(test) == 0:
			ni = i
			mj = j
print(a[ni], b[mj])


import sys
n = int(input())
a = set(map(int, input().split()))
m = int(input())
b = set(map(int, input().split()))
for u in a:
	for v in b:
		if u + v not in a and u + v not in b:
			print(u, v)
			sys.exit()


wyn = 0
for i in range(2):
	n = int(input())
	l = list(map(int, input().split()))
	print(max(l), end=' ')


n = int(input())
elementsOfA = [int(i) for i in input().split()]
m = int(input())
elementsOfB = [int(i) for i in input().split()]
largestElementOfA = -1
largestElementOfB = -1
for item in elementsOfA:
	if item > largestElementOfA:
		largestElementOfA = item
for item in elementsOfB:
	if item > largestElementOfB:
		largestElementOfB = item
print(largestElementOfA, largestElementOfB)


n = int(input())
na = list(map(int, input().split()))
m = int(input())
mb = list(map(int, input().split()))
(x, y) = (0, 0)
l = na + mb
for i in na:
	for j in mb:
		if i + j not in l:
			if x == 0 and y == 0:
				(x, y) = (i, j)
		else:
			continue
print(x, y)


a = int(input())
sa = list(map(int, input().split()))
b = int(input())
ba = list(map(int, input().split()))
sa.sort()
ba.sort()
for i in sa:
	for j in ba:
		s = i + j
	if s not in sa and s not in ba:
		print(i, j)
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
s = set(a) | set(b)
p = 0
for i in a:
	for j in b:
		if i + j not in s:
			print(i, j)
			p = 1
			break
	if p == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
D = {}
for i in range(n):
	D[a[i]] = 1
for j in range(m):
	D[b[j]] = 1
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in D:
			print(a[i], b[j])
			exit()


a = int(input())
b = map(int, input().split(maxsplit=a))
c = int(input())
d = map(int, input().split(maxsplit=c))
e = sorted(list(b))
r = sorted(list(d))
print(e[a - 1], r[c - 1])


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
print(max(l1), max(l2))


import sys
import os
from io import IOBase, BytesIO

def main():
	n = int(input())
	A = get_array()
	m = int(input())
	B = get_array()
	A.sort()
	B.sort()
	print(A[-1], B[-1])
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()
main()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
sa = set(a)
sb = set(b)
for i in range(n):
	for j in range(m):
		q = a[i] + b[j]
		if q not in sa and q not in sb:
			print(a[i], b[j])
			exit(0)


n = int(input())
a = input().split()
m = int(input())
b = input().split()
for i in range(n):
	a[i] = int(a[i])
for i in range(m):
	b[i] = int(b[i])
a.sort()
b.sort()
k = [a[n - 1], b[m - 1]]
k[0] = str(k[0])
k[1] = str(k[1])
s = ' '.join(k)
print(s)


n = int(input())
li = [int(i) for i in input().split()]
m = int(input())
li1 = [int(i) for i in input().split()]
a = 0
b = 0
for i in range(n):
	for j in range(m):
		k = li[i] + li1[j]
		if k not in li and k not in li1:
			a = li[i]
			b = li1[j]
			break
	if a != 0 and b != 0:
		break
print(a, b)


n = int(input())
A = []
A = list(map(int, input().split()))
m = int(input())
B = []
B = list(map(int, input().split()))
l = []
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			l.append([i, j])
for i in l[0]:
	print(i, end=' ')


n = int(input())
A = list((int(x) for x in input().split()))
m = int(input())
B = list((int(y) for y in input().split()))
flag = 0
for i in range(n):
	for j in range(m):
		c = A[i] + B[j]
		if c not in A and c not in B:
			print('{} {}'.format(A[i], B[j]))
			flag = 1
		if flag == 1:
			break
	if flag == 1:
		break


n = int(input())
ln = [int(x) for x in input().split()]
m = int(input())
lm = [int(x) for x in input().split()]
print(max(ln), ' ', max(lm))


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
(h, u) = (0, 0)
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			(h, u) = (i, j)
print(h, u)


a = []
b = []
x = []
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
	a.append(x[i])
m = int(input())
y = []
y = list(map(int, input().split()))
for i in range(m):
	b.append(y[i])
m1 = a[0]
for i in range(1, n):
	if a[i] > m1:
		m1 = a[i]
m2 = b[0]
for i in range(1, m):
	if b[i] > m2:
		m2 = b[i]
print(m1, ' ', m2)


import sys
a = int(input())
alist = list(map(int, input().split()))
b = int(input())
blist = list(map(int, input().split()))
brk = False
for i in alist:
	if brk:
		break
	for j in blist:
		s = i + j
		if s not in alist and s not in blist:
			print(str(i) + ' ' + str(j))
			brk = True
			break


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
ans1 = 0
ans2 = 0
found = False
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			ans1 = i
			ans2 = j
			found = True
			break
	if found:
		break
print(ans1, ans2)


import bisect
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
for x in a:
	for y in b:
		s = x + y
		ba = bisect.bisect_right(a, s)
		bb = bisect.bisect_right(b, s)
		if (ba == 0 or a[ba - 1] != s) and (bb == 0 or b[bb - 1] != s):
			print(x, y)
			exit(0)


n1 = int(input())
l1 = input().split(' ')
for i in range(len(l1)):
	l1[i] = int(l1[i])
n2 = int(input())
l2 = input().split(' ')
for i in range(len(l2)):
	l2[i] = int(l2[i])
l1.sort()
l2.sort()
print(l1[n1 - 1], l2[n2 - 1])


n1 = int(input())
a = [int(x) for x in input().split()]
n2 = int(input())
b = [int(x) for x in input().split()]
print(max(a), max(b))


a_length = int(input())
a_string = input()
a_string = a_string.split(' ')
b_length = int(input())
b_string = input()
b_string = b_string.split(' ')

def create_list(string_list):
	output = []
	for current_number in string_list:
		output.append(int(current_number))
	return output
(a_list, b_list) = (create_list(a_string), create_list(b_string))
global_list = []
for current_num in a_list:
	global_list.append(current_num)
for current_num in b_list:
	global_list.append(current_num)
ans = False
for current_a in a_list:
	for current_b in b_list:
		if ans == False:
			if current_a + current_b not in global_list:
				print(current_a, current_b)
				ans = True


ac = int(input())
a = list(map(int, input().split()))
bc = int(input())
b = list(map(int, input().split()))
print(max(a), max(b))


nA = int(input())
A = list(map(int, input().split()))
nB = int(input())
B = list(map(int, input().split()))
print(max(A), end=' ')
print(max(B))


n = int(input())
l1 = max([int(q) for q in input().split()])
m = int(input())
l2 = max([int(w) for w in input().split()])
print(l1, l2)


n1 = int(input())
l1 = list(map(int, input().split()))
n2 = int(input())
l2 = list(map(int, input().split()))
for i in range(len(l1)):
	for j in range(len(l2)):
		x = l1[i] + l2[j]
		b = 1
		if x in l1 or x in l2:
			b = 0
		if b:
			print(l1[i], l2[j])
			break
	if b:
		break


int(input())
n = max(map(int, input().split()))
int(input())
m = max(map(int, input().split()))
print(n, m)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = set()
for elem in a:
	c.add(elem)
for elem in b:
	c.add(elem)
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in c:
			print(a[i], b[j])
			c = set()
			break
	if len(c) == 0:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
x = a[n - 1]
y = b[m - 1]
print(f'{x} {y}')


n = int(input())
a = input().split()
m = int(input())
b = input().split()
for i in range(n):
	a[i] = int(a[i])
for j in range(m):
	b[j] = int(b[j])
a.sort()
b.sort()
print(a[n - 1], b[m - 1])


input()
print(max([int(i) for i in input().split()]), end=' ')
input()
print(max([int(i) for i in input().split()]), end=' ')


sizeA = int(input())
elementA = input()
sizeB = int(input())
elementB = input()

def splitting(size, element):
	num = []
	split = element.split(' ')
	for i in range(size):
		num.append(int(split[i]))
	return num
A = splitting(sizeA, elementA)
B = splitting(sizeB, elementB)

def main(A, B):
	for a in A:
		for b in B:
			temp = a + b
			if not temp in A and (not temp in B):
				return str(a) + ' ' + str(b)
print(main(A, B))


n = int(input())
a = list(map(int, input().split()))
print(max(a), end=' ')
n = int(input())
a = list(map(int, input().split()))
print(max(a), end=' ')


n = int(input())
na = map(int, input().split())
m = int(input())
ma = map(int, input().split())
print(max(na), max(ma))


n = int(input())
a = [int(num) for num in input().split()]
m = int(input())
b = [int(num) for num in input().split()]
for i in a:
	for j in b:
		if a.count(i + j) == 0 and b.count(i + j) == 0:
			print(i, j)
			break
	else:
		continue
	break


q = int(input())
w = list(map(int, input().split()))
e = input()
r = list(map(int, input().split()))
for ii in w:
	for jj in r:
		p = ii + jj
		if p not in w and p not in r:
			ans1 = ii
			ans2 = jj
print(ans1, ans2)


n = int(input())
arr1 = [int(i) for i in input().split()]
m = int(input())
arr2 = [int(i) for i in input().split()]
arr1.sort()
arr2.sort()
print(arr1[-1], arr2[-1])


n = int(input())
nn = [*map(int, input().split())]
m = int(input())
mm = [*map(int, input().split())]
nn.sort()
mm.sort()
print(nn[-1], mm[-1])


def solve():
	first = input()
	first = set(map(int, input().split()))
	second = input()
	second = set(map(int, input().split()))
	for i in first:
		for j in second:
			if i + j not in first and i + j not in second:
				print('{0} {1}'.format(i, j))
				return
solve()


import sys
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().rstrip().split()))
m = int(f.readline())
b = list(map(int, f.readline().rstrip().split()))
a.sort()
b.sort()
print(str(a[n - 1]) + ' ' + str(b[m - 1]))


n1 = int(input())
l = list(map(int, input().split()))
set1 = set(l)
n2 = int(input())
l1 = list(map(int, input().split()))
set2 = set(l1)
for i in set1:
	for j in set2:
		if i + j not in set1 and i + j not in set2:
			print(i, j)
			exit()


R = lambda : map(int, input().split())
input()
l = sorted(R())
input()
k = sorted(R())
print(l[-1], k[-1])


input()
A = list((int(i) for i in input().split()))
input()
B = list((int(i) for i in input().split()))
print(max(A), max(B))


nA = int(input())
A = list(map(int, input().split(' ')))
nB = int(input())
B = list(map(int, input().split(' ')))
max1 = max(A)
max2 = max(B)
print(max1, max2)


a = input()
b = [int(b) for b in input().split()]
b.sort()
c = input()
d = [int(d) for d in input().split()]
d.sort()
print(b[-1], d[-1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
f = False
for i in range(n):
	for j in range(m):
		x = a[i] + b[j]
		if x not in a and x not in b:
			print(a[i], b[j])
			f = True
			break
	if f:
		break


input()
(*a,) = map(int, input().split())
input()
(*b,) = map(int, input().split())
c = set(a)
d = set(b)
for (s, t) in [(i, j) for i in a for j in b]:
	if s + t not in a and s + t not in b:
		print(s, t)
		exit()


n = int(input())
ar1 = list(map(int, input().split()))
m = int(input())
ar2 = list(map(int, input().split()))
print(max(ar1), max(ar2))


input()
A = set([int(x) for x in input().split()])
input()
B = set([int(x) for x in input().split()])
print(max(A), max(B))


n_A = int(input())
A = [int(i) for i in input().split(' ')]
n_B = int(input())
B = [int(i) for i in input().split(' ')]
A.sort()
B.sort()
print('{} {}'.format(A[-1], B[-1]))


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
N1 = int(stdin.readline())
a = list(map(int, stdin.readline().rstrip().split()))
N2 = int(stdin.readline())
b = list(map(int, stdin.readline().rstrip().split()))
f = 'a'
for i in range(N1):
	if f == 'b':
		break
	for j in range(N2):
		s = a[i] + b[j]
		if s not in a and s not in b:
			print(a[i], b[j])
			f = 'b'
			break


a = int(input())
d = list(map(int, input().split()))
b = int(input())
c = list(map(int, input().split()))
x = 0
y = 0
s = 0
for i in d:
	for j in c:
		if i + j not in d and i + j not in c:
			x = i
			y = j
		else:
			s = 0
print(x, y)


a = int(input())
b = input().split(' ')
c = []
for i in b:
	c.append(int(i))
d = int(input())
e = input().split(' ')
f = []
for i in e:
	f.append(int(i))
for i in range(len(c)):
	for j in range(len(f)):
		if c[i] + f[j] not in c and c[i] + f[j] not in f:
			x = c[i]
			y = f[j]
print(x, y)


m = int(input())
mlist = list(map(int, input().split()))
n = int(input())
nlist = list(map(int, input().split()))
final = []
for i in range(len(mlist)):
	for j in range(len(nlist)):
		k = mlist[i] + nlist[j]
		if k not in mlist and k not in nlist:
			final.append((mlist[i], nlist[j]))
print(final[0][0], final[0][1])


import random

def str_list_to_int(a):
	list_of_integers = list(map(int, a))
	return list_of_integers

def choose_numbers(list_1, list_2, n, m):
	while True:
		a = random.randint(0, n - 1)
		b = random.randint(0, m - 1)
		if list_1[a] + list_2[b] not in list_1 and list_1[a] + list_2[b] not in list_2:
			print(list_1[a], list_2[b])
			break
n = int(input())
list_1 = str_list_to_int(input().split())
m = int(input())
list_2 = str_list_to_int(input().split())
choose_numbers(list_1, list_2, n, m)


input()
a = sorted(map(int, input().split()), reverse=True)
input()
b = sorted(map(int, input().split()), reverse=True)
print(a[0], b[0])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]

def check(x, a, b):
	if x not in a and x not in b:
		return True
	else:
		return False
f = False
for i in a:
	if f:
		break
	for j in b:
		if check(i + j, a, b):
			print(i, j)
			f = True
			break


a = int(input())
am = sorted(list(map(int, input().rstrip().split())))
b = int(input())
bm = sorted(list(map(int, input().rstrip().split())))
print(am[-1], bm[-1])


n = int(input())
a = [int(x) for x in input().strip().split()]
m = int(input())
b = [int(x) for x in input().strip().split()]
c = []
for i in a:
	for j in b:
		s = i + j
		if s not in a and s not in b:
			c.append(i)
			c.append(j)
			break
print(c[0], c[1])


A = []
B = []
lenA = int(input())
A = input()
dataA = A.split()
lenB = int(input())
B = input()
dataB = B.split()
for i in dataA:
	for j in dataB:
		temp = int(i) + int(j)
		if not str(temp) in dataA and (not str(temp) in dataB):
			print(i, j)
			exit()


n = int(input())
AInp = input()
m = int(input())
BInp = input()
A = [int(elem) for elem in AInp.split(' ')]
B = [int(elem) for elem in BInp.split(' ')]
stop = False
for a in A:
	for b in B:
		if a + b not in A + B:
			print(str(a) + ' ' + str(b))
			stop = True
			break
	if stop:
		break


n = int(input())
a = set(map(int, input().split()))
m = int(input())
b = set(map(int, input().split()))
for i in range(1, 201):
	if i in a:
		for j in range(1, 201):
			if j in b:
				if i + j not in a and i + j not in b:
					print(i, j)
					exit()


num = int(input())
num1 = input()
arr = []
for i in num1.split():
	arr.append(int(i))
arr.sort()
if num != len(arr):
	print('error')
num3 = int(input())
num4 = input()
arr1 = []
for i in num4.split():
	arr1.append(int(i))
arr1.sort()
if num3 != len(arr1):
	print('error')
print(str(arr.pop()), str(arr1.pop()))


a = int(input())
a = [int(i) for i in input().split()]
b = int(input())
b = [int(i) for i in input().split()]
a.sort()
b.sort()
print(a[-1], b[-1])


a = int(input())
arr = [int(new) for new in input().split()]
arr.sort()
b = int(input())
brr = [int(new) for new in input().split()]
brr.sort()
print(arr[a - 1], brr[b - 1])


s = set()
a = []
b = []
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	s.add(a[i])
m = int(input())
b = [int(i) for i in input().split()]
for i in range(m):
	s.add(b[i])
for i in range(n):
	for j in range(m):
		if a[i] + b[j] in s:
			continue
		print(str(a[i]), str(b[j]))
		exit(0)


class cinn:

	def __init__(self):
		self.x = []

	def cin(self, t=int):
		if len(self.x) == 0:
			a = input()
			self.x = a.split()
			self.x.reverse()
		return self.get(t)

	def get(self, t):
		return t(self.x.pop())

	def clist(self, n, t=int):
		l = [0] * n
		for i in range(n):
			l[i] = self.cin(t)
		return l

	def clist2(self, n, t1=int, t2=int, t3=int, tn=2):
		l = [0] * n
		for i in range(n):
			if tn == 2:
				a1 = self.cin(t1)
				a2 = self.cin(t2)
				l[i] = (a1, a2)
			elif tn == 3:
				a1 = self.cin(t1)
				a2 = self.cin(t2)
				a3 = self.cin(t3)
				l[i] = (a1, a2, a3)
		return l

	def clist3(self, n, t1=int, t2=int, t3=int):
		return self.clist2(self, n, t1, t2, t3, 3)

	def cout(self, i, ans=''):
		if ans == '':
			print('Case #' + str(i + 1) + ':', end=' ')
		else:
			print('Case #' + str(i + 1) + ':', ans)

	def printf(self, thing):
		print(thing, end='')

	def countlist(self, l, s=0, e=None):
		if e == None:
			e = len(l)
		dic = {}
		for el in range(s, e):
			if l[el] not in dic:
				dic[l[el]] = 1
			else:
				dic[l[el]] += 1
		return dic

	def talk(self, x):
		print(x, flush=True)

	def dp1(self, k):
		L = [-1] * k
		return L

	def dp2(self, k, kk):
		L = [-1] * k
		for i in range(k):
			L[i] = [-1] * kk
		return L

	def isprime(self, n):
		if n == 1 or n == 0:
			return False
		for i in range(2, int(n ** 0.5 + 1)):
			if n % i == 0:
				return False
		return True

	def factors(self, n):
		from functools import reduce
		return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

	def nthprime(self, n):
		i = 0
		s = 2
		L = []
		while i < n:
			while not self.isprime(s):
				s += 1
			L.append(s)
			s += 1
			i += 1
		return L

	def matrixin(self, m, n, t=int):
		L = []
		for i in range(m):
			p = self.clist(n, t)
			L.append(p)
		return L

	def seive(self, k):
		n = k + 1
		L = [True] * n
		L[1] = False
		L[0] = False
		for i in range(2, n):
			if L[i] == True:
				for j in range(2 * i, n, i):
					L[j] = False
		return L

	def seiven(self, n, L):
		i = 0
		for j in range(len(L)):
			if L[j] == True:
				i += 1
			if i == n:
				return j

	def matrixin2(self, m, t=int):
		L = []
		for i in range(m):
			iny = self.cin(str)
			lsmall = []
			for el in iny:
				lsmall.append(t(el))
			L.append(lsmall)
		return L

def rotcord(i, j, n):
	return (j, n - i - 1)

def rotbje(k):
	if k == '.':
		return k
	ar = ['>', 'v', '<', '^']
	return ar[(ar.index(k) + 1) % 4]
c = cinn()
n = c.cin()
a = c.clist(n)
a.sort()
y = a[n - 1]
x = c.cin()
b = c.clist(x)
b.sort()
f = b[x - 1]
print(y, f)


n = int(input())
k = [int(n) for n in input().split()]
m = int(input())
l = [int(m) for m in input().split()]
flag = 0
for i in range(len(k)):
	for j in range(len(l)):
		sum = k[i] + l[j]
		if sum not in k and sum not in l:
			print(k[i], l[j])
			flag = 1
			break
	if flag == 1:
		break


n = input().split()
a = list(map(int, input().split()))
m = input().split()
b = list(map(int, input().split()))
print(str(max(a)) + ' ' + str(max(b)))


from sys import stdin
inp = stdin.readlines()
a = [int(i) for i in inp[1].split()]
b = [int(i) for i in inp[3].split()]
a = list(sorted(a))
b = list(sorted(b))

def bs(arr, val, l, r):
	if not l <= r:
		return False
	mid = (l + r) // 2
	if arr[mid] == val:
		return True
	if arr[mid] < val:
		return bs(arr, val, mid + 1, r)
	return bs(arr, val, l, mid - 1)
for i in a:
	for j in b:
		if not (bs(a, i + j, 0, len(a) - 1) or bs(b, i + j, 0, len(b) - 1)):
			print(i, j)
			exit()


n = int(input())
a = [int(o) for o in input().split()]
m = int(input())
b = [int(o) for o in input().split()]
s = a[:] + b[:]
s = set(s)
flag = 0
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in s:
			print(a[i], b[j])
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
listA = [int(x) for x in input().split()]
m = int(input())
listB = [int(x) for x in input().split()]
flag = 0
for i in listA:
	for j in listB:
		if i + j not in listA and i + j not in listB:
			print(i, j, end=' ')
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
s = list(map(int, input().split()))
m = int(input())
g = list(map(int, input().split()))
g.sort(reverse=True)
s.sort(reverse=True)
print(s[0], g[0])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print(max(a), max(b), sep=' ')


x = input()
first = map(int, input().split(' '))
y = input()
second = map(int, input().split(' '))
print(max(first), max(second))


def check(A, B):
	for i in A:
		for j in B:
			a = int(i) + int(j)
			if not str(a) in A and (not str(a) in B):
				return (i, j)

def main():
	arr_a = int(input())
	A = input().split()
	arr_b = int(input())
	B = input().split()
	(i, j) = check(A, B)
	print(i, j)
main()


n = int(input())
a1 = input().split()
m = int(input())
b1 = input().split()
a = []
b = []
k = 0
for i in a1:
	a.append(int(i))
for i in b1:
	b.append(int(i))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			k = 1
			break
	if k == 1:
		break


n = input()
A = [int(n) for n in input().split()]
m = input()
B = [int(m) for m in input().split()]
nomer = 0
while nomer < len(A):
	pinkypie = A[nomer]
	Avrora = 0
	nomer = nomer + 1
	flag = 0
	while Avrora < len(B):
		donut = B[Avrora]
		Avrora = Avrora + 1
		chocolate = 0
		while chocolate < len(A) + len(B):
			if chocolate < len(A):
				if A[chocolate] == pinkypie + donut:
					break
			elif B[chocolate - len(A)] == pinkypie + donut:
				break
			chocolate = chocolate + 1
		else:
			print(pinkypie, donut)
			flag = 1
			break
	if flag == 1:
		break


n = input()
A = list(map(int, input().split()))
m = input()
B = list(map(int, input().split()))
count = 0
for o in A:
	for p in B:
		sum = o + p
		if sum in A or sum in B:
			continue
		else:
			count = count + 1
			print('{0} {1}'.format(o, p))
			break
	if count == 1:
		break


def solve(test):
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	b = list(map(int, input().split()))
	d = [0 for i in range(600)]
	for x in a:
		d[x] = 1
	for x in b:
		d[x] = 1
	ok = False
	for x in a:
		for y in b:
			if d[x + y] == 0 and (not ok):
				print(x, y)
				ok = True
t = 1
for _ in range(t):
	solve(_ + 1)


p = int(input())
lst = list(map(int, input().split()))
q = int(input())
lst1 = list(map(int, input().split()))
q = 0
for i in lst:
	if q == 0:
		for j in lst1:
			if i + j in lst or i + j in lst1:
				pass
			else:
				print(i, j)
				q = 1
				break
	else:
		break


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
x = sorted(A)[-1]
y = sorted(B)[-1]
print(x, y)


input()
A = input().split()
input()
B = input().split()
for x in range(len(A)):
	A[x] = int(A[x])
for x in range(len(B)):
	B[x] = int(B[x])
flag = False
for n in A:
	for m in B:
		if n + m not in A and n + m not in B:
			print(n, m)
			flag = True
			break
	if flag:
		break


def check(A, B):
	for i in A:
		for j in B:
			a = int(i) + int(j)
			if not str(a) in A and (not str(a) in B):
				return (i, j)
lenA = int(input())
A = input().split()
lenB = int(input())
B = input().split()
(i, j) = check(A, B)
print(i, j)


def f(a, b, n, m):
	for i in range(a):
		for j in range(b):
			x = n[i] + m[j]
			if x not in n and x not in m:
				return (n[i], m[j])
a = int(input())
n = list(map(int, input().split()))
b = int(input())
m = list(map(int, input().split()))
x = f(a, b, n, m)
for i in x:
	print(i, end=' ')


input()
l = list(map(int, input().split()))
input()
m = list(map(int, input().split()))
print(max(l), max(m))


def main():
	n = input()
	ns = set([int(x) for x in input().split(' ')])
	m = input()
	ms = set([int(x) for x in input().split(' ')])
	print(str(max(ns)) + ' ' + str(max(ms)))
main()


a = int(input())
if a == 1:
	al = int(input())
else:
	al = list(map(int, input().split()))
b = int(input())
if b == 1:
	bl = int(input())
else:
	bl = list(map(int, input().split()))
if a == 1 and b == 1:
	print(al, end=' ')
	print(bl)
elif a == 1 and b > 1:
	print(al, end=' ')
	print(max(bl))
elif b == 1 and a > 1:
	print(max(al), end=' ')
	print(bl)
else:
	print(max(al), end=' ')
	print(max(bl))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
ma = max(a)
mb = max(b)
print(ma, mb)


x = int(input())
c = list(map(int, input().split()))
y = int(input())
d = list(map(int, input().split()))
lst = []
for x in c:
	for y in d:
		e = x + y
		if e not in c and e not in d:
			lst.append((x, y))
			break
	if len(lst) == 1:
		break
print(lst[0][0], lst[0][1])


n = input()
a = list(map(int, str(input()).strip().split()))
m = input()
b = list(map(int, str(input()).strip().split()))
(di1, di2) = ({}, {})
for i in a:
	di1[i] = 1
for i in b:
	di2[i] = 1
flag = 0
for i in a:
	for j in b:
		m = i + j
		if not m in di1 and (not m in di2):
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
a = list(map(int, input().split()))[:n]
m = int(input())
b = list(map(int, input().split()))[:m]
sum = 0
for i in range(n):
	for j in range(m):
		sum = a[i] + b[j]
		if sum in a or sum in b:
			continue
		else:
			c = a[i]
			d = b[j]
			break
print(c, end=' ')
print(d)


a = int(input())
al = list(map(int, input().split()))
b = int(input())
bl = list(map(int, input().split()))
al.sort()
bl.sort()
print(al[-1], end=' ')
print(bl[-1])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
arr1 = list(map(int, input().split()))
print(max(arr), max(arr1))


n = int(input())
a = [int(n) for n in input().split()]
m = int(input())
b = [int(m) for m in input().split()]
for i in range(n):
	for j in range(m):
		cek = 0
		total = a[i] + b[j]
		for k in range(n):
			if total != a[k]:
				cek = cek + 1
		for l in range(m):
			if total != b[l]:
				cek = cek + 1
		if cek == n + m:
			print(str(a[i]) + ' ' + str(b[j]))
			break
	if cek == n + m:
		break


from math import *
m = []
n = []
for i in range(2):
	y = input()
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	m.append(x)
print(m[0][0], end=' ')
print(m[1][0])


x = int(input())
l = []
for x in map(int, input().split()):
	l.append(x)
z = int(input())
l2 = []
for z in map(int, input().split()):
	l2.append(z)
f = l + l2
h = 0
while h < len(l):
	s = 0
	while s < len(l2):
		if l[h] + l2[s] in f:
			s += 1
		else:
			print(l[h], l2[s])
			exit()
	h += 1


na = int(input())
a = str(input()).split()
nb = int(input())
b = str(input()).split()
maxa = -1
maxb = -1
for x in a:
	maxa = max(int(x), maxa)
for x in b:
	maxb = max(int(x), maxb)
print(maxa, maxb)


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
l = list(set(a + b))
f = 1
for i in a:
	for j in b:
		if i + j not in l:
			print(i, j)
			f = 0
			break
	if f == 0:
		break


cap_first = int(input())
a = list([int(x) for x in input().split(' ')])
cap_second = int(input())
b = list([int(x) for x in input().split(' ')])
result = []
for i in range(cap_first):
	for j in range(cap_second):
		if not a[i] + b[j] in a and (not a[i] + b[j] in b):
			result.append(a[i])
			result.append(b[j])
			break
	if result != []:
		break
print(result[0], result[1])


def I():
	return map(int, input().split())
n = int(input())
a = sorted(list(I()))
m = int(input())
b = sorted(list(I()))
if (a[-1] + b[-1] < a[0] or a[-1] + b[-1] > a[-1]) and (a[-1] + b[-1] < b[0] or a[-1] + b[-1] > b[-1]):
	print(a[-1], b[-1])
else:
	print(a[0], b[0])


def choose2num(a, b):
	return [max(a), max(b)]
na = int(input())
ea = list(map(int, input().split()))
nb = int(input())
eb = list(map(int, input().split()))
print(*choose2num(ea, eb))


a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
m = 0
for x in range(a):
	for j in range(c):
		if b[x] + d[j] not in b:
			if b[x] + d[j] not in d:
				print(b[x], d[j])
				m = 1
				break
	if m == 1:
		break
if m != 1:
	print(0)


def solve():
	n = int(input())
	a = [int(s) for s in input().split()]
	m = int(input())
	b = [int(s) for s in input().split()]
	print(max(a), max(b))
solve()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
d = {}
for i in a:
	if i not in d:
		d[i] = 'True'
for i in b:
	if i not in d:
		d[i] = 'True'
for i in a:
	for j in b:
		if i + j not in d:
			print(i, j)
			exit()


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
ok = False
for i in l1:
	for j in l2:
		if i + j not in l1 and i + j not in l2:
			print(i, j)
			ok = True
			break
	if ok:
		break


n1 = int(input())
numList1 = [int(x) for x in input().split()]
n2 = int(input())
numList2 = [int(x) for x in input().split()]
print(max(numList1), max(numList2))


n = int(input())
from sys import stdin
a = list(map(int, stdin.readline().split()))
m = int(input())
b = list(map(int, stdin.readline().split()))
z = True
i = 0
while i < n and z:
	j = 0
	while j < m and z:
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			z = False
		else:
			j += 1
	i += 1


from sys import stdin

def main():
	la = int(stdin.readline().strip())
	A = list(map(int, stdin.readline().split()))
	lb = int(stdin.readline().strip())
	B = list(map(int, stdin.readline().split()))
	conj = {}
	for i in A:
		conj[i] = 1
	for i in B:
		conj[i] = 1
	band = True
	i = 0
	while i < la and band:
		j = 0
		while j < lb and band:
			if conj.get(A[i] + B[j]) == None:
				print(A[i], B[j])
				band = False
			j += 1
		i += 1
main()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for e in a:
	for f in b:
		if e + f not in a and e + f not in b:
			print(e, f)
			exit(0)


a = int(input())
A = [int(x) for x in input().split(' ', a - 1)]
b = int(input())
B = [int(y) for y in input().split(' ', b - 1)]
print(max(A), max(B))


a = int(input())
x = input().split()
b = int(input())
y = input().split()
lst = []
lst1 = []
for i in x:
	for j in y:
		t = 0
		t = int(i) + int(j)
		if str(t) not in x and str(t) not in y:
			lst.append(int(i))
			lst1.append(int(j))
print(lst[0], lst1[0])


import sys
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
M = int(sys.stdin.readline())
B = list(map(int, sys.stdin.readline().split()))
answer = 0
for n in range(N):
	for m in range(M):
		if A[n] + B[m] not in A and A[n] + B[m] not in B:
			print(str(A[n]) + ' ' + str(B[m]))
			answer = 1
			break
	if answer == 1:
		break


ax = int(input())
a = [int(el) for el in input().split()]
bx = int(input())
b = [int(el) for el in input().split()]
print(max(a), max(b), sep=' ')


def count(n, numsA, m, numsB):
	(maxA, maxB) = (max(numsA), max(numsB))
	return str(maxA) + ' ' + str(maxB)
n = int(input())
numsA = [int(i) for i in input().split()]
m = int(input())
numsB = [int(i) for i in input().split()]
print(count(n, numsA, m, numsB))


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
max_A = max(A)
max_B = max(B)
print(max_A, max_B)


input()
X = list(map(int, input().split()))
input()
Y = list(map(int, input().split()))
for i in X:
	for j in Y:
		if i + j not in X and i + j not in Y:
			print(i, j)
			exit()


len_a = int(input())
A = [int(x) for x in input().split(' ')]
len_b = int(input())
B = [int(x) for x in input().split(' ')]
c = []
for a in A:
	for b in B:
		if a + b not in A and a + b not in B:
			c.append([str(a), str(b)])
print(' '.join(c[0]))


n = int(input())
l = list(set(map(int, input().split())))
s = set(l)
m = int(input())
arr = list(map(int, input().split()))
s1 = set(arr)
for i in range(n):
	for j in range(m):
		if l[i] + arr[j] not in s and l[i] + arr[j] not in s1:
			print(l[i], arr[j])
			exit()


a = int(input())
a_ar = list(map(int, input().split()))
b = int(input())
b_ar = list(map(int, input().split()))
for x in a_ar:
	for y in b_ar:
		if x + y not in a_ar and x + y not in b_ar:
			print(x, y)
			exit()
		else:
			continue


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)
input = stdin.readline
n = int(input().rstrip())
a = sorted([int(i) for i in input().split()], reverse=1)
m = int(input().rstrip())
b = sorted([int(i) for i in input().split()], reverse=1)
print(a[0], b[0])


m = int(input())
li = map(int, input().split())
li = sorted(li)
n = int(input())
li1 = map(int, input().split())
li1 = sorted(li1)
for i in li:
	for j in li1:
		if not i + j in li1:
			if not i + j in li:
				print(i, j)
				exit(0)


A = int(input())
a = list(map(int, input().split()))
B = int(input())
b = list(map(int, input().split()))
for i in range(A):
	for j in range(B):
		x = a[i] + b[j]
		if x not in a and x not in b:
			print(a[i], b[j])
			break
	else:
		continue
	break


def main():
	n = input()
	a_list = list(map(int, input().split(' ')))
	m = input()
	b_list = list(map(int, input().split(' ')))
	for a in a_list:
		for b in b_list:
			c = a + b
			if c not in a_list and c not in b_list:
				print(a, b)
				return
main()


def find(A, B):
	for a in A:
		for b in B:
			if a + b not in A and a + b not in B:
				return (a, b)
n = int(input())
A = [int(i) for i in input().split()]
m = int(input())
B = [int(i) for i in input().split()]
(a, b) = find(A, B)
print(a, b)


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
if a > b:
	while A[a - 1] + B[b - 1] in A or A[a - 1] + B[b - 1] in B:
		a -= 1
		if a == 0:
			a = len(A)
			b -= 1
else:
	while A[a - 1] + B[b - 1] in A or A[a - 1] + B[b - 1] in B:
		b -= 1
		if b == 0:
			b = len(B)
			a -= 1
print(A[a - 1], B[b - 1])


t = int(input())
l = list(map(int, input().split(' ')))
n = int(input())
k = list(map(int, input().split(' ')))
l.sort(reverse=True)
k.sort(reverse=True)
print(str(l[0]) + ' ' + str(k[0]))


from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
M = int(input())
B = [int(x) for x in input().split()]
DictA = defaultdict(bool)
for i in A:
	DictA[i] = True
DictB = defaultdict(bool)
for i in B:
	DictB[i] = True
flag = 0
for i in range(N):
	for j in range(M):
		if DictA[A[i] + B[j]] == False and DictB[A[i] + B[j]] == False:
			print(A[i], B[j])
			flag = 1
			break
	if flag == 1:
		break


def choose2num():
	inp1 = int(input())
	inpa1 = map(int, input().split())
	int(input())
	inpa2 = map(int, input().split())
	print(max(inpa1), max(inpa2))
choose2num()


def similar(l, a, m, b):
	a.sort()
	b.sort()
	flag = 0
	for i in range(l):
		for j in range(m):
			if a[i] + b[j] not in a and a[i] + b[j] not in b:
				print(a[i], b[j])
				flag = 1
				break
		if flag == 1:
			break
l = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
similar(l, a, m, b)


_ = input()
a = list(map(int, input().split()))
_ = input()
b = list(map(int, input().split()))
a.sort()
b.sort()
print(a[-1], b[-1])


arr1Len = int(input())
arr1 = [int(x) for x in input().split(' ')]
arr2Len = int(input())
arr2 = [int(x) for x in input().split(' ')]
for i in arr1:
	for j in arr2:
		if i + j not in arr1 and i + j not in arr2:
			print(i, j)
			exit()


n = int(input())
x = list(map(int, input().split()))
m = int(input())
y = list(map(int, input().split()))
x.sort()
y.sort()
print(x[n - 1], y[m - 1])


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	n = int(input())
	a = max((int(i) for i in input().split()))
	m = int(input())
	b = max((int(i) for i in input().split()))
	print(a, b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
state = 0
for x in l1:
	for y in l2:
		if x + y not in l1 and x + y not in l2:
			print(str(x) + ' ' + str(y))
			state = 1
			break
	if state == 1:
		break


m = int(input())
arr1 = set(map(int, input().split()))
n = int(input())
arr2 = set(map(int, input().split()))
print(str(max(arr1)) + ' ' + str(max(arr2)))


n = int(input())
arra = list(map(int, input().split()))
m = int(input())
arrb = list(map(int, input().split()))
for i in arra:
	flg = 0
	for j in arrb:
		if not i + j in arra and (not i + j in arrb):
			print(i, end=' ')
			print(j)
			flg = 1
			break
	if flg == 1:
		break


n = int(input())
a_num = str(input())
a_num = a_num.split()
if n == len(a_num):
	a = [int(i) for i in a_num]
n = int(input())
b_num = str(input())
b_num = b_num.split()
if n == len(b_num):
	b = [int(i) for i in b_num]
flag = 0
for i in a:
	if flag == 1:
		break
	for x in range(0, len(b)):
		ans = i + b[x]
		if ans not in a and ans not in b:
			print(i, b[x])
			flag += 1
			break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
s = 0
f = 0
for i in range(0, n):
	s = 0
	for j in range(0, m):
		s = a[i] + b[j]
		if s not in a and s not in b:
			f = 1
			p = a[i]
			q = b[j]
			break
if f == 1:
	print(p, q)


list1 = []
n1 = int(input())
list1 = [int(num) for num in input().split()]
list2 = []
n2 = int(input())
list2 = [int(num) for num in input().split()]
max1 = 0
for i in range(0, n1):
	if max1 < list1[i]:
		max1 = list1[i]
max2 = 0
for j in range(0, n2):
	if max2 < list2[j]:
		max2 = list2[j]
print(max1, max2)


def solve():
	input()
	return max(map(int, input().split()))
print(solve(), solve())


n = int(input())
a = input()
m = int(input())
b = input()
p = a.split()
q = [int(d) for d in p]
r = b.split()
s = [int(d) for d in r]
q.sort()
s.sort()
print(q[-1], s[-1])


N = int(input())
a = list(map(int, input().rstrip().split()))
M = int(input())
b = list(map(int, input().rstrip().split()))
s = set()
aset = set(a)
bset = set(b)
ok = False
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in aset and a[i] + b[j] not in bset:
			print(str(a[i]) + ' ' + str(b[j]))
			ok = True
			break
	if ok:
		break


def inp(dtype=str, strip=True):
	s = input()
	res = [dtype(p) for p in s.split()]
	res = res[0] if len(res) == 1 and strip else res
	return res

def problem1():
	n = inp(int)
	a = inp(int, strip=False)
	m = inp(int)
	b = inp(int, strip=False)
	union = set(a + b)
	for k1 in a:
		for k2 in b:
			if k1 + k2 not in union:
				print(k1, k2)
				return

def problem2():
	pass

def problem3():
	pass

def problem4():
	pass
problem1()


a = int(input())
b = list(map(int, set(map(int, input().split()))))
c = int(input())
d = list(map(int, set(map(int, input().split()))))
for i in range(len(b)):
	for j in range(len(d)):
		if b[i] + d[j] not in b and b[i] + d[j] not in d:
			break
print(b[i], d[j])


import math
n = int(input())
list1 = input().split()
for i in range(len(list1)):
	list1[i] = int(list1[i])
m = int(input())
list2 = input().split()
for i in range(len(list2)):
	list2[i] = int(list2[i])
list1.sort()
list2.sort()
print(str(list1[n - 1]) + ' ' + str(list2[m - 1]))


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = int(input())
ll = list(map(int, input().split()))
ll.sort()
print(l[-1], ll[-1])


from sys import stdin, stdout
a = int(input())
arr1 = [int(x) for x in stdin.readline().split()]
b = int(input())
arr2 = [int(y) for y in stdin.readline().split()]
print(str(max(arr1)) + ' ' + str(max(arr2)))


import sys
import math
import bisect

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	m = int(input())
	B = list(map(int, input().split()))
	sa = set(A)
	sb = set(B)
	for a in A:
		for b in B:
			if a + b not in sa and a + b not in sb:
				return [a, b]
	return [-1, -1]

def main():
	ans = solve()
	print(' '.join(list((str(a) for a in ans))))
main()


a = int(input())
array1 = list(map(int, input().split(' ')))
b = int(input())
array2 = list(map(int, input().split(' ')))
array1.sort(reverse=True)
array2.sort(reverse=True)
maximum = max(a, b)
for i in range(maximum):
	sum = array1[0] + array2[i]
	if sum not in array1 and sum not in array2:
		print(array1[0], array2[i])
		break
	else:
		continue


import getpass
import sys
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')
import math
import string
import re
import random
from decimal import Decimal, getcontext
from collections import deque
mod = 10 ** 9 + 7

def ria():
	return [int(i) for i in input().split()]
n = ria()[0]
a = max(ria())
n = ria()[0]
b = max(ria())
print(a, b)


n_a = int(input())
a = []
data = input().split(' ')
for i in data:
	a.append(int(i))
n_b = int(input())
b = []
data = input().split(' ')
for i in data:
	b.append(int(i))
max_a = max(a)
max_b = max(b)
print(max_a, max_b)


a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
for j in range(a):
	for i in range(c):
		e = b[j] + d[i]
		if e not in d and e not in b:
			print(b[j], ' ', d[i], sep='')
			exit()


n = int(input())
N = list(map(int, input().split()))
m = int(input())
M = list(map(int, input().split()))
find = False
for i in N:
	for j in M:
		if (i + j in N) == False and (i + j in M) == False:
			print(i, j)
			find = True
			break
	if find == True:
		break


n = int(input())
arrn = list(map(int, input().split()))
m = int(input())
arrm = list(map(int, input().split()))
arrn.sort()
arrm.sort()
print(arrn[-1], arrm[-1])


def lista(A, B):
	return (max(A), max(B))
nA = int(input())
A = [int(x) for x in input().split()]
nB = int(input())
B = [int(x) for x in input().split()]
print(max(A), max(B))


n1 = int(input())
numbers1 = input()
number1 = numbers1.split(' ')
n2 = int(input())
numbers2 = input()
number2 = numbers2.split(' ')
number1.sort(key=int)
a = number1[len(number1) - 1]
number2.sort(key=int)
b = number2[len(number2) - 1]
print(a + ' ' + b)


n = int(input())
first = [int(i) for i in input().split()]
m = int(input())
second = [int(i) for i in input().split()]
for i in range(len(first)):
	for y in range(len(second)):
		c = first[i] + second[y]
		if c not in first and c not in second:
			print(first[i], second[y])
			exit()
		else:
			continue


n = int(input())
a = list(map(int, input().strip().split()))[:n]
m = int(input())
b = list(map(int, input().strip().split()))[:m]
flag = 0
for i in range(0, n):
	for k in range(0, m):
		if a[i] + b[k] not in a and a[i] + b[k] not in b:
			print(a[i], b[k], sep=' ')
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
arr1 = set(map(int, input().split()))
m = int(input())
arr2 = set(map(int, input().split()))
check = False
for d in arr1:
	for t in arr2:
		if d + t not in arr1 and d + t not in arr2:
			print(d, t)
			check = True
			break
	if check:
		break


t = input()
z = map(int, input().split())
n = input()
y = map(int, input().split())
print(max(z), max(y))


a = int(input())
A = map(int, input().split())
b = int(input())
B = map(int, input().split())
print(max(A), max(B))


n = int(input())
arr1 = list(map(int, input().strip().split()))[:n]
k = int(input())
arr2 = list(map(int, input().strip().split()))[:k]
print(max(arr1), end=' ')
print(max(arr2))


n = int(input())
l = list(map(int, input().split()))
m = int(input())
z = list(map(int, input().split()))
flag = 0
for i in l:
	for j in z:
		if i + j not in l and i + j not in z:
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
A = input().split()
for i in range(n):
	A[i] = int(A[i])
m = int(input())
B = input().split()
for i in range(m):
	B[i] = int(B[i])
a = b = 0
for i in range(n):
	for j in range(m):
		x = A[i] + B[j]
		if A.count(x) == 0 and B.count(x) == 0:
			a = i
			b = j
print(A[a], B[b])


n = int(input())
l1 = list(map(int, input().strip().split()))[:n]
m = int(input())
l2 = list(map(int, input().strip().split()))[:m]
for i in l1:
	for j in l2:
		if i + j not in l1 and i + j not in l2:
			break
print(i, j)


N = int(input())
A = list(map(int, input().split()))
N1 = int(input())
A1 = list(map(int, input().split()))
for i in A:
	for j in A1:
		if j + i not in A and j + i not in A1:
			print(i, j)
			break
	else:
		continue
	break


input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			quit()


na = int(input())
a = list(map(int, input().split()))
a.sort()
nb = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
d = 0
for i in range(0, na):
	for j in range(0, nb):
		c = a[i] + b[j]
		if c not in a and c not in b:
			print(a[i], b[j])
			d = 1
			break
	if d == 1:
		break


import sys
import re
import random
import math
import os
l = 0
r = 0
la = int(input())
a = list(map(int, input().rstrip().split()))
lb = int(input())
b = list(map(int, input().rstrip().split()))
for i in range(len(a)):
	for j in range(len(b)):
		if not a[i] + b[j] in a and (not a[i] + b[j] in b):
			print('{} {}'.format(a[i], b[j]))
			exit(0)


import timeit

def splitElements(size, array):
	temp = array.split()
	result = list()
	for i in range(size):
		try:
			temp[i] = result.append(int(temp[i]))
		except IndexError:
			continue
	return result

def resultOutput(arrayA, arrayB):
	for i in arrayA:
		for j in arrayB:
			temp = i + j
			if not temp in arrayA and (not temp in arrayB):
				return str(i) + ' ' + str(j)
sizeA = int(input())
elementA = input()
A = splitElements(sizeA, elementA)
sizeB = int(input())
elementB = input()
B = splitElements(sizeB, elementB)
result = resultOutput(A, B)
print(result)


t = int(input())
y = list(map(int, input().split()))
u = int(input())
r = list(map(int, input().split()))
d = y + r
w = 0
for i in y:
	for j in r:
		c = i + j
		if c not in d:
			print(i, j)
			w += 1
			break
	if w == 1:
		break


n1 = int(input())
li = list(map(int, input().split()))
n2 = int(input())
li2 = list(map(int, input().split()))
for i in range(n1):
	for j in range(n2):
		l = li[i] + li2[j]
		if l not in li and l not in li2:
			(a, b) = (li[i], li2[j])
			break
print(a, b)


n = int(input())
a = [*map(int, input().split())]
m = int(input())
b = [*map(int, input().split())]
sa = set(a)
sb = set(b)
for i in a:
	for j in b:
		if i + j not in sa and i + j not in sb:
			print(i, j)
			exit()


n = int(input())
n_list = list(map(int, input().split()))
m = int(input())
m_list = list(map(int, input().split()))
flag = 0
for i in n_list:
	for j in m_list:
		if i + j not in n_list and i + j not in m_list:
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
print('{} {}'.format(max(a), max(b)))


n = int(input())
A = [int(x) for x in input().split()]
m = int(input())
B = [int(x) for x in input().split()]
A.sort()
B.sort()
print(str(A[-1]) + ' ' + str(B[-1]))


a = int(input())
a1 = list(map(int, input().split()))
b = int(input())
b1 = list(map(int, input().split()))
a1.sort()
b1.sort()
print(a1[-1], b1[-1])


I = input
n = int(I())
a = sorted(map(int, I().split()))
m = int(I())
b = sorted(map(int, I().split()))
print(a[n - 1], end=' ')
print(b[m - 1], end=' ')


n = int(input())
lista = [int(x) for x in input().split()]
m = int(input())
listb = [int(x) for x in input().split()]
flag = 1
for i in range(n):
	for j in range(m):
		k = lista[i] + listb[j]
		if k in lista or k in listb:
			flag = 0
			continue
		else:
			flag = 1
			print(lista[i], end=' ')
			print(listb[j])
			break
	if flag == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = 0
for i in range(n):
	x = a[i]
	for j in range(m):
		y = b[j]
		s = x + y
		if s not in a and s not in b:
			flag = 1
			break
	if flag == 1:
		break
print(x, y)


def convert(x):
	for i in x:
		x[x.index(i)] = int(i)
	return x
nA = int(input())
A = str(input()).split()
nB = int(input())
B = str(input()).split()
A = list(set(convert(A)))
B = list(set(convert(B)))
for a in A:
	for b in B:
		if not (a + b in A or a + b in B):
			break
	if not (a + b in A or a + b in B):
		break
print(a, b)


I = lambda : map(int, input().split())
n = int(input())
a = list(I())
m = int(input())
b = list(I())
d = {}
for i in a:
	d[i] = 1
for i in b:
	d[i] = 1
pp = 0
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in d:
			pp = 1
			print(a[i], b[j])
			exit(0)


m = int(input())
arr1 = [int(x) for x in input().split()]
n = int(input())
arr2 = [int(x) for x in input().split()]

def func(arr1, arr2):
	for x in arr1:
		if x in arr2:
			s = 2 * x
			if s not in arr1 and s not in arr2:
				return [x, x]
		for z in arr2:
			y = x + z
			if y not in arr1 and y not in arr2:
				return [x, z]
x = func(arr1, arr2)
for y in x:
	print(y, end=' ')


a = int(input())
ticla1 = list(map(int, input().split()))
b = int(input())
ticla2 = list(map(int, input().split()))
t = 1
for i in range(0, a):
	for g in range(0, b):
		ticlo = ticla1[i] + ticla2[g]
		if ticlo not in ticla1 and ticlo not in ticla2:
			print(ticla1[i], ticla2[g])
			t = 0
			break
	if t == 0:
		break


def limit_str(n):
	if n >= 1 and n <= 100:
		return True
	else:
		return False

def num_limit(a):
	if a >= 1 and a <= 200:
		return True
	else:
		return False

def sortFirst(val):
	return val[0]

def sortSecond(val):
	return val[1]
n = int(input())
a = input()
m = int(input())
b = input()
parse1 = a.split(' ')
parse2 = b.split(' ')
numlist1 = []
numlist2 = []
num1 = 0
num2 = 0
for i in range(0, n):
	num1 = int(parse1[i])
	numlist1.append(num1)
for j in range(0, m):
	num2 = int(parse2[j])
	numlist2.append(num2)
if n % 2 == 0:
	numlist1.sort()
else:
	numlist1.reverse()
if m % 2 == 0:
	numlist2.reverse()
else:
	numlist2.sort()
numlist3 = []
for a in range(0, n):
	for b in range(0, m):
		if numlist1[a] + numlist2[b] not in numlist1 and numlist1[a] + numlist2[b] not in numlist2:
			numlist3.append((numlist1[a], numlist2[b]))
numlist3.sort(key=sortSecond)
print(numlist3[0][0], ' ', numlist3[0][1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a1 = max(a)
a2 = min(a)
b1 = max(b)
b2 = min(b)
maxi = a1 + b1
mini = a2 + b2
if maxi not in a and maxi not in b:
	print(a1, b1)
else:
	print(a2, b2)


n = int(input())
lsta = list(map(int, input().split()))
m = int(input())
lstb = list(map(int, input().split()))
c = 0
for i in range(n):
	for j in range(m):
		if lsta[i] + lstb[j] not in lsta and lsta[i] + lstb[j] not in lstb:
			print(str(lsta[i]) + ' ' + str(lstb[j]))
			c += 1
			break
	if c == 1:
		break


n = int(input())
li = list(map(int, input().split()))
k = int(input())
test = list(map(int, input().split()))
print(max(li), max(test))


ar = []
ar2 = []
size1 = int(input())
for t in input().split(' '):
	ar.append(int(t))
size2 = int(input())
for t in input().split(' '):
	ar2.append(int(t))
check = 0
for x in ar:
	if check == 2:
		break
	for y in ar2:
		temp = x + y
		if temp in ar:
			continue
		if temp in ar2:
			continue
		print(x, y)
		check = 2
		break


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	n = inp()
	l = set(map(int, input().split()))
	m = inp()
	k = set(map(int, input().split()))
	(a, b) = (list(l), list(k))
	c = 0
	for i in a:
		for j in b:
			if i + j not in l and i + j not in k:
				print(i, j)
				c = 1
				break
		if c:
			break
	if c == 0:
		for i in b:
			for j in a:
				if i + j not in k and i + j not in l:
					print(j, i)
					break
for _ in range(1):
	solve()


from itertools import permutations
arr1_size = int(input())
arr1 = list(set(map(int, input().split())))
arr2_size = int(input())
arr2 = list(set(map(int, input().split())))
for i in arr1:
	pairs = list(permutations([i] + arr2, 2))
	for i in pairs:
		if i[0] + i[1] not in arr1 and i[0] + i[1] not in arr2:
			print(i[0], i[1])
			exit()


n = int(input())
a = tuple([int(x) for x in input().split()])
m = int(input())
b = tuple([int(x) for x in input().split()])
i = max(a)
j = max(b)
print(f'{i} {j}', end='')


n = int(input())
a = input().split()
a = [int(i) for i in a]
m = int(input())
b = input().split()
b = [int(i) for i in b]
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			store = str(i) + ' ' + str(j)
print(store)


n = int(input())
a = input().split()
m = int(input())
b = input().split()
for i in range(0, n):
	a[i] = int(a[i])
for i in range(0, m):
	b[i] = int(b[i])
a.sort()
b.sort()
print(a[n - 1], end=' ')
print(b[m - 1])


n = int(input())
a = list(map(int, input().split()[:n]))
n1 = int(input())
b = list(map(int, input().split()[:n1]))
s = 0
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			s = s + 1
			print(i, j)
			break
	if s == 1:
		break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
x = []
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			exit()


def nextInt():
	return int(input())

def nextInts():
	return map(int, input().split())
n = nextInt()
a = nextInts()
m = nextInt()
b = nextInts()
print(max(a), max(b))


n = int(input())
data1 = [int(i) for i in input().split()]
m = int(input())
data2 = [int(i) for i in input().split()]
print(max(data1), max(data2))


n = int(input())
list_1 = list(map(int, input().split()))
m = int(input())
list_2 = list(map(int, input().split()))
for i in list_1:
	for j in list_2:
		if i + j not in list_1:
			if i + j not in list_2:
				print(i, j)
				exit()


def toint(l):
	for i in range(len(l)):
		l[i] = int(l[i])
	return l
na = int(input())
a = input()
a = a.split()
a = toint(a)
nb = int(input())
b = input()
b = b.split()
b = toint(b)
ma = max(a)
mb = max(b)
print(ma, mb, sep=' ')


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
print(max(a), max(b))


n = int(input())
ns = input().split()
m = int(input())
ms = input().split()
for i in range(n):
	for x in range(m):
		if str(int(ms[x]) + int(ns[i])) in ns:
			pass
		elif str(int(ms[x]) + int(ns[i])) in ms:
			pass
		else:
			print(ns[i], ms[x])
			exit()


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))

def func(A, B):
	for i in range(len(A)):
		for j in range(len(B)):
			if not A[i] + B[j] in A and (not A[i] + B[j] in B):
				print(A[i], B[j])
				return
func(A, B)


import sys
input = sys.stdin.readline
from collections import defaultdict, deque
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
l = a + b
for x in a:
	for y in b:
		if x + y not in l:
			print(x, y)
			exit(0)


n1 = int(input())
nums1 = [int(s) for s in input().split()]
n2 = int(input())
nums2 = [int(s) for s in input().split()]
flag = False
for i in range(n1):
	for j in range(n2):
		if nums1[i] + nums2[j] not in nums1 and nums1[i] + nums2[j] not in nums2:
			print(nums1[i], nums2[j])
			flag = True
			break
	if flag == True:
		break


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
x = max(l1)
y = max(l2)
print(x, y)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().split(' ')))
	nn = int(input())
	b = list(map(int, sys.stdin.readline().split(' ')))
	print(max(a), max(b))
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def int1():
	return int(input())
import string
import math
from itertools import combinations

def main():
	n = int1()
	a = get_array()
	m = int1()
	b = get_array()
	k = 0
	for i in a:
		for j in b:
			if i + j not in a and i + j not in b:
				print(i, j)
				k = 1
				break
		if k == 1:
			break
main()


n = int(input())
a = [int(i) for i in input().split()]
n1 = int(input())
b = [int(i) for i in input().split()]
for i in range(n):
	for j in range(n1):
		c = a[i] + b[j]
		if c not in a and c not in b:
			s = a[i]
			s1 = b[j]
			break
print(s, s1)


n = int(input())
list1 = input().split()
m = input()
list2 = input().split()
arr1 = []
arr2 = []
for item in list1:
	arr1.append(int(item))
for item in list2:
	arr2.append(int(item))
for i in arr1:
	boolean = False
	for j in arr2:
		total = i + j
		if total not in arr1:
			if total not in arr2:
				boolean = True
				print(f'{i} {j}')
				break
	if boolean:
		break


lengthA = int(input())
a = input().split(' ')
a = [int(i) for i in a]
lengthB = int(input())
b = input().split(' ')
b = [int(i) for i in b]
a = sorted(a)
b = sorted(b)

def binary_search(a_list, item):
	f = 0
	last = len(a_list) - 1
	found = False
	while f <= last and (not found):
		mid = (f + last) // 2
		if a_list[mid] == item:
			found = True
		elif item < a_list[mid]:
			last = mid - 1
		else:
			f = mid + 1
	return found
for i in range(lengthA):
	found = False
	for k in b:
		j = a[i] + k
		if not binary_search(a, j) and (not binary_search(b, j)):
			print(a[i], k)
			found = True
			break
	if found:
		break


n1 = int(input())
l1 = [int(x) for x in input().split()]
n2 = int(input())
l2 = [int(x) for x in input().split()]
for i in range(0, n1):
	for j in range(0, n2):
		if l1[i] + l2[j] not in l1 and l1[i] + l2[j] not in l2:
			s = l1[i]
			s1 = l2[j]
print(s, s1)


first = int(input())
a = list(map(int, input().split()))
second = int(input())
b = list(map(int, input().split()))
for i in range(first):
	temp = 0
	for j in range(second):
		c = a[i] + b[j]
		flag = 0
		for k in range(first):
			if c == a[k]:
				flag = 1
				break
		for k in range(second):
			if c == b[k]:
				flag = 2
				break
		if flag == 0:
			print(a[i], b[j])
			temp = 1
			break
	if temp == 1:
		break


p = int(input())
a = set(map(int, input().split()))
p = int(input())
b = set(map(int, input().split()))
fl = False
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j)
			fl = True
			break
	if fl:
		break


a_1 = int(input())
a = [int(i) for i in input().split()]
b_1 = int(input())
b = [int(j) for j in input().split()]

def find_numb(a, b):
	for i in a:
		for j in b:
			if i + j not in a and i + j not in b:
				return (i, j)
for i in find_numb(a, b):
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
k = 0
t = 0
s = 0
for i in range(m):
	for j in range(n):
		if a[j] + b[i] in a:
			continue
		elif a[j] + b[i] in b:
			continue
		else:
			t = a[j]
			s = b[i]
			k += 1
print(t, s)


n = int(input())
x = [int(i) for i in input().split()]
maxx = -99999
for key in x:
	if key > maxx:
		maxx = key
m = int(input())
y = [int(i) for i in input().split()]
maxy = -99999
for key in y:
	if key > maxy:
		maxy = key
print(maxx, maxy)


import sys
from math import sqrt, floor, factorial
from collections import deque
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	n = int(inp())
	arr1 = max(read())
	m = int(inp())
	arr2 = max(read())
	print(arr1, arr2)
solve()


n = int(input())
a = list(map(int, input().rstrip().rsplit()))
m = int(input())
b = list(map(int, input().rstrip().rsplit()))
(ma, mb) = (max(a), max(b))
if ma == mb:
	print(ma, mb)
else:
	m = max(ma, mb)
	if m in a:
		print(m, b[0])
	else:
		print(a[0], m)


n1 = int(input())
A_string = input().split()
A = []
for i in A_string:
	A.append(int(i))
n2 = int(input())
B_string = input().split()
B = []
for i in B_string:
	B.append(int(i))
a = []
b = []
for ia in range(len(A)):
	for i in range(len(B)):
		sum = A[ia] + B[i]
		if sum in B or sum in A:
			continue
		else:
			a.append(A[ia])
			b.append(B[i])
			break
print(a[0], b[0])


import sys
a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
AB = list(A) + list(B)
for i in A:
	for j in B:
		if i + j in AB:
			pass
		else:
			print(i, j)
			sys.exit()


from sys import setcheckinterval, stdin
setcheckinterval(1000)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
n = iin()
a = lin()
n = iin()
b = lin()
sa = set(a)
sb = set(b)
for i in a:
	for j in b:
		if i + j not in sa and i + j not in sb:
			print(i, j)
			exit()


a = int(input())
list_a = list(map(int, input().split(' ')))
b = int(input())
list_b = list(map(int, input().split(' ')))
for i in range(len(list_a) - 1):
	if list_a[i + 1] < list_a[i]:
		c = list_a[i + 1]
		list_a[i + 1] = list_a[i]
		list_a[i] = c
for i in range(len(list_b) - 1):
	if list_b[i + 1] < list_b[i]:
		d = list_b[i + 1]
		list_b[i + 1] = list_b[i]
		list_b[i] = d
print(list_a[a - 1], list_b[b - 1])


lenA = int(input())
A = [int(x) for x in input().split()]
lenB = int(input())
B = [int(x) for x in input().split()]
print(max(A), max(B))


def two_numbers(A, B):
	AB = A + B
	for a in A:
		for b in B:
			if a + b not in AB:
				print(f'{a} {b}')
				return
a_len = input()
A = list(map(int, input().split(' ')))
b_len = input()
B = list(map(int, input().split(' ')))
two_numbers(A, B)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n1 = ii()
l1 = il()
n2 = ii()
l2 = il()
for i in l1:
	for j in l2:
		if not i + j in l1 and (not i + j in l2):
			print(i, j)
			exit(0)


a = int(input())
a1 = list(map(int, input().split()))
b = int(input())
b1 = list(map(int, input().split()))
for i in range(a):
	for j in range(b):
		su = a1[i] + b1[j]
		if a1.count(su) == 0 and b1.count(su) == 0:
			print(a1[i], b1[j])
			exit()


input()
a = {*map(int, input().split())}
input()
b = {*map(int, input().split())}
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			exit(print(i, j))


n = int(input())
arr = list(map(int, input().split()))
n2 = int(input())
arr2 = list(map(int, input().split()))
arr.sort()
arr2.sort()
print(arr[-1], arr2[-1])


while True:
	try:
		s = input()
		t1 = list(map(int, input().split(' ')))
		s = input()
		t2 = list(map(int, input().split(' ')))
		for i in t1:
			b = True
			for j in t2:
				if i + j not in t1 and i + j not in t2:
					print(str(i) + ' ' + str(j))
					b = False
					break
			if not b:
				break
	except:
		break


iloA = int(input())
inpA = input().split()
iloB = int(input())
inpB = input().split()
tabA = []
tabB = []
for i in range(iloA):
	tabA.append(int(inpA[i]))
for i in range(iloB):
	tabB.append(int(inpB[i]))
tabA.sort(reverse=True)
tabB.sort(reverse=True)
print(tabA[0], tabB[0])


t = 1
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	k = int(input())
	l1 = list(map(int, input().split()))
	l.sort()
	l1.sort()
	print(l[-1], l1[-1])


k = int(input())
A = [*map(int, input().split())]
i = int(input())
B = [*map(int, input().split())]
print(max(A), max(B))


n = input()
max_n = max(map(int, input().split(' ')))
m = input()
max_m = max(map(int, input().split(' ')))
print(max_n, max_m)


n = int(input())
A = set(map(int, input().split()))
m = int(input())
B = set(map(int, input().split()))
x = 0
y = 0
for a in A:
	for b in B:
		if a + b not in A and a + b not in B:
			x = a
			y = b
print(x, y)


a = input()
b = input()
c = input()
d = input()
b = [int(e) for e in b.split()]
d = [int(e) for e in d.split()]
print('%s %s' % (max(b), max(d)))


na = int(input())
la = list(map(int, input().split()))
nb = int(input())
lb = list(map(int, input().split()))
la.sort()
lb.sort()
print(la[-1], lb[-1])


n = int(input())
arrA = list(map(int, input().split()))
m = int(input())
arrB = list(map(int, input().split()))
for i in range(len(arrA)):
	for j in range(len(arrB)):
		if arrA[i] + arrB[j] not in arrA and arrA[i] + arrB[j] not in arrB:
			print(arrA[i], arrB[j])
			break
	if arrA[i] + arrB[j] not in arrA and arrA[i] + arrB[j] not in arrB:
		break


input()
A = list(map(int, input().split(' ')))
input()
B = list(map(int, input().split(' ')))
C = 0
D = 0
for i in A:
	for j in B:
		if i + j not in B and i + j not in A:
			C = i
			D = j
print(C, D)


t = int(input())
l = [int(i) for i in input().split()]
g = int(input())
l1 = [int(i) for i in input().split()]
bool_ = False
for i in range(t):
	for j in range(g):
		if l[i] + l1[j] not in l and l[i] + l1[j] not in l1:
			bool_ = True
			print(l[i], l1[j])
			break
	if bool_ == True:
		break


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
maxA = max(a)
maxB = max(b)
print(maxA, maxB)


n = int(input())
a = [int(x) for x in input().split()]
n1 = int(input())
b = [int(x) for x in input().split()]
print(max(a), max(b))


n = int(input())
it = list(map(int, input().split()))
m = int(input())
its = list(map(int, input().split()))
st = False
for i in it:
	for j in its:
		if i + j not in it and i + j not in its:
			a = i
			b = j
			st = True
	if st:
		break
print(a, b)


na = int(input())
a = [int(i) for i in input().split()]
nb = int(input())
b = [int(i) for i in input().split()]
f = 0
for i in range(na):
	for j in range(nb):
		sum = a[i] + b[j]
		if sum not in a and sum not in b:
			f = 1
			t = (a[i], b[j])
			break
	if f == 1:
		break
print(*t)


a1 = int(input())
a = list(map(int, input().split()))
b1 = int(input())
b = list(map(int, input().split()))
k = max(a)
j = max(b)
print(k, j)


M = int(input())
numList1 = list(map(int, input().split()))
N = int(input())
numList2 = list(map(int, input().split()))
print(max(numList1), max(numList2))


sizeofA = int(input())
elementA = input()
sizeofB = int(input())
elementB = input()

def splits(size, element):
	arr = list()
	part = element.split()
	for i in range(size):
		part[i] = arr.append(int(part[i]))
	return arr
arrofA = splits(sizeofA, elementA)
arrofB = splits(sizeofB, elementB)

def count(arrA, arrB):
	for i in arrA:
		for j in arrB:
			result = i + j
			if not result in arrA and (not result in arrB):
				return str(i) + ' ' + str(j)
print(count(arrofA, arrofB))


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
input()
a = max(get_list())
input()
b = max(get_list())
print(a, b)


a = int(input())
a1 = list(map(int, input().split()))
b = int(input())
b1 = list(map(int, input().split()))
temp_list = []
for x in range(a):
	for y in range(b):
		if a1[x] + b1[y] not in a1 and (not a1[x] + b1[y] in b1):
			temp_list.append('Value Found')
			print(a1[x], b1[y])
			break
	if len(temp_list) == 0:
		continue
	else:
		break


input()
a_all = list(map(int, input().split()))
input()
b_all = list(map(int, input().split()))
a_data = []
b_data = []

def check():
	for a in a_all:
		for b in b_all:
			c = a + b
			if c not in a_all and c not in b_all:
				print(a, b)
				return
check()


(a, max1) = (input(), max(map(int, input().split())))
(b, max2) = (input(), max(map(int, input().split())))
print(max1, max2)


(a, b) = [list(map(int, input().split())) for i in range(4)][1::2]
print(max(a), max(b))


nA = int(input())
lA = list(map(int, input().split()))
nB = int(input())
lB = list(map(int, input().split()))
numsGA = []
numsGB = []
for i in lA:
	for j in lB:
		x = i + j
		if x not in lA and x not in lB:
			numsGA.append(i)
			numsGB.append(j)
print(numsGA[0], numsGB[0])


n = int(input())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
d = a + b
for i in a:
	if k > 1:
		for j in b:
			if not i + j in d:
				print(i, j)
				break
			elif i + j in d:
				continue
	elif k == 1:
		j = b[0]
		for i in a:
			if not i + j in d:
				print(i, j)
				break
			elif i + j in d:
				continue
	break


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
n = ii()
d = sorted(li())
m = ii()
t = sorted(li())
print(d[-1], t[-1])


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
flag = 0
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


t = int(input())
k = list(map(int, input().split()))
l = int(input())
m = list(map(int, input().split()))
print(max(k), max(m))


import math
flag = 0
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, end=' ')
			print(j)
			flag = 1
			break
	if flag == 1:
		break


input()
a = [int(x) for x in input().split()]
input()
b = [int(x) for x in input().split()]
r1 = 0
r2 = 0
stop = False
for i in a:
	if not stop:
		for j in b:
			if i + j not in a and i + j not in b:
				r1 = i
				r2 = j
				break
print(r1, r2)


print(*(max(map(int, input() and input().split())) for _ in '00'))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			print(i, j, sep=' ')
			sys.exit()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = 0
for i in a:
	for j in b:
		if i + j in a or i + j in b:
			continue
		else:
			print(i, j)
			flag = 1
			break
	if flag == 1:
		break


e = int(input())
x = [int(t) for t in input().split()]
c = int(input())
y = [int(l) for l in input().split()]
(m, n) = (sorted(x), sorted(y))
print(m[len(x) - 1], n[len(y) - 1])


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
m = int(input())
b = sorted(list(map(int, input().split())), reverse=True)
print(a[0], b[0])


A = []
rangeA = int(input())
num = input()
test = num.split(' ')
for j in test:
	A.append(j)
B = []
rangeB = int(input())
num = input()
test = num.split(' ')
for k in test:
	B.append(k)
list = []
list1 = []
list2 = []
for i in A:
	for j in B:
		a = int(i) + int(j)
		list.append(a)
		list1.append(int(i))
		list2.append(int(j))
for j in range(len(list)):
	for x in A:
		if int(list[j]) == int(x):
			list1[j] = None
			list2[j] = None
			list[j] = None
			break
	if list[j] is not None:
		for y in B:
			if int(list[j]) == int(y):
				list1[j] = None
				list2[j] = None
				list[j] = None
				break
index = 0
for k in list:
	if k is not None:
		index = list.index(k)
		break
print(list1[index], list2[index])


import sys
import math
import random
input = sys.stdin.readline
n = map(int, input().split())
a = list(map(int, input().split()))
m = map(int, input().split())
b = list(map(int, input().split()))
a.sort()
b.sort()
print(a[len(a) - 1], b[len(b) - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
s = set()
for i in range(n):
	s.add(a[i])
for i in range(m):
	s.add(b[i])
for i in range(len(a)):
	for j in range(len(b)):
		if a[i] + b[j] not in s:
			print(str(a[i]) + ' ' + str(b[j]))
			exit()


n = int(input())
max_a = -9999999
splits = input().split(' ')
for i in range(n):
	val = int(splits[i])
	if val > max_a:
		max_a = val
m = int(input())
max_b = -9999999
splits = input().split(' ')
for i in range(m):
	val = int(splits[i])
	if val > max_b:
		max_b = val
print(max_a, max_b)


input()
l1 = sorted(map(int, input().split()))
input()
l2 = sorted(map(int, input().split()))
print(l1[-1], l2[-1])


print('%d %d' % (lambda n, max_a, m, max_b: (max_a, max_b))(int(input()), max(map(int, input().split())), int(input()), max(map(int, input().split()))))


an = int(input())
a = list(map(int, input().split()))
bn = int(input())
b = list(map(int, input().split()))
for i in range(an):
	for j in range(bn):
		c = a[i] + b[j]
		if c in a or c in b:
			continue
		else:
			print(a[i], b[j])
			exit()


a = int(input())
lst1 = list(map(int, input().split()))
b = int(input())
lst2 = list(map(int, input().split()))
print(max(lst1), max(lst2))


nA = int(input())
A = [int(x) for x in input().split()]
nB = int(input())
B = [int(x) for x in input().split()]
for i in A:
	for j in B:
		s = i + j
		if s not in A and s not in B:
			print(i, j)
			quit()


a = int(input())
lst1 = sorted(list(map(int, input().split())))
b = int(input())
lst2 = sorted(list(map(int, input().split())))
print(lst1[-1], lst2[-1])


n1 = int(input())
num1 = input()
a = []
b = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(int(num[count:i]))
			count = i + 1
		elif i == len(num) - 1:
			arr.append(int(num[count:len(num)]))
	return arr
arr1 = get_the_data(0, num1, a)
n2 = int(input())
num2 = input()
arr2 = get_the_data(0, num2, b)
arr1.sort()
arr2.sort()
print(str(arr1[len(arr1) - 1]) + ' ' + str(arr2[len(arr2) - 1]))


import sys
n = int(input())
lis1 = set([int(x) for x in input().split()])
m = int(input())
lis2 = set([int(x) for x in input().split()])
for i in lis1:
	for j in lis2:
		a = i + j
		if a not in lis1 and a not in lis2:
			print(i, j)
			sys.exit()


n = int(input())
arr1 = [int(num) for num in input().split()]
m = int(input())
arr2 = [int(num) for num in input().split()]
for i in arr1:
	for j in arr2:
		if arr1.count(i + j) == 0 and arr2.count(i + j) == 0:
			print(i, j)
			break
	else:
		continue
	break


n = int(input())
r = lambda : map(int, input().split())
A = [*r()]
m = int(input())
B = [*r()]
for i in range(0, n):
	for j in range(0, m):
		temp = A[i] + B[j]
		if temp not in A and temp not in B:
			print(A[i], B[j])
			exit()


n = int(input())
mA = max(map(int, input().split()))
n = int(input())
mB = max(map(int, input().split()))
print(mA, mB)


A = []
B = []
n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
a = 0
b = 0
found = 0
for i in range(n):
	for j in range(m):
		if A[i] + B[j] not in A and A[i] + B[j] not in B:
			a = A[i]
			b = B[j]
			found = 1
			break
	if found == 1:
		break
print(a, b)


def fun(a, b):
	sum = 0
	a.sort()
	b.sort()
	sum += a[-1] + b[-1]
	print(a[-1], b[-1])
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
fun(a, b)


n = int(input())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
t = True
d = a + b
for i in a:
	for j in b:
		if not i + j in d:
			print(i, j)
			t = False
			break
		elif i + j in d:
			continue
	if not t:
		break


nomer = 0
n = input()
A = [int(n) for n in input().split()]
m = input()
B = [int(m) for m in input().split()]
while nomer < len(A):
	plusiki = nomer
	bigestnumber = nomer
	while plusiki < len(A):
		if A[plusiki] < A[bigestnumber]:
			bigestnumber = plusiki
		plusiki = plusiki + 1
	(A[nomer], A[bigestnumber]) = (A[bigestnumber], A[nomer])
	nomer = nomer + 1
nomer = 0
while nomer < len(B):
	plusiki = nomer
	bigestnumber = nomer
	while plusiki < len(B):
		if B[plusiki] < B[bigestnumber]:
			bigestnumber = plusiki
		plusiki = plusiki + 1
	(B[nomer], B[bigestnumber]) = (B[bigestnumber], B[nomer])
	nomer = nomer + 1
print(A[len(A) - 1], B[len(B) - 1])


t = int(input())
l1 = list(map(int, input().split()))
k = int(input())
l2 = list(map(int, input().split()))
print(max(l1), max(l2))


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
m1 = max(a)
m2 = max(b)
print(m1, m2)


n = int(input())
a = [int(i) for i in input().split(' ')]
m = int(input())
b = [int(i) for i in input().split(' ')]
set_a = set()
set_b = set()
for i in a:
	set_a.add(i)
answer = [0, 0]
for i in b:
	set_b.add(i)
for i in range(200)[::-1]:
	value = i + 1
	if value in set_a and answer[0] < value:
		answer[0] = value
	if value in set_b and answer[1] < value:
		answer[1] = value
for i in answer:
	print(i, end=' ')


n = int(input())
A = sorted(list(map(int, input().split())))
m = int(input())
B = sorted(list(map(int, input().split())))
flag = False
for i in A[::-1]:
	for j in B[::-1]:
		if not (i + j in A or i + j in B):
			print(i, j, sep=' ')
			flag = True
			break
	if flag:
		break


n = int(input())
ar = list(map(int, input().split()))
m = int(input())
ar1 = list(map(int, input().split()))
print(max(ar), max(ar1))


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
print(str(max(arr1)) + ' ' + str(max(arr2)))


input()
a = [int(s) for s in input().split()]
input()
b = [int(s) for s in input().split()]
print(max(a), max(b))


import sys
import math
from collections import defaultdict
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
x = max(a)
y = max(b)
print(x, y)


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
(ar1, ar2, flag) = (set(arr1), set(arr2), 0)
for (i, j) in enumerate(arr1):
	for k in arr2:
		if k + j not in ar2 and k + j not in ar1:
			print(j, k)
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	for (i, j) in enumerate(arr2):
		for k in arr1:
			if k + j not in ar1 and k + j not in ar2:
				print(k, j)
				flag = 1
				break
		if flag == 1:
			break


n = int(input())
arr = list(map(int, input().split()))
n1 = int(input())
brr = list(map(int, input().split()))
arr.sort()
brr.sort()
print(arr[-1], brr[-1])


n = int(input())
A = sorted([*map(int, input().split())])
m = int(input())
B = sorted([*map(int, input().split())])
print(A[-1], B[-1])


def choose():
	inp1 = input()
	inpa1 = map(int, input().split())
	inp2 = input()
	inpa2 = map(int, input().split())
	print(max(inpa1), max(inpa2))
choose()


n = int(input())
l1 = list(map(int, input().split()))
k = int(input())
l2 = list(map(int, input().split()))
l1.sort()
l2.sort()
print(l1[len(l1) - 1], l2[len(l2) - 1])


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))
inp()
a = invr()
inp()
b = invr()
for i in a:
	for j in b:
		n = i + j
		if not (n in a or n in b):
			print(i, j)
			sys.exit()


x = int(input())
a = list(map(int, input().split()))
y = int(input())
b = list(map(int, input().split()))
a.sort()
b.sort()
print(a[-1], b[-1])


input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
a.sort()
b.sort()
maxa = max(a)
maxb = max(b)
print(maxa, max(b))


size1 = int(input())
a1 = list(map(int, input().split()))
size2 = int(input())
a2 = list(map(int, input().split()))
val1 = max(a1)
val2 = max(a2)
print(val1, val2)


def inp():
	return map(int, input().split())

def inp_arr():
	return list(map(int, input().split()))
n1 = int(input())
a = inp_arr()
n2 = int(input())
b = inp_arr()
print(str(max(a)) + ' ' + str(max(b)))


n = int(input())
s = input()
l1 = s.split()
m = int(input())
s1 = input()
l2 = s1.split()
flag = 0
x = 0
for i in l1:
	for j in l2:
		x = int(i) + int(j)
		if str(x) not in l1 and str(x) not in l2:
			print(i)
			print(j)
			flag = 1
			break
	if flag is 1:
		break


n = int(input())
nl = list(map(int, input().split()))
d = {}
for i in range(len(nl)):
	d[nl[i]] = 1
m = int(input())
ml = list(map(int, input().split()))
for i in range(len(ml)):
	d[ml[i]] = 1
flag = 0
for i in range(n):
	for j in range(m):
		if nl[i] + ml[j] not in d:
			print(nl[i], ml[j])
			flag = 1
			break
	if flag == 1:
		break


def checkit(n, A, x):
	for i in range(n):
		if A[i] == x:
			return 0
	return 1
n = int(input())
A = list(map(int, input().split(' ')))
m = int(input())
B = list(map(int, input().split(' ')))
for i in range(n):
	done = 0
	for j in range(m):
		if checkit(n, A, A[i] + B[j]) == 1 and checkit(m, B, A[i] + B[j]) == 1:
			print('{} {}'.format(A[i], B[j]))
			done = 1
			break
	if done == 1:
		break


i = 0
k = 0
l = 0
s = 0
t = 0
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(0, n):
	p = a[i]
	for k in range(0, m):
		q = b[k]
		for s in range(0, n):
			if p + q == a[s]:
				x1 = None
				break
			else:
				for t in range(0, m):
					if p + q == b[t]:
						x1 = None
						break
					else:
						x1 = p
						x2 = q
		if x1 == p:
			break
	if x1 == p:
		break
print(x1, x2)


input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
w1 = 0
w2 = 0
for i in a:
	for j in b:
		w1 = i
		w2 = j
		w = w1 + w2
		if w not in a and w not in b:
			break
print(str(w1) + ' ' + str(w2), end='')


kk = input()
A = set(map(int, input().split()))
kk = input()
B = set(map(int, input().split()))
for a in A:
	for b in B:
		if a + b in A or a + b in B:
			continue
		else:
			print(a, b)
			exit()


import sys
n = int(input().strip())
l1 = [int(x) for x in input().strip().split()]
m = int(input().strip())
l2 = [int(x) for x in input().strip().split()]

def check():
	(set1, set2) = (set(), set())
	for i in l1:
		set1.add(i)
	for i in l2:
		set2.add(i)
	ans = list()
	for i in range(n):
		for j in range(m):
			val = l1[i] + l2[j]
			if val not in set1 and val not in set2:
				ans.append(l1[i])
				ans.append(l2[j])
				return ans
	return ans
ans = ' '.join((str(i) for i in check()))
print(ans)


input()
a = [int(x) for x in input().split()]
input()
b = [int(x) for x in input().split()]
for i in a:
	for j in b:
		if i + j not in a and i + j not in b:
			ans = str(i) + ' ' + str(j)
			break
print(ans)


n = int(input())
A = [int(x) for x in input().split()]
As = set(A)
m = int(input())
B = [int(x) for x in input().split()]
Bs = set(B)

def printnos(a, b):
	print(str(a) + ' ' + str(b))
	exit()
for a in A:
	for b in B:
		if a + b not in As and a + b not in Bs:
			printnos(a, b)


x = int(input())
sun = 0
mx = max(map(int, input().split()))
x = int(input())
mn = max(map(int, input().split()))
print(mx, mn)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
mxa = 0
mxb = 0
for i in a:
	mxa = max(mxa, i)
for i in b:
	mxb = max(mxb, i)
print(str(mxa) + ' ' + str(mxb))


import random
import time

def part(arr, start, end):
	i = start - 1
	pvt = arr[end]
	for j in range(start, end):
		if arr[j] < pvt:
			i += 1
			(arr[i], arr[j]) = (arr[j], arr[i])
	(arr[i + 1], arr[end]) = (arr[end], arr[i + 1])
	return i + 1

def quicksort(arr, start, end):
	if start < end:
		partitionindex = part(arr, start, end)
		quicksort(arr, start, partitionindex - 1)
		quicksort(arr, partitionindex + 1, end)

def interpolSearch(arr, item):
	found = False
	low = mid = 0
	high = len(arr) - 1
	while low <= high:
		mid = int(arr[low] / arr[high] * (high - low) + low)
		if arr[mid] == item:
			found = True
			break
		elif arr[mid] < item:
			low = mid + 1
		elif arr[mid] > item:
			high = mid - 1
	if found:
		return True
	else:
		return False

def findpair(arrA, arrB):
	sortA = quicksort(arrA, 0, len(arrA) - 1)
	sortB = quicksort(arrB, 0, len(arrB) - 1)
	sizeA = len(arrA)
	sizeB = len(arrB)
	while True:
		guessA = arrA[random.randint(0, sizeA - 1)]
		guessB = arrB[random.randint(0, sizeB - 1)]
		guess = guessA + guessB
		if interpolSearch(arrA, guess) or interpolSearch(arrB, guess):
			continue
		else:
			print(str(guessA) + ' ' + str(guessB))
			break

def main():
	arr1 = []
	arr2 = []
	size1 = int(input())
	arr1s = input()
	size2 = int(input())
	arr2s = input()
	arr1s = arr1s.split(' ', size1)
	arr2s = arr2s.split(' ', size2)
	for i in range(0, size1):
		arr1.append(int(arr1s[i]))
	for i in range(0, size2):
		arr2.append(int(arr2s[i]))
	findpair(arr1, arr2)
main()


def bi(a, x):
	(m, i, j) = (0, 0, len(a) - 1)
	while i <= j:
		m = (i + j) // 2
		if x == a[m]:
			return True
		elif x > a[m]:
			i = m + 1
		elif x < a[m]:
			j = m - 1
	return False

def cal(a, b):
	a.sort()
	b.sort()
	f = 1
	for i in reversed(a):
		for j in reversed(b):
			x = i + j
			if bi(b, x) == False and bi(a, x) == False:
				print(i, j, sep=' ')
				f = 0
				break
		if f == 0:
			break
n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
cal(a, b)


n = int(input())
L = []
L = map(int, input().split())
m = int(input())
O = []
O = map(int, input().split())
f = max(L)
j = max(O)
print(f)
print(j)


from sys import stdin
input = stdin.readline
n = int(input())
a = sorted([int(i) for i in input().split()])
m = int(input())
b = sorted([int(i) for i in input().split()])
print(str(a[n - 1]) + ' ' + str(b[m - 1]))


a = input()
l1 = [int(x) for x in input().split()]
b = input()
l2 = [int(i) for i in input().split()]
print(max(l1), max(l2))


x = int(input())
l = list(map(int, input().split()))
y = int(input())
z = list(map(int, input().split()))
f = 0
for i in l:
	for j in z:
		if i + j not in l and i + j not in z:
			print(i, j)
			f = 1
			break
	if f:
		break


error = False
a = 1
a = int(input())
array1 = input().split()
for i in range(len(array1)):
	array1[i] = int(array1[i])
b = 1
b = int(input())
array2 = input().split()
for i in range(len(array2)):
	array2[i] = int(array2[i])
for c1 in range(a):
	if error == True:
		break
	for c2 in range(b):
		if error == True:
			break
		q = array1[c1] + array2[c2]
		error = True
		for j in range(a):
			if array1[j] == q:
				error = False
		for j in range(b):
			if array2[j] == q:
				error = False
		if error == True:
			print(array1[c1], array2[c2])
			break


input()
a = max(map(int, input().split()))
input()
b = max(map(int, input().split()))
print(str(a) + ' ' + str(b))


import collections
import math
n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
flag = 0
for i in range(0, n):
	for j in range(0, m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			print(a[i], b[j])
			flag = 1
			break
	if flag == 1:
		break


n = int(input())
l = list(map(int, input().strip().split()))
m = int(input())
o = list(map(int, input().strip().split()))
for i in range(n):
	for j in range(m):
		z = l[i] + o[j]
		if z not in l and z not in o:
			print(l[i], o[j])
			quit()
		else:
			continue


def ii():
	return int(input())

def lmii():
	return list(map(int, input().split()))
n = ii()
na = lmii()
m = ii()
ma = lmii()
na.sort()
ma.sort()
print(na[n - 1], ma[m - 1])


n = int(input())
l = [int(s) for s in input().split()]
m = int(input())
l1 = [int(s) for s in input().split()]
l.sort()
l1.sort()
print(l[-1], l1[-1])


n = input()
A = map(int, input().split(' '))
m = input()
B = map(int, input().split(' '))
print(str(max(A)) + ' ' + str(max(B)))


(n, a) = (input(), [int(i) for i in input().strip().split()])
(m, b) = (input(), [int(i) for i in input().strip().split()])
print(max(a), max(b))


n = int(input())
a = [int(i) for i in input().split()][:n]
m = int(input())
b = [int(i) for i in input().split()][:m]
l = [[i, j] for i in a for j in b if i + j not in a and i + j not in b]
print(l[0][0], l[0][1])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
b = [int(x) for x in input().split()]
flg = 0
for ai in a:
	if flg == 1:
		break
	for bj in b:
		m = ai + bj
		if m not in a:
			if m not in b:
				print(ai, bj)
				flg = 1
				break


n = int(input())
s1 = list(map(int, input().split()))
m = int(input())
s2 = list(map(int, input().split()))
d = max(s1)
k = max(s2)
print(d, k)


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
b = list(map(int, input().split(' ')))
l = []
m = []
for i in a:
	for j in b:
		s = i + j
		if s not in a and s not in b:
			l.append(i)
			l.append(j)
m.append(l[0])
m.append(l[1])
print(' '.join([str(e) for e in m]))


n = int(input())
a = [int(x) for x in input().strip().split()]
m = int(input())
b = [int(x) for x in input().strip().split()]
a.sort()
b.sort()
print(a[-1], b[-1])


NA = int(input())
S0 = sorted(list(map(int, input().split())))
NB = int(input())
S1 = sorted(list(map(int, input().split())))
print(S0[len(S0) - 1], S1[len(S1) - 1])


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
m = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().split()))
dct = defaultdict(int)
for ele in a:
	dct[ele] += 1
for ele in b:
	dct[ele] += 1

def get_ans(n, m):
	for i in range(n):
		for j in range(m):
			if not a[i] + b[j] in dct:
				return (a[i], b[j])
(x, y) = get_ans(n, m)
print(x, y)


n = int(input())
lis = list(map(int, input().split()))
m = int(input())
li = list(map(int, input().split()))
a = max(lis)
b = max(li)
print(a, b)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
u = 0
for i in range(n):
	for j in range(m):
		x = a[i] + b[j]
		if x not in a and x not in b:
			u = 1
		if u:
			r1 = a[i]
			r2 = b[j]
			break
	if u:
		break
print(r1, r2)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
su = 0
f = 0
for i in range(len(a)):
	for j in range(len(b)):
		su = a[i] + b[j]
		if su not in a and su not in b:
			if f == 0:
				print(a[i], b[j])
				f = 1
		else:
			su = 0


n = int(input())
A = [*map(int, input().split())]
m = int(input())
B = [*map(int, input().split())]
for i in A:
	for j in B:
		if i + j not in A and i + j not in B:
			print(i, j)
			exit()


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = int(input())
	l1 = list(map(int, input().split()))
	print(max(l[:]), max(l1[:]))


input()
arr1 = list(map(int, input().split()))
input()
arr2 = list(map(int, input().split()))
arr3 = []
for num1 in arr1:
	for num2 in arr2:
		target = num1 + num2
		if target not in arr1 and target not in arr2:
			arr3.extend([num1, num2])
			print(*arr3)
			break
	if len(arr3) > 0:
		break


n = int(input())
a = list(map(int, input().strip().split()))[:n]
m = int(input())
b = list(map(int, input().strip().split()))[:m]
j = b[m - 1]
for i in a:
	if j != b[m - 1]:
		break
	for j in b:
		if not (i + j in a or i + j in b):
			print(i, end=' ')
			print(j, end=' ')
			break


I = input
R = lambda : map(int, I().split())
I()
a = R()
I()
print(max(a), max(R()))


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = ri()
m = ri(1)
b = ri()
c1 = dd(int)
c2 = dd(int)
for i in a:
	c1[i] = 1
for i in b:
	c2[i] = 1
sol1 = -1
sol2 = -1
for i in a:
	for j in b:
		if i + j not in c1 and i + j not in c2:
			sol1 = i
			sol2 = j
			break
print(sol1, sol2)


firstArraySize = int(input())
firstArray = list(map(int, input().split()))
secondArraySize = int(input())
secondArray = list(map(int, input().split()))
print(str(max(firstArray)) + ' ' + str(max(secondArray)))


a_N = int(input())
a = sorted(list(map(int, input().split())))
b_N = int(input())
b = sorted(list(map(int, input().split())))
print(a[-1], b[-1])


n = int(input())
A = list([int(x) for x in input().split()])
m = int(input())
B = list([int(y) for y in input().split()])
i = 0
while i < n:
	j = 0
	while j < m:
		sum = A[i] + B[j]
		if sum not in A and sum not in B:
			print(A[i], B[j])
			exit()
		j += 1
	i += 1


n = int(input())
A = []
A = input().split(' ')
m = int(input())
B = input().split(' ')
for i in range(n):
	A[i] = int(A[i])
for i in range(m):
	B[i] = int(B[i])
check = 0
B.sort()
result = 0
for a in A:
	for b in B:
		result = a + b
		if result not in A:
			if result not in B:
				check = 1
				print(str(a) + ' ' + str(b))
				break
	if check == 1:
		break


n = int(input())
list1 = list(map(int, input().split()))
m = int(input())
list2 = list(map(int, input().split()))
print(max(list1), max(list2))


n = input()
a = list(map(int, input().split()))
n = input()
b = list(map(int, input().split()))
a.sort()
b.sort()
print(a[-1], b[-1])


n = int(input())
a = [int(i) for i in input().split(' ')]
m = int(input())
b = [int(j) for j in input().split(' ')]
a.sort()
b.sort()
l = []
for p in range(n):
	for d in range(m):
		r = a[p] + b[d]
		if r not in a:
			if r not in b:
				l.append(a[p])
				l.append(b[d])
				break
print(l[0], l[1])


def binarySearch(arr, l, r, x):
	if r >= l:
		mid = int(l + (r - l) / 2)
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return -1

def problem():
	_ = int(input())
	A = list(map(int, input().split()))
	_ = int(input())
	B = list(map(int, input().split()))
	sorted(A)
	sorted(B)
	for x in A:
		for y in B:
			z = x + y
			if z not in A:
				if z not in B:
					print(x, y)
					return
problem()


def mp():
	return map(int, input().split())
n = int(input())
a = list(mp())
m = int(input())
b = list(mp())
print(max(a), max(b))


n1 = int(input())
a = input().split()
a = [int(x) for x in a]
n2 = int(input())
b = input().split()
b = [int(x) for x in b]
ans = []
for j in a:
	for k in b:
		if j + k not in a and j + k not in b:
			ans.append([j, k])
print(ans[0][0], ans[0][1])


import math
from decimal import Decimal
import heapq

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def Factor(n):
	Ans = []
	d = 2
	while d * d <= n:
		if n % d == 0:
			Ans.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		Ans.append(n)
	return Ans
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		d = a[i] + b[j]
		if d not in a and d not in b:
			print(a[i], b[j])
			exit()


from sys import stdin, stdout
from collections import Counter
import math

def rsingle_int():
	return int(stdin.readline().rstrip())

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

def r_str():
	return stdin.readline().rstrip()

def rsingle_char():
	return stdin.read(1)

def main():
	n = rsingle_int()
	a = rmult_int()
	m = rsingle_int()
	b = rmult_int()
	max_a = 0
	for el in a:
		if el > max_a:
			max_a = el
	max_b = 0
	for el in b:
		if el > max_b:
			max_b = el
	print(*[max_a, max_b])
main()


def numSum(A, B):
	return list(([a, b] for a in A for b in B if a + b not in A and a + b not in B))
m = int(input())
A = list(map(int, input().split()))
n = int(input())
B = list(map(int, input().split()))
print(numSum(A, B)[0][0], end=' ')
print(numSum(A, B)[0][1])


t1 = int(input())
lista1 = [int(x) for x in input().split()]
t2 = int(input())
lista2 = [int(y) for y in input().split()]
print(max(lista1), max(lista2))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n1 = get_int()
lst1 = sorted(get_int_list())
n2 = get_int()
lst2 = sorted(get_int_list())
print(lst1[-1], lst2[-1])


def num(a, b, l, m):
	for i in range(a):
		x = l[i]
		for j in range(b):
			y = m[j]
			if x + y not in l and x + y not in m:
				return (x, y)
a = int(input())
l = list(map(int, input().split()))
b = int(input())
m = list(map(int, input().split()))
(a, b) = num(a, b, l, m)
print(a, b)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
l = []
for i in range(n):
	for j in range(m):
		if a[i] + b[j] not in a and a[i] + b[j] not in b:
			l.append([a[i], b[j]])
print(l[0][0], l[0][1])


n1 = int(input())
l1 = list(map(int, input().split()))
l1.sort()
n2 = int(input())
l2 = list(map(int, input().split()))
l2.sort()
print(l1[-1], end=' ')
print(l2[-1])


n = int(input())
l1 = sorted(list(map(int, input().split())))
m = int(input())
l2 = sorted(list(map(int, input().split())))
z = 0
for i in l1:
	if z == 1:
		break
	for y in l2:
		if i + y not in l1 and i + y not in l2:
			print(i, y)
			z = 1
			break


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
ra = max(a)
rb = max(b)
print(ra, rb)


n = int(input())
l = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
l.sort()
l2.sort()
print(l[-1], l2[-1])


n = int(input())
lis = [int(i) for i in input().split()]
m = int(input())
lis1 = [int(i) for i in input().split()]
print(max(lis), max(lis1))


int(input())
x = max([int(q) for q in input().split()])
int(input())
y = max([int(q) for q in input().split()])
print(x, y)


(_, a) = (input(), list(map(int, input().split())))
(_, b) = (input(), list(map(int, input().split())))
for v in a:
	for v1 in b:
		s = v + v1
		if s not in a and s not in b:
			print(v, v1)
			quit()


a = int(input())
a_list = list(map(int, input().split()))
b = int(input())
b_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
print(a_list[0], b_list[0])


n1 = int(input())
a = [int(i) for i in input().split()]
n2 = int(input())
b = [int(i) for i in input().split()]
print(max(a), max(b))


N = int(input())
A = tuple(map(int, input().split()))
M = int(input())
B = tuple(map(int, input().split()))
print(max(A), max(B))


n = int(input())
N = list(map(int, input().split()))
m = int(input())
M = list(map(int, input().split()))
for i in N:
	for j in M:
		r = i + j
		if r not in N and r not in M:
			print(i, j)
			exit()


def naiveSolve(n):
	return

def main():
	input()
	a = max(readIntArr())
	input()
	b = max(readIntArr())
	print('{} {}'.format(a, b))
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


n = int(input())
a = list(map(int, input().split()))
aset = set(a)
m = int(input())
b = list(map(int, input().split()))
bset = set(b)
for i in range(n):
	for j in range(m):
		s = a[i] + b[j]
		if s not in aset and s not in bset:
			ans = (a[i], b[j])
print(ans[0], ans[1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
hasha = dict()
hashb = dict()
for i in a:
	hasha[i] = 1
for i in b:
	hashb[i] = 1
i = 0
ans = []
while i < len(a) and len(ans) == 0:
	j = 0
	while j < len(b):
		if a[i] + b[j] not in hasha and a[i] + b[j] not in hashb:
			ans = [a[i], b[j]]
			break
		j += 1
	i += 1
print(ans[0], ans[1])


n1 = int(input())
c1 = sorted(list(map(int, input().split())))
n2 = int(input())
c2 = sorted(list(map(int, input().split())))
print(c1[-1], c2[-1])


n = int(input())
a1 = list(map(int, input().split()))
m = int(input())
b1 = list(map(int, input().split()))
print(str(sorted(a1)[-1]) + ' ' + str(sorted(b1)[-1]))


n = int(input())
A = list(map(int, input().rstrip().split()))
m = int(input())
B = list(map(int, input().rstrip().split()))
C = []
C.extend(A)
C.extend(B)
ma = max(A)
mb = max(B)
if ma + mb not in C:
	print(ma, mb)


n = int(input())
l = []
l = list(map(int, input().split(' ')))
n = int(input())
l1 = []
l1 = list(map(int, input().split(' ')))
k = 0
for j in l:
	for t in l1:
		if j + t not in l and j + t not in l1:
			print(j, t)
			k = 1
		if k == 1:
			break
	if k == 1:
		break


x = input
a = x()
b = sorted(map(int, input().split()))
c = x()
d = sorted(map(int, input().split()))
s = 0
for i in b[::-1]:
	for j in d[::-1]:
		if i + j not in b and i + j not in d:
			print(i, j)
			s = 1
			break
	if s == 1:
		break


n = int(input())
l = list(map(int, input().split()))
m = int(input())
ml = list(map(int, input().split()))
print(max(l), max(ml))