import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); ArrayList> graph = new ArrayList<>(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; int c = sc.nextInt(); graph.get(a).add(new Path(b, c)); graph.get(b).add(new Path(a, c)); } TreeSet current = new TreeSet<>(); for (int i = 0; i < n; i++) { current.add(i); } for (int i = 0; i < k; i++) { TreeSet next = new TreeSet<>(); int d = sc.nextInt(); for (int x : current) { for (Path y : graph.get(x)) { if (y.value == d) { next.add(y.idx); } } } current = next; } StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (int x : current) { if (!isFirst) { sb.append(" "); } isFirst = false; sb.append(x + 1); } System.out.println(current.size()); System.out.println(sb); } static class Path { int idx; int value; public Path (int idx, int value) { this.idx = idx; this.value = value; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }