#include #include #include #include #include #include using namespace std; int main() { int N, M; cin >> N >> M; vector> G(N); for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); } int Q; cin >> Q; while (Q--) { int A; cin >> A; A--; vector d(N, -1); d[A] = 0; queue q; q.push(A); int c = 0; int m = 0; while (!q.empty()) { int u = q.front(); q.pop(); c++; m = max(m, d[u] / 2); for (int v : G[u]) if (d[v] == -1) { d[v] = d[u] + 1; q.push(v); } } cout << c-1 << ' ' << m << '\n'; } }