import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, m, q=map(int, readline().split()) abcd=list(map(int ,read().split())) a=abcd[:2*m:2] b=abcd[1:2*m:2] c=abcd[2*m::2] d=abcd[2*m+1::2] par=list(range(n)) v=[[i] for i in range(n)] ans=[0]*n def merge(x, y): if len(v[x])>len(v[y]): x, y=y, x while v[x]: z=v[x].pop() par[z]=y v[y].append(z) cd=set(zip(c, d)) for x, y in zip(a, b): if (x, y) not in cd: x1, y1=par[x-1], par[y-1] if x1==y1: continue if x1==par[0]: for z in v[y1]: ans[z]=-1 elif y1==par[0]: for z in v[x1]: ans[z]=-1 merge(x1, y1) for i in range(q-1, -1, -1): x, y=c[i]-1, d[i]-1 x1, y1=par[x], par[y] if x1==y1: continue if x1==par[0]: for z in v[y1]: ans[z]=i+1 elif y1==par[0]: for z in v[x1]: ans[z]=i+1 merge(x1, y1) print('\n'.join(map(str, ans[1:])))