#include using namespace std; pair solve(int s, int N, const vector> & edges){ vector dist(N, -1); int f = 0; int d = 0; dist[s] = d; vector pool = {s}; vector next_pool; while (pool.size()){ next_pool.clear(); ++d; for (auto p: pool){ for (auto q: edges[p]){ if (dist[q] == -1){ dist[q] = d; next_pool.push_back(q); ++f; } } } swap(pool, next_pool); } d = *max_element(dist.begin(), dist.end()); int days = 0; int tmp = 1; while (d > tmp){ ++days; tmp *= 2; } return make_pair(f, days); } int main() { ios::sync_with_stdio(false); cout.tie(0); int N, M; cin >> N >> M; vector> edges(N); while (M--){ int p, q; cin >> p >> q; edges[p - 1].push_back(q - 1); edges[q - 1].push_back(p - 1); } int Q; cin >> Q; while (Q--){ int A; cin >> A; auto ans = solve(A - 1, N, edges); cout << ans.first << ' ' << ans.second << "\n"; } return 0; }