#include using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) typedef long long ll; typedef long double ld; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; int n; using P = pair; struct edge { int to; int cost; }; vector dist; vector > g; void dijkstra(int s) { dist = vector(n, Inf); dist[s] = 0; priority_queue, greater

> pq; pq.push(P(0, s)); while (!pq.empty()) { P p = pq.top(); pq.pop(); int v = p.second; if (dist[v] < p.first) continue; rep (i, g[v].size()) { edge e = g[v][i]; if (dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; pq.push(P(dist[e.to], e.to)); } } } } int main() { cin.tie(nullptr); ios::sync_with_stdio(0); int m, q; cin >> n >> m; g = vector >(n, vector()); rep (i, m) { int s, t; cin >> s >> t; s--, t--; edge e; e.to = t; e.cost = 1; g[s].push_back(e); e.to = s; g[t].push_back(e); } cin >> q; rep (x, q) { int a; cin >> a; a--; dijkstra(a); int cnt = 0; int day = 0; rep (i, n) { if (i == a) continue; if (dist[i] == Inf) continue; cnt++; int tmp = 0; dist[i]--; while (dist[i] > 0) { dist[i] /= 2; tmp++; } day = max(day, tmp); } cout << cnt << " " << day << endl; } return 0; }