import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); final int K = sc.nextInt(); ArrayList>> adj = new ArrayList>>(); for(int i = 0; i < N; i++){ adj.add(new LinkedHashMap>()); } for(int i = 0; i < M; i++){ final int a = sc.nextInt() - 1; final int b = sc.nextInt() - 1; final long c = sc.nextLong(); if(!adj.get(a).containsKey(b)){ adj.get(a).put(b, new LinkedList()); } if(!adj.get(b).containsKey(a)){ adj.get(b).put(a, new LinkedList()); } adj.get(a).get(b).add(c); adj.get(b).get(a).add(c); } TreeSet set = new TreeSet(); for(int i = 0; i < N; i++){ set.add(i); } for(int i = 0; i < K; i++){ final long d = sc.nextLong(); TreeSet new_set = new TreeSet(); for(final int node : set){ for(final int next : adj.get(node).keySet()){ for(final long cost : adj.get(node).get(next)){ if(cost == d){ new_set.add(next); } } } } set.clear(); set.addAll(new_set); } System.out.println(set.size()); boolean first = true; for(final int node : set){ if(first){ first = false; }else{ System.out.print(" "); } System.out.print(node + 1); } System.out.println(); } }