N,M,Q = map(int,input().split()) parent = list(range(N)) renketu = [{i} for i in range(N)] import sys sys.setrecursionlimit(10 ** 8) def find(i): if parent[i] == i: return i parent[i] = find(parent[i]) return parent[i] def isSame(i,j): return find(i) == find(j) def unite(i,j): I = find(i) J = find(j) if I == J:return False if len(renketu[I]) > len(renketu[J]): I,J = J,I parent[I] = J renketu[J] |= renketu[I] return True hasi = [] for _ in range(M): a,b = map(int,input().split()) a -= 1 b -= 1 hasi.append((a,b)) query = [] qs = set() for _ in range(Q): c,d = map(int,input().split()) c -= 1 d -= 1 query.append((c,d)) qs.add((c,d)) for a,b in hasi: if (a,b) not in qs: unite(a,b) ans = [0] * N for a in renketu[find(0)]: ans[a] = -1 for i in range(Q - 1,-1,-1): c,d = query[i] if isSame(c,d): continue if c in renketu[find(0)]: for x in renketu[find(d)]: ans[x] = i + 1 if d in renketu[find(0)]: for x in renketu[find(c)]: ans[x] = i + 1 unite(c,d) for i in range(1,N): print(ans[i])