import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; import java.util.TreeMap; public class Main { static TreeMap ansMap = new TreeMap(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); Map> map = new HashMap>(); for (int i = 0; i < m; i++) { int p = sc.nextInt(); int q = sc.nextInt(); if (map.containsKey(p)) { map.get(p).add(q); } else { Set set = new HashSet(); set.add(q); map.put(p, set); } if (map.containsKey(q)) { map.get(q).add(p); } else { Set set = new HashSet(); set.add(p); map.put(q, set); } } int q = sc.nextInt(); int[] a = new int[q]; for (int i = 0; i < q; i++) { a[i] = sc.nextInt(); } sc.close(); for (int i = 0; i < q; i++) { Set set = map.get(a[i]); if (set == null) { System.out.println("0 0"); continue; } int cnt = set.size(); int d = 0; Set baseSet = new HashSet(); baseSet.addAll(set); Set oldSet = baseSet; while (true) { Set newSet = new HashSet(); Integer[] arr = oldSet.toArray(new Integer[0]); for (int key : arr) { Set val = map.get(key); baseSet.addAll(val); baseSet.remove(a[i]); newSet.addAll(val); newSet.remove(a[i]); } int cnt2 = baseSet.size(); if (cnt == cnt2) { if (d == 0) { System.out.println(cnt + " " + 0); } else { int d2 = 1; while (d >= 2) { d /= 2; d2++; } System.out.println(cnt + " " + d2); } break; } oldSet = newSet; cnt = cnt2; d++; } } } }