func main() var N: int :: cui@inputInt() var M: int :: cui@inputInt() var friendList: []list :: #[N]list for i(0, N - 1) do friendList[i] :: #list end for for i(0, M - 1) var p: int :: cui@inputInt() - 1 var q: int :: cui@inputInt() - 1 do friendList[p].add(q) do friendList[q].add(p) end for var friendArray: [][]int :: #[N][]int for i(0, N - 1) do friendArray[i] :: friendList[i].toArray() end for var Q: int :: cui@inputInt() var que: 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@inputInt() - 1 do people[A] :: 1 do que.add(A) var num: int :: 0 while(^que <> 0) var p: int :: que.get() for i(0, ^friendArray[p] - 1) var f: int :: friendArray[p][i] if(people[f] = 0) do people[f] :: people[p] + 1 do num :+ 1 do que.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