import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); int m = stdin.nextInt(); List> friend = IntStream.range(0, n).mapToObj(unused -> new ArrayList()).collect(Collectors.toList()); for (int i = 0; i < m; i++) { int p = stdin.nextInt() - 1; int q = stdin.nextInt() - 1; friend.get(p).add(q); friend.get(q).add(p); } int q = stdin.nextInt(); List alist = new ArrayList<>(); for (int i = 0; i < q; i++) { int a = stdin.nextInt() - 1; alist.add(a); } int inf = 1000000007; for (int a : alist) { List d = IntStream.range(0, n).map(unused -> inf).boxed().collect(Collectors.toList()); d.set(a, 0); PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> d.get(i))); IntStream.range(0, n).forEach(i -> pq.offer(i)); while (!pq.isEmpty()) { int x = pq.poll(); for (int y : friend.get(x)) { if (d.get(x) + 1 < d.get(y)) { d.set(y, d.get(x) + 1); pq.offer(y); } } } int b = 0; int c = 0; for (int v : d) { if (v != 0 && v != inf) { b++; c = Math.max(c, v); } } if (c == 0) { System.out.printf("%d %d%n", b, c); } else { System.out.printf("%d %d%n", b, (int)Math.ceil(Math.log(c) / Math.log(2))); } } } }