func main() var ss: [][]char do ss :: cui@input().split(" ") var N: int :: ss[0].toInt(&) var M: int :: ss[1].toInt(&) var friends: []list :: #[N]list for i(0, N - 1) do friends[i] :: #list end for for i(0, M - 1) do ss :: cui@input().split(" ") var p: int :: ss[0].toInt(&) - 1 var q: int :: ss[1].toInt(&) - 1 do friends[p].add(q) do friends[q].add(p) end for var Q: int :: cui@input().toInt(&) var st: queue :: #queue var people: []int :: #[N]int for(1, Q) for i(0, N - 1) do people[i] :: 0 end for var A: int :: cui@input().toInt(&) - 1 do people[A] :: 1 do st.add(A) var num: int :: 0 while(^st <> 0) var p: int :: st.get() do friends[p].head() for i(0, ^friends[p] - 1) var f: int :: friends[p].get() do friends[p].next() if(people[f] = 0) do people[f] :: people[p] + 1 do num :+ 1 do st.add(f) else if(people[p] + 1 < people[f]) do people[f] :: people[p] + 1 end if end if end for end while var len: int :: 0 for i(0, N - 1) if(people[i] > len) do len :: people[i] end if end for do len :- 1 var ans: int :: 0 while(2 ^ ans < len) do ans :+ 1 end while do cui@print("\{num} \{ans}\n") end for end func