from collections import defaultdict N, M, Q = map(int, input().split()) bridge = defaultdict(int) for _ in range(M): a, b = map(int, input().split()) bridge[(a, b)] = Q + 1 for i in range(1, Q + 1): c, d = map(int, input().split()) bridge[(c, d)] = i data = [[i] for i in range(N)] ans = [0] * N def find(x): if isinstance(data[x], list): return x data[x] = find(data[x]) return data[x] def merge(x, y, time): x = find(x) y = find(y) if x == y: return if x > y: x, y = y, x if x == 0: while data[y]: i = data[y].pop() ans[i] = time data[x].append(i) data[y] = 0 return if len(data[x]) > len(data[y]): x, y = y, x while data[x]: data[y].append(data[x].pop()) data[x] = y query = [(n, a, b) for (a, b), n in bridge.items()] query.sort(reverse=True) for n, a, b in query: merge(a - 1, b - 1, n) for a in ans[1:]: if a > Q: print(-1) else: print(a)