#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines class UnionFind: def __init__(self, N): self.root = list(range(N)) self.size = [1] * (N) self.component = [[i] for i in range(N)] def find_root(self, x): root = self.root while root[x] != x: root[x] = root[root[x]] x = root[x] return x def merge(self, x, y): x = self.find_root(x) y = self.find_root(y) if x == y: return False sx, sy = self.size[x], self.size[y] if sx < sy: self.root[x] = y self.size[y] += sx self.component[y] += self.component[x] else: self.root[y] = x self.size[x] += sy self.component[x] += self.component[y] return True N, M, Q = map(int, readline().split()) m = map(int, read().split()) ABCD = tuple(zip(m, m)) AB = ABCD[:M] CD = ABCD[M:] init_edge = set(AB) - set(CD) uf = UnionFind(N + 1) find = uf.find_root answer = [0] * (N + 1) def merge(t, u, v): u = find(u) v = find(v) r = find(1) if u == v: return if r == v: u, v = v, u if r == u: for i in uf.component[v]: answer[i] = t uf.merge(u, v) for a, b in init_edge: merge(-1, a, b) for i, (a, b) in enumerate(CD[::-1]): merge(Q - i, a, b) print('\n'.join(map(str, answer[2:])))