import math



ans = 0

N = int(eval(input()))

for i in range(N):

    a = int(eval(input()))

    if a != 2 and a%2 == 0:

        continue

    b = True

    for j in range(3, int(math.sqrt(a))+1, 2):

        if a%j == 0:

            b = False

    if b:

        ans += 1



print(ans)
ans = 0

N = int(eval(input()))

for i in range(N):

    a = int(eval(input()))

    if a == 2:

        ans += 1

    elif a%2 == 0:

        continue

    else:

        if pow(2, a-1, a) == 1:

            ans += 1



print(ans)
import math

ans = 0
N = int(eval(input()))
for i in range(N):
    a = int(eval(input()))
    if a != 2 and a % 2 == 0:
        continue
    b = True
    for j in range(3, int(math.sqrt(a)) + 1, 2):
        if a % j == 0:
            b = False
    if b:
        ans += 1
print(ans)

ans = 0
N = int(eval(input()))
for i in range(N):
    a = int(eval(input()))
    if a == 2:
        ans += 1
    elif a % 2 == 0:
        continue
    else:
        if pow(2, a - 1, a) == 1:
            ans += 1
print(ans)

-import math - -    if a != 2 and a % 2 == 0: +    if a == 2: +        ans += 1 +    elif a % 2 == 0: -    b = True -    for j in range(3, int(math.sqrt(a)) + 1, 2): -        if a % j == 0: -            b = False -    if b: -        ans += 1 +    else: +        if pow(2, a - 1, a) == 1: +            ans += 1