#include using namespace std; #define int long long #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) template bool chmax(T &a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; return true; } return false; } constexpr int INF = 1e9; signed main() { int N, M; cin >> N >> M; vector> g(N); rep(i, 0, M) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } int Q; cin >> Q; rep(i, 0, Q) { int A; cin >> A; A--; vector dist(N, INF); queue q; q.push(A); dist[A] = 0; int sum = 0; int mx = 0; while (q.size()) { int v = q.front(); q.pop(); for (int w : g[v]) { if (dist[w] > dist[v] + 1) { dist[w] = dist[v] + 1; chmax(mx, dist[w]); q.push(w); sum++; } } } int cnt = 0; if (mx > 0) { mx--; while (mx) { mx >>= 1; cnt++; } } cout << sum << " " << cnt << endl; } }