local ior = io.input() local n, m = ior:read("*n", "*n") local t = {} for i = 1, n do t[i] = {} end for i = 1, m do local a, b = ior:read("*n", "*n") t[a][b], t[b][a] = true, true end local map = {} local q = ior:read("*n") for i = 1, q do local fst = ior:read("*n") for j = 1, n do map[j] = -2 end map[fst] = -1 local tasks = {fst} local tasknum = 1 local done = 0 local friendnum, day = 0, 0 while(done < tasknum) do done = done + 1 local curidx = tasks[done] for k, v in pairs(t[curidx]) do if(map[k] == -2) then map[k] = map[curidx] + 1 friendnum, day = friendnum + 1, map[k] tasknum = tasknum + 1 tasks[tasknum] = k end end end local i_d = 0 while(i_d * (i_d + 1) <= 2 * (day - 1)) do i_d = i_d + 1 end print(friendnum .. " " .. i_d) end