import java.util.ArrayDeque; import java.util.ArrayList; import java.util.List; import java.util.Queue; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Main_yukicoder92 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); List> edges = new ArrayList>(); for (int i = 0; i < n; i++) { edges.add(new ArrayDeque()); } for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; int c = sc.nextInt(); edges.get(a).add(new Edge(a, b, c)); edges.get(b).add(new Edge(b, a, c)); } int[] d = new int[k]; for (int i = 0; i < k; i++) { d[i] = sc.nextInt(); } Set ret = new TreeSet(); for (int i = 0; i < n; i++) { ret.add(i); } for (int i = 0; i < k; i++) { Set tmp = new TreeSet(); for (int v : ret) { for (Edge e : edges.get(v)) { if (e.w == d[i]) { tmp.add(e.v); } } } ret = tmp; } System.out.println(ret.size()); boolean flag = false; for (int e : ret) { if (!flag) { System.out.printf("%d", e + 1); flag = true; } else { System.out.printf(" %d", e + 1); } } System.out.println(""); sc.close(); } private static class Edge { // int u; // from int v; // to int w; // cost Edge(int u, int v, int w) { // this.u = u; this.v = v; this.w = w; } } }