N = int(eval(input()))

P = list([int(a) - 1 for a in input().split()])



ans = 0

for i in range(N):

    p = P[i]

    if p == i:

        if i < N - 1:

            P[i], P[i + 1] = P[i + 1], P[i]

        ans += 1



print(ans)
N = int(eval(input()))

P = list(map(int, input().split()))



ans = 0



for i in range(N):

    if P[i] == i + 1:

        if i + 1 < N:

            P[i], P[i + 1] = P[i + 1], P[i]

        ans += 1

print(ans)

N = int(eval(input()))
P = list([int(a) - 1 for a in input().split()])
ans = 0
for i in range(N):
    p = P[i]
    if p == i:
        if i < N - 1:
            P[i], P[i + 1] = P[i + 1], P[i]
        ans += 1
print(ans)

N = int(eval(input()))
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if P[i] == i + 1:
        if i + 1 < N:
            P[i], P[i + 1] = P[i + 1], P[i]
        ans += 1
print(ans)

-P = list([int(a) - 1 for a in input().split()]) +P = list(map(int, input().split())) -    p = P[i] -    if p == i: -        if i < N - 1: +    if P[i] == i + 1: +        if i + 1 < N: