<reponame>isac322/BOJ<filename>2408/2408.py2.py<gh_stars>10-100
t = ""
for _ in range(2 * input() - 1):
	t += raw_input()
print eval(t)

t = ""
for _ in range(2 * input() - 1):
	t += raw_input()
print eval(t)