N = int(eval(input()))

src = [tuple(map(int,input().split())) for i in range(N)]

src.sort()



print((src[-1][0] + src[-1][1]))
N = int(eval(input()))

AB = [tuple(map(int,input().split())) for i in range(N)]

a,b = max(AB)

print((a+b))
N = int(eval(input()))
src = [tuple(map(int, input().split())) for i in range(N)]
src.sort()
print((src[-1][0] + src[-1][1]))

N = int(eval(input()))
AB = [tuple(map(int, input().split())) for i in range(N)]
a, b = max(AB)
print((a + b))

-src = [tuple(map(int, input().split())) for i in range(N)] -src.sort() -print((src[-1][0] + src[-1][1])) +AB = [tuple(map(int, input().split())) for i in range(N)] +a, b = max(AB) +print((a + b))