#include using namespace std; signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n, m; cin >> n >> m; vector x(m), y(m); for(int i = 0; i < m; ++i){ cin >> x[i] >> y[i]; --x[i], --y[i]; } int q; cin >> q; vector a(q); for(int i = 0; i < q; ++i){ cin >> a[i]; --a[i]; } vector> edges(n); for(int i = 0; i < m; ++i){ edges[x[i]].push_back(y[i]); edges[y[i]].push_back(x[i]); } for(int i = 0; i < q; ++i){ int id = a[i]; vector dist(n, 1e9); queue que; dist[id] = 0; que.push(id); while(!que.empty()){ int from = que.front(); que.pop(); for(auto to : edges[from]){ if(dist[to] > dist[from] + 1){ dist[to] = dist[from] + 1; que.push(to); } } } int cnt = 0, time = 0; for(int i = 0; i < n; ++i) if(i != id && dist[i] != 1e9){ ++cnt; time = max(time, dist[i] - 1); } cout << cnt << " " << time << endl; } }