n, m = list(map(int, input().split()))



X = [0]*n

C = [1]*n

X[0] = 1



for i in range(m):

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

    x, y = x-1, y-1

    if X[x] == 1:

        X[y] = 1

        if C[x] == 1:

            X[x] = 0

        C[x] -= 1

        C[y] += 1

    else:

        C[x] -= 1

        C[y] += 1



ans = sum(X)

print(ans)

n, m = list(map(int, input().split()))

X = [0]*n

X[0] = 1

C = [1]*n

for i in range(m):

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

    x, y = x-1, y-1

    if X[x] == 1:

        if C[x] == 1:

            X[x] = 0

            X[y] = 1

            C[x] -= 1

            C[y] += 1

        else:

            X[x] = 1

            X[y] = 1

            C[x] -= 1

            C[y] += 1

    else:

        C[x] -= 1

        C[y] += 1



print((sum(X)))

n, m = list(map(int, input().split()))
X = [0] * n
C = [1] * n
X[0] = 1
for i in range(m):
    x, y = list(map(int, input().split()))
    x, y = x - 1, y - 1
    if X[x] == 1:
        X[y] = 1
        if C[x] == 1:
            X[x] = 0
        C[x] -= 1
        C[y] += 1
    else:
        C[x] -= 1
        C[y] += 1
ans = sum(X)
print(ans)

n, m = list(map(int, input().split()))
X = [0] * n
X[0] = 1
C = [1] * n
for i in range(m):
    x, y = list(map(int, input().split()))
    x, y = x - 1, y - 1
    if X[x] == 1:
        if C[x] == 1:
            X[x] = 0
            X[y] = 1
            C[x] -= 1
            C[y] += 1
        else:
            X[x] = 1
            X[y] = 1
            C[x] -= 1
            C[y] += 1
    else:
        C[x] -= 1
        C[y] += 1
print((sum(X)))

+X[0] = 1 -X[0] = 1 -        X[y] = 1 -        C[x] -= 1 -        C[y] += 1 +            X[y] = 1 +            C[x] -= 1 +            C[y] += 1 +        else: +            X[x] = 1 +            X[y] = 1 +            C[x] -= 1 +            C[y] += 1 -ans = sum(X) -print(ans) +print((sum(X)))