class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n self.group = n self.ans = [0] * n self.child = [[i] for i in range(n)] def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y, i): x = self.find(x) y = self.find(y) if x == y: return self.group -= 1 if self.parents[x] > self.parents[y]: x, y = y, x p = self.find(0) if x == p: for j in self.child[y]: self.ans[j] = i elif y == p: for j in self.child[x]: self.ans[j] = i self.parents[x] += self.parents[y] self.parents[y] = x for c in self.child[y]: self.child[x].append(c) def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return self.group def all_group_members(self): dic = {r:[] for r in self.roots()} for i in range(self.n): dic[self.find(i)].append(i) return dic def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) n, m, q = map(int, input().split()) edges = set(tuple(map(int, input().split())) for _ in range(m)) cd = [] for _ in range(q): c, d = map(int, input().split()) cd.append((c, d)) edges.remove((c, d)) UF = UnionFind(n) for a, b in edges: UF.union(a - 1, b - 1, -1) for i in range(q - 1, -1, -1): c, d = cd[i] UF.union(c - 1, d - 1, i + 1) print(*UF.ans[1:], sep="\n")