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

red_possible = [1] + [0]*(N-1)

balls = [1] * N

for i in range(M):

    x,y = [int(x)-1 for x in input().split()]

    if red_possible[x]:

        red_possible[y] = 1

        if balls[x] == 1:

            red_possible[x] = 0

    balls[x] -= 1

    balls[y] += 1

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

src = [tuple(map(int,input().split())) for i in range(M)]

red = [0] * N

red[0] = 1

ballnum = [1] * N



for a,b in src:

    a,b = a-1,b-1

    ballnum[b] += 1

    ballnum[a] -= 1

    if red[a]:

        red[b] = 1

        if not ballnum[a]:

            red[a] = 0

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

N, M = list(map(int, input().split()))
src = [tuple(map(int, input().split())) for i in range(M)]
red = [0] * N
red[0] = 1
ballnum = [1] * N
for a, b in src:
    a, b = a - 1, b - 1
    ballnum[b] += 1
    ballnum[a] -= 1
    if red[a]:
        red[b] = 1
        if not ballnum[a]:
            red[a] = 0
print((sum(red)))

-red_possible = [1] + [0] * (N - 1) -balls = [1] * N -for i in range(M): -    x, y = [int(x) - 1 for x in input().split()] -    if red_possible[x]: -        red_possible[y] = 1 -        if balls[x] == 1: -            red_possible[x] = 0 -    balls[x] -= 1 -    balls[y] += 1 -print((sum(red_possible))) +src = [tuple(map(int, input().split())) for i in range(M)] +red = [0] * N +red[0] = 1 +ballnum = [1] * N +for a, b in src: +    a, b = a - 1, b - 1 +    ballnum[b] += 1 +    ballnum[a] -= 1 +    if red[a]: +        red[b] = 1 +        if not ballnum[a]: +            red[a] = 0 +print((sum(red)))