func main() var ss: [][]char do ss :: cui@input().split(" ") var N: int :: ss[0].toInt(&) var M: int :: ss[1].toInt(&) var friends: [][]int :: #[N, 0]int 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] :~ [q] do friends[q] :~ [p] end for var Q: int :: cui@input().toInt(&) 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@input().toInt(&) - 1 do people[A] :: 1 do que.add(A) var num: int :: 0 while(^que <> 0) var p: int :: que.get() for i(0, ^friends[p] - 1) var f: int :: friends[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