import java.util.Arrays; import java.util.Scanner; public class Yuki092 { public static void main(String[] args) { Yuki092 hoge = new Yuki092(); } Yuki092() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int M = scanner.nextInt(); int K = scanner.nextInt(); int[] a = new int[M]; int[] b = new int[M]; int[] c = new int[M]; boolean[] prev = new boolean[N + 1]; Arrays.fill(prev, true); for (int i = 0; i < M; i++) { a[i] = scanner.nextInt(); b[i] = scanner.nextInt(); c[i] = scanner.nextInt(); } for (int i = 0; i < K; i++) { int d = scanner.nextInt(); boolean[] next = new boolean[N+1]; for (int j = 0; j < M; j++) { if (c[j] == d) { int u = a[j], v = b[j]; if (prev[u]) { next[v] = true; } if (prev[v]) { next[u] = true; } } } prev = next; } int count = 0; for (int j = 0; j < N+1; j++) { if (prev[j]) { count++; } } System.out.println(count); StringBuilder ans = new StringBuilder(); for (int j = 0; j < N+1; j++) { if (prev[j]) { if (ans.length() > 0) { ans.append(" "); } ans.append(j); } } System.out.println(ans); } }