import sys input = sys.stdin.readline class UnionFindWithGroup(): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] self.group = [{i} for i in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] for s in self.group[y]: self.group[x].add(s) def is_same(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): x = self.find(x) return self.size[x] def get_group(self, x): x = self.find(x) return self.group[x] N, M, Q = map(int, input().split()) A, B, C, D = [0] * M, [0] * M, [0] * Q, [0] * Q for i in range(M): A[i], B[i] = map(int, input().split()) A[i], B[i] = A[i] - 1, B[i] - 1 S = set() for i in range(Q): C[i], D[i] = map(int, input().split()) C[i], D[i] = C[i] - 1, D[i] - 1 S.add((C[i], D[i])) U = UnionFindWithGroup(N) for a, b in zip(A, B): if (a, b) in S: continue U.union(a, b) ans = [-1] * N for i in range(Q - 1, -1, -1): f1 = int(U.is_same(C[i], 0)) f2 = int(U.is_same(D[i], 0)) if f1 ^ f2 == 1: if f1: for s in U.get_group(D[i]): ans[s] = i + 1 else: for s in U.get_group(C[i]): ans[s] = i + 1 U.union(C[i], D[i]) for i in range(1, N): if U.is_same(0, i): print(ans[i]) else: print(0)