#include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; typedef pair P; vector edges[100005]; int main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int p, q; cin >> p >> q; p--; q--; edges[p].push_back(q); edges[q].push_back(p); } int Q; cin >> Q; for (int x = 0; x < Q; x++) { int a; cin >> a; a--; priority_queue , greater

> q; q.push(P(0, a)); vector visited(n, false); visited[a] = true; vector cost(n, 1e9); cost[a] = 0; int ans_count = 0; int ans_depth = 0; while (q.size()) { P cur = q.top(); q.pop(); int now = cur.second; int c = cur.first; if (cost[now] < c) continue; for (int node : edges[now]) { if (!visited[node]) ans_count++; visited[node] = true; if (cost[node] > c + 1) { cost[node] = c + 1; ans_depth = max(ans_depth, c + 1); q.push(P(c+1, node)); } } } if (ans_depth == 1) { ans_depth = 0; } else { ans_depth = ans_depth % 2 == 0 ? ans_depth / 2 : ans_depth / 2 + 1; } cout << ans_count << " " << ans_depth << "\n"; } return 0; }