N = int(input())
count = 0
for i in range(N):
a = int(input())
if a % 4 == 0 and a % 7 != 0:
count+=1
print(count)
N = int(input())
count = 0
for i in range(N):
a = int(input())
if a % 4 == 0 and a % 7 != 0:
count+=1
print(count)