import java.util.*; public class Main { static ArrayList[] graph; static int k; static HashSet[] visited; static TreeSet ans = new TreeSet<>(); static int[] costs; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); k = sc.nextInt(); graph = new ArrayList[n + 1]; visited = new HashSet[n + 1]; costs = new int[k]; for (int i = 1; i <= n; i++) { graph[i] = new ArrayList(); visited[i] = new HashSet(); } for (int i = 0; i < m; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); graph[a].add(new Path(b, c)); graph[b].add(new Path(a, c)); } for (int i = 0; i < k; i++) { costs[i] = sc.nextInt(); } for (int i = 1; i <= n; i++) { search(0, i); } System.out.println(ans.size()); boolean notFirst = false; StringBuilder sb = new StringBuilder(); for (Integer x : ans) { if (notFirst) { sb.append(" "); } sb.append(x); notFirst = true; } System.out.println(sb); } static void search(int idx, int to) { if (visited[to].contains(idx)) { return; } if (idx >= k) { ans.add(to); return; } visited[to].add(idx); for (Path p : graph[to]) { if (costs[idx] == p.cost) { search(idx + 1, p.to); } } } static class Path { int to; int cost; public Path (int to, int cost) { this.to = to; this.cost = cost; } } }