#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; pair solve(const vector >& edges, int a) { int n = edges.size(); vector isUsed(n, false); queue q; isUsed[a] = true; q.push(a); int len = -1; int cnt = 0; while(!q.empty()){ ++ len; int m = q.size(); while(--m >= 0){ int x = q.front(); q.pop(); for(int y : edges[x]){ if(!isUsed[y]){ isUsed[y] = true; q.push(y); ++ cnt; } } } } int day = 0; while(len > 1){ ++ day; len = (len + 1) / 2; } return make_pair(cnt, day); } int main() { int n, m; cin >> n >> m; vector > edges(n); for(int i=0; i> p >> q; -- p; -- q; edges[p].push_back(q); edges[q].push_back(p); } int q; cin >> q; while(--q >= 0){ int a; cin >> a; -- a; auto ans = solve(edges, a); cout << ans.first << ' ' << ans.second << endl; } return 0; }