<gh_stars>0
number = int(input())
sum_number = 0

while number > sum_number:
    num = int(input())
    sum_number += num

print(sum_number)
number = int(input())
sum_number = 0

while number > sum_number:
    num = int(input())
    sum_number += num

print(sum_number)