#include #include #include #include #include #include #include #include #include #include #include #define mk make_pair #define pb push_back #define printf printf_s #define scanf scanf_s using namespace std; typedef long long int ll; typedef pair pos; const ll MOD = 1000000007, N = 100001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838; ll mn(ll a, ll b) { if (a == -1)return b; if (b == -1)return a; return min(a, b); } ll gcd(ll v1, ll v2) { if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2); } ll pw(ll v1, ll v2) { ll v3 = 1; while (v2 > 0) { if (v2 % 2)v3 = (v3*v1) % MOD; v1 = (v1*v1) % MOD; v2 /= 2; } return v3; } struct ab { ll a, b; bool operator<(const ab& right) const { return right.b*a - right.a*b < 0; } }; ll n,m,Q,ind[N],ans[N]; vector g[N]; pos cd[N * 2],ab[N*2]; map st; void src(ll ind, ll v1) { queue q; q.push(ind); ans[ind] = v1; while (!q.empty()) { ll v2 = q.front(); q.pop(); for (int i = 0; i < g[v2].size(); i++) { if (ans[g[v2][i]] ==-2) { ans[g[v2][i]] = v1; q.push(g[v2][i]); } } } } int main() { cin >> n >> m >> Q; for (int i = 0; i < m; i++) { cin >> ab[i].first >> ab[i].second; st[ab[i]] = true; } for (int i = 0; i < Q; i++) { cin >> cd[i].first >> cd[i].second; st[cd[i]] = false; } for (int i = 0; i < m; i++) { if (st[ab[i]]) { g[ab[i].first].pb(ab[i].second); g[ab[i].second].pb(ab[i].first); } } st.clear(); for (int i = 1; i <= n; i++)ans[i] = -2; src(1, -1); for (int i = Q - 1; i >= 0; i--) { ll v1=cd[i].first, v2=cd[i].second; if (ans[v2] != -2&&ans[v1] == -2) { src(v1, i + 1); } if (ans[v1] != -2&&ans[v2] == -2) { src(v2, i + 1); } g[v1].pb(v2); g[v2].pb(v1); } for (int i = 1; i <= n; i++) { if (ans[i] == -2)ans[i] = 0; } for (int i = 2; i <= n; i++)cout << ans[i] << endl; return 0; }