n, m, q = map(int, input().split()) es = [tuple(map(int, input().split())) for _ in range(m)] qs = [tuple(map(int, input().split())) for _ in range(q)] vs = [[i] for i in range(n+1)] def find(i): if vs[i][0] == i: return i j = find(vs[i][0]) vs[i] = vs[j] return j def union(i, j): if vs[i] is vs[j]: return if len(vs[i]) < len(vs[j]): i, j = j, i vs[i] += vs[j] vs[j] = vs[i] s = set(qs) for i, j in es: if (i,j) not in s: union(find(i), find(j)) res = [-1]*(n+1) for i, j in qs[::-1]: q -= 1 i = find(i) j = find(j) if i == j: continue k = find(1) if j == k: i, j = j, i if i == k: for v in vs[j]: res[v] = q + 1 union(i, j) for i in range(2, n+1): print(res[i] * (find(i) is find(1)))