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

R = [0 for _ in range(N+1)]

R[1] = 1

B = [1 for _ in range(N+1)]

B[0] = 0

for _ in range(M):

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

    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()))

A = [0 for _ in range(N+1)]

B = [1 for _ in range(N+1)]

A[1] = 1

B[0] = 0

for _ in range(M):

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

    if A[x]==1:

        A[y]=1

    B[y] += 1

    B[x] -= 1

    if B[x]==0:

        A[x] = 0

print((sum(A)))
N, M = list(map(int, input().split()))
R = [0 for _ in range(N + 1)]
R[1] = 1
B = [1 for _ in range(N + 1)]
B[0] = 0
for _ in range(M):
    x, y = list(map(int, input().split()))
    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()))
A = [0 for _ in range(N + 1)]
B = [1 for _ in range(N + 1)]
A[1] = 1
B[0] = 0
for _ in range(M):
    x, y = list(map(int, input().split()))
    if A[x] == 1:
        A[y] = 1
    B[y] += 1
    B[x] -= 1
    if B[x] == 0:
        A[x] = 0
print((sum(A)))

-R = [0 for _ in range(N + 1)] -R[1] = 1 +A = [0 for _ in range(N + 1)] +A[1] = 1 -    if R[x] == 1: -        R[y] = 1 +    if A[x] == 1: +        A[y] = 1 +    B[y] += 1 -    B[y] += 1 -        R[x] = 0 -print((sum(R))) +        A[x] = 0 +print((sum(A)))