import sys def dfs(b,h,E,ans,reachable,turn): if reachable[h]: return reachable[h] = 1 ans[h] = turn for nxt in E[h]: if b == nxt: continue dfs(h,nxt,E,ans,reachable,turn) def solve(): ofs = 10**6 sys.setrecursionlimit(ofs) N,M,Q = map(int,raw_input().split()) reachable = [False]*N EL = [[] for i in xrange(N)] ans = [0]*N Break = set() Edges = map(lambda x: map(lambda x:int(x)-1,x.split()),sys.stdin.readlines()) for i in xrange(Q): Break.add(Edges[M+i][0]+Edges[M+i][1]*ofs) Break.add(Edges[M+i][0]*ofs+Edges[M+i][1]) for i in xrange(M): f,t = Edges[i] if (f+t*ofs) in Break: continue EL[f].append(t) EL[t].append(f) dfs(-1,0,EL,ans,reachable,-1) for i in xrange(Q,0,-1): f,t = Edges[M+i-1] EL[f].append(t) EL[t].append(f) if reachable[f]: dfs(f,t,EL,ans,reachable,i) elif reachable[t]: dfs(t,f,EL,ans,reachable,i) for i in xrange(1,N): print ans[i] solve()