/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.14 02:54:23 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n,m;cin >> n >> m; vector> g(n); for (int i = 0; i < m; i++) { int p,q;cin >> p >> q; p--;q--; g[p].push_back(q); g[q].push_back(p); } int q;cin >> q; for (int i = 0; i < q; i++) { int a; cin >> a; a--; vector dist(n,-1); queue que; que.push(a); dist[a] = 0; int ans = 0; int cnt = 0; while(!que.empty()) { auto q = que.front(); que.pop(); for(int v : g[q]) { if (dist[v] != -1) continue; dist[v] = dist[q] + 1; cnt++; ans = max(ans,dist[v]); que.push(v); } } for(int i = 0; ;i++) { if (1 << i >= ans) { ans = i; break; } } cout << cnt << " " << ans << endl; } return 0; }