import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 3); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); int q = Integer.parseInt(first[2]); HashSet bridges = new HashSet<>(); for (int i = 0; i < m; i++) { bridges.add(new Bridge(br.readLine())); } Bridge[] events = new Bridge[q]; for (int i = 0; i < q; i++) { events[i] = new Bridge(br.readLine()); bridges.remove(events[i]); } UnionFindTree uft = new UnionFindTree(n); for (Bridge b : bridges) { uft.unite(b); } int[] results = new int[n]; HashSet now = uft.prepare(); for (int x : now) { results[x] = -1; } for (int i = q - 1; i >= 0; i--) { HashSet next = uft.uniteNext(events[i]); for (int x : next) { results[x] = i + 1; } } StringBuilder sb = new StringBuilder(); for (int i = 1; i < n; i++) { sb.append(results[i]).append("\n"); } System.out.print(sb); } static class Bridge { int left; int right; public Bridge (String arg) { String[] arr = arg.split(" ", 2); left = Integer.parseInt(arr[0]) - 1; right = Integer.parseInt(arr[1]) - 1; } public int hashCode() { return left + right; } public boolean equals(Object o) { Bridge b = (Bridge)o; return b.left == left && b.right == right; } } static class UnionFindTree { int[] parents; HashMap> map = new HashMap<>(); HashSet nothing = new HashSet<>(); public UnionFindTree(int size) { parents = new int[size]; for (int i = 0; i < size; i++) { parents[i] = i; } } public int find(int x) { if (parents[x] == x) { return x; } else { return parents[x] = find(parents[x]); } } public void unite(int x, int y) { int xx = find(x); int yy = find(y); if (xx == yy) { return; } int small = Math.min(xx, yy); int large = Math.max(xx, yy); parents[large] = small; } public void unite(Bridge b) { unite(b.left, b.right); } public HashSet uniteNext(int x, int y) { int xx = find(x); int yy = find(y); if (xx == yy) { return nothing; } int small = Math.min(xx, yy); int large = Math.max(xx, yy); parents[large] = small; map.get(small).addAll(map.get(large)); if (small == 0) { return map.get(large); } else { return nothing; } } public HashSet uniteNext(Bridge b) { return uniteNext(b.left, b.right); } public HashSet prepare() { for (int i = 0; i < parents.length; i++) { int x = find(i); if (!map.containsKey(x)) { map.put(x, new HashSet()); } map.get(x).add(i); } return map.get(0); } } }