import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int K = sc.nextInt(); int[] a = new int[M]; int[] b = new int[M]; int[] c = new int[M]; int[] d = new int[K]; for(int i = 0; i < M; i++) { a[i] = sc.nextInt() - 1; b[i] = sc.nextInt() - 1; c[i] = sc.nextInt(); } for(int i = 0; i < K; i++) { d[i] = sc.nextInt(); } // dp[i][j]はd1~di(i個)までから町jが可能性があるかどうかを表す int[][] dp = new int[K + 1][N]; for(int j = 0; j < N; j++) { dp[0][j] = 1; } for(int i = 1; i < K + 1; i++) { for(int k = 0; k < M; k++) { if(c[k] == d[i - 1]) { int towna = a[k]; int townb = b[k]; if(dp[i][towna] == 0) { dp[i][towna] = dp[i - 1][townb]; } if(dp[i][townb] == 0) { dp[i][townb] = dp[i - 1][towna]; } } } } int ans = 0; for(int j = 0; j < N; j++) { ans += dp[K][j]; } System.out.println(ans); ArrayList town = new ArrayList(); for(int j = 0; j < N; j++) { if(dp[K][j] == 1) town.add(j + 1); } for(int j = 0; j < town.size(); j++) { System.out.print(town.get(j)); if(j < town.size() - 1) { System.out.print(" "); } else { System.out.println(); } } } }