import java.util.Arrays; import java.util.Scanner; class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int N = in.nextInt(), M = in.nextInt(), K = in.nextInt(); int[] a = new int[M + 1], b = new int[M + 1], c = new int[M + 1]; for (int i = 1; i < M + 1; i++) { a[i] = in.nextInt(); b[i] = in.nextInt(); c[i] = in.nextInt(); } int[] d = new int[K + 1]; for(int i = 1; i < K + 1; i++){ d[i] = in.nextInt(); } boolean[][] n = new boolean[K + 1][N + 1]; Arrays.fill(n[0], true); for(int i = 1; i < K + 1; i++){ Arrays.fill(n[i], false); } for(int x = 1; x < K + 1; x++){ for(int y = 1; y < N + 1; y++){ for(int z = 1; z < M + 1; z++){ if(n[x - 1][y]){ if(a[z] == y && c[z] == d[x]){ n[x][b[z]] = true; } if(b[z] == y && c[z] == d[x]){ n[x][a[z]] = true; } } } } } int sum = 0; for(int i = 1; i < N + 1; i++){ if(n[K][i]){ sum++; } } System.out.println(sum); boolean t = true; for(int i = 1; i < N + 1; i++){ if(t && n[K][i]){ System.out.print(i); t = false; }else if(n[K][i]){ System.out.print(" " + i); } } System.out.println(); } }