import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); ArrayList[] graph = new ArrayList[n]; for (int i = 0; i < n; i++) { graph[i] = new ArrayList<>(); } for (int i = 0; i < m; i++) { String[] line = br.readLine().split(" ", 2); int a = Integer.parseInt(line[0]) - 1; int b = Integer.parseInt(line[1]) - 1; graph[a].add(b); graph[b].add(a); } int q = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); ArrayDeque next = new ArrayDeque<>(); ArrayDeque day = new ArrayDeque<>(); for (int i = 0; i < q; i++) { int x = Integer.parseInt(br.readLine()) - 1; int[] friends = new int[n]; Arrays.fill(friends, Integer.MAX_VALUE / 10); next.add(x); day.add(0); while (next.size() > 0) { int y = next.poll(); int z = day.poll(); if (friends[y] > z) { friends[y] = z; for (int a : graph[y]) { next.add(a); day.add(z + 1); } } } int count = 0; int max = 0; for (int j = 0; j < n; j++) { if (friends[j] < Integer.MAX_VALUE / 10) { count++; max = Math.max(max, friends[j]); } } sb.append(count - 1).append(" ").append(max - 1).append("\n"); } System.out.print(sb); } }