mas = [0]*14
s = 0
for i in range(14):
mas[i] = int(input())
for m in range(14):
if mas[m]>8:
print(mas[m])
s +=mas[m]
print(s)
mas = [0]*14
s = 0
for i in range(14):
mas[i] = int(input())
for m in range(14):
if mas[m]>8:
print(mas[m])
s +=mas[m]
print(s)