N, M = list(map(int, input().split()))



B = [[1, 0] for i in range(N)]



B[0][1] = 1



for i in range(M):

    x, y = list(map(int, input().split()))

    if B[x - 1][1] == 1:

        B[y - 1][1] = 1

    B[x - 1][0] -= 1

    B[y - 1][0] += 1

    if B[x - 1][0] == 0:

        B[x - 1][1] = 0



cnt = 0

for i in range(N):

    if B[i][1] == 1:

        cnt += 1



print(cnt)

N, M = list(map(int, input().split()))



B = [1]*N

R=[0]*N



R[0]=1



for i in range(M):

    x, y = list(map(int, input().split()))

    x-=1

    y-=1

    if R[x] == 1:

        R[y] = 1

    B[x] -= 1

    B[y] += 1

    if B[x] == 0:

        R[x] = 0



print((sum(R)))

N, M = list(map(int, input().split()))
B = [[1, 0] for i in range(N)]
B[0][1] = 1
for i in range(M):
    x, y = list(map(int, input().split()))
    if B[x - 1][1] == 1:
        B[y - 1][1] = 1
    B[x - 1][0] -= 1
    B[y - 1][0] += 1
    if B[x - 1][0] == 0:
        B[x - 1][1] = 0
cnt = 0
for i in range(N):
    if B[i][1] == 1:
        cnt += 1
print(cnt)

N, M = list(map(int, input().split()))
B = [1] * N
R = [0] * N
R[0] = 1
for i in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    if R[x] == 1:
        R[y] = 1
    B[x] -= 1
    B[y] += 1
    if B[x] == 0:
        R[x] = 0
print((sum(R)))

-B = [[1, 0] for i in range(N)] -B[0][1] = 1 +B = [1] * N +R = [0] * N +R[0] = 1 -    if B[x - 1][1] == 1: -        B[y - 1][1] = 1 -    B[x - 1][0] -= 1 -    B[y - 1][0] += 1 -    if B[x - 1][0] == 0: -        B[x - 1][1] = 0 -cnt = 0 -for i in range(N): -    if B[i][1] == 1: -        cnt += 1 -print(cnt) +    x -= 1 +    y -= 1 +    if R[x] == 1: +        R[y] = 1 +    B[x] -= 1 +    B[y] += 1 +    if B[x] == 0: +        R[x] = 0 +print((sum(R)))