import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int q = sc.nextInt(); HashSet bridges = new HashSet<>(); for (int i = 0; i < m; i++) { bridges.add(new Bridge(sc.nextInt() - 1, sc.nextInt() - 1)); } Bridge[] brokens = new Bridge[q]; for (int i = 0; i < q; i++) { brokens[i] = new Bridge(sc.nextInt() - 1, sc.nextInt() - 1); bridges.remove(brokens[i]); } UnionFindTree uft = new UnionFindTree(n); for (Bridge x : bridges) { uft.unite(x); } int[] ans = new int[n]; for (int x : uft.getSet(0)) { ans[x] = -1; } for (int i = q - 1; i >= 0; i--) { HashSet tmp = null; if (uft.same(0, brokens[i].left) && !uft.same(0, brokens[i].right)) { tmp = uft.getSet(brokens[i].right); } else if (uft.same(0, brokens[i].right) && !uft.same(0, brokens[i].left)) { tmp = uft.getSet(brokens[i].left); } else { uft.unite(brokens[i]); continue; } for (int x : tmp) { ans[x] = i + 1; } uft.unite(brokens[i]); } StringBuilder sb = new StringBuilder(); for (int i = 1; i < n; i++) { sb.append(ans[i]).append("\n"); } System.out.print(sb); } static class UnionFindTree { int[] parents; ArrayList> group = new ArrayList<>(); public UnionFindTree(int size) { parents = new int[size]; for (int i = 0; i < size; i++) { parents[i] = i; group.add(new HashSet<>()); group.get(i).add(i); } } public int find(int x) { if (x == parents[x]) { return x; } else { return parents[x] = find(parents[x]); } } public boolean same(int x, int y) { return find(x) == find(y); } public boolean same(Bridge b) { return same(b.left, b.right); } public void unite(Bridge b) { unite(b.left, b.right); } public void unite(int x, int y) { int xx = find(x); int yy = find(y); if (xx == yy) { return; } if (group.get(xx).size() < group.get(yy).size()) { parents[xx] = yy; group.get(yy).addAll(group.get(xx)); } else { parents[yy] = xx; group.get(xx).addAll(group.get(yy)); } } public HashSet getSet(int x) { return group.get(find(x)); } } static class Bridge { int left; int right; public Bridge(int left, int right) { this.left = left; this.right = right; } public int hashCode() { return left; } public boolean equals(Object o) { Bridge b = (Bridge)o; return b.left == left && b.right == right; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }