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

x=[0]*n

x[0]=1

y=[1]*n

for i in range(m):

  a,b=list(map(int,input().split()))

  if x[a-1]==1:x[b-1]=1

  y[a-1]-=1

  y[b-1]+=1

  if y[a-1]==0:x[a-1]=0

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

ans=[False]*n

ans[0]=True

co=[1]*n

for i in range(m):

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

  ans[y-1]|=ans[x-1]

  co[x-1]-=1

  co[y-1]+=1

  if co[x-1]==0:ans[x-1]=False

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

n, m = list(map(int, input().split()))
ans = [False] * n
ans[0] = True
co = [1] * n
for i in range(m):
    x, y = list(map(int, input().split()))
    ans[y - 1] |= ans[x - 1]
    co[x - 1] -= 1
    co[y - 1] += 1
    if co[x - 1] == 0:
        ans[x - 1] = False
print((ans.count(True)))

-x = [0] * n -x[0] = 1 -y = [1] * n +ans = [False] * n +ans[0] = True +co = [1] * n -    a, b = list(map(int, input().split())) -    if x[a - 1] == 1: -        x[b - 1] = 1 -    y[a - 1] -= 1 -    y[b - 1] += 1 -    if y[a - 1] == 0: -        x[a - 1] = 0 -print((sum(x))) +    x, y = list(map(int, input().split())) +    ans[y - 1] |= ans[x - 1] +    co[x - 1] -= 1 +    co[y - 1] += 1 +    if co[x - 1] == 0: +        ans[x - 1] = False +print((ans.count(True)))