import java.io.*; import java.util.*; import java.math.*; class Main { static int n , m , k; static int[] usedMoney; static String[][] memo; static PriorityQueue ans = new PriorityQueue(); public static void out (Object o) { System.out.println(o); } public static void bruteForce (int cnt , int pos) { if (cnt == k) { ans.add(pos); return; } if (pos == -1) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (memo[i][j] == null) continue; String[] s = memo[i][j].split(","); for (int k = 0; k < s.length; k++) { int l = Integer.parseInt(s[k]); if (usedMoney[cnt] == l) bruteForce(cnt + 1 , j); } } } } else { for (int i = 1; i <= n; i++) { if (memo[pos][i] == null) continue; String[] s = memo[pos][i].split(","); for (int j = 0; j < s.length; j++) { int l = Integer.parseInt(s[j]); if (usedMoney[cnt] == l) bruteForce(cnt + 1 , i); } } } } public static void solve () { bruteForce(0 , -1); out(ans.size()); System.out.print(ans.poll()); while (!ans.isEmpty()) System.out.print(" " + ans.poll()); out(""); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); n = Integer.parseInt(line[0]); m = Integer.parseInt(line[1]); k = Integer.parseInt(line[2]); usedMoney = new int[k]; memo = new String[n + 1][n + 1]; for (int i = 0; i < m; i++) { line = br.readLine().split(" "); int j = Integer.parseInt(line[0]); int k = Integer.parseInt(line[1]); memo[j][k] = memo[j][k] == null ? line[2] : memo[j][k] + "," + line[2]; memo[k][j] = memo[k][j] == null ? line[2] : memo[k][j] + "," + line[2]; } line = br.readLine().split(" "); for (int i = 0; i < k; i++) usedMoney[i] = Integer.parseInt(line[i]); solve(); } }