#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long W; const W INF = 1 << 25; struct edge { int to; W cost; }; typedef pair P; typedef vector > Graph; void dijkstra(int s, const Graph& G, vector& d) { priority_queue

que; fill(d.begin(), d.end(), -1); d[s] = INF; que.push(P(INF, s)); while(!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if(d[v] > p.first) continue; for(int i = 0; i < G[v].size(); i++) { edge e = G[v][i]; if(d[e.to] < min(d[v], e.cost)) { d[e.to] = min(d[v], e.cost); que.push(P(d[e.to], e.to)); } } } } const int MAX = 100010; int N, M, Q; int main() { cin.tie(0); ios::sync_with_stdio(false); map m; cin >> N >> M >> Q; for(int i = 0; i < M; i++) { int A, B; cin >> A >> B; m[P(A, B)] = INF; } for(int i = 1; i <= Q; i++) { int A, B; cin >> A >> B; m[P(A, B)] = i; } Graph G(N); for(auto val : m) { int A = val.first.first, B = val.first.second; int T = val.second; G[A - 1].push_back(edge{ B - 1, T }); G[B - 1].push_back(edge{ A - 1, T }); } vector d(N); dijkstra(0, G, d); for(int i = 1; i < N; i++) { if(d[i] == INF) { cout << -1 << endl; } else if(d[i] == -1) { cout << 0 << endl; } else { cout << d[i] << endl; } } }