from collections import deque int1 = lambda x: int(x) - 1 N, M, Q = map(int, input().split()) edges = [tuple(map(int1, input().split())) for _ in range(M)] edges_broken = [tuple(map(int1, input().split())) for _ in range(Q)] edges_broken.reverse() edges_broken_set = set(edges_broken) G = [[] for _ in range(N)] for edge in edges: if edge not in edges_broken_set: a, b = edge G[a].append(b) G[b].append(a) visited = [0] * N def dfs(i, x0): d = deque([x0]) while d: v = d.pop() visited[v] = i for x in G[v]: if visited[x] == 0: d.append(x) dfs(-1, 0) i = Q for edge in edges_broken: a, b = edge G[a].append(b) G[b].append(a) if visited[a] == 0 and visited[b] != 0: dfs(i, a) elif visited[a] != 0 and visited[b] == 0: dfs(i, b) i -= 1 print(*visited[1:], sep='\n')