I=lambda:map(int,input().split());N,M,K=I();G=[0]*N for _ in'.'*M:x,y=I();x-=1;y-=1;G[x]|=1<(G[x]&G[y]&~(1<