import java.util.*; import java.io.*; class Main implements Runnable { //その時の思考をここに書く /* * */ record Edge(int to , int cost ) { } record State(int now , int idx) { } void solve() { int N = in.nextInt() , M = in.nextInt() , K = in.nextInt(); List [] G = new ArrayList[N]; for(int i = 0 ; i < N ; i ++ ) { G[i] = new ArrayList<>(); } for(int i = 0 ; i < M ; i ++ ) { int a = in.nextInt() , b = in.nextInt() , c = in.nextInt(); --a;--b; G[a].add(new Edge(b , c)); G[b].add(new Edge(a, c)); } int [] d = in.IntArray(K); boolean [] pob = new boolean[N]; Queue Q = new ArrayDeque<>(); for(int i = 0 ; i < N ; i ++ ) { Q.add(new State(i, 0)); while(!Q.isEmpty()) { var q = Q.poll(); int now = q.now , id = q.idx ; if(id == K) { pob[now] = true; continue; } for(Edge nxt : G[now]) { int next = nxt.to , cost = nxt.cost; if(d[id] == cost) Q.add(new State(next , ++id)); } } } TreeSet ver = new TreeSet<>(); for(int i = 0 ; i < N ; i ++ ) if(pob[i]) ver.add(i + 1); out.println(ver.size()); for(int v : ver) out.print(v+" "); } public static void main(String[] args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); } public void run() { solve(); out.flush(); } record ip(int fi , int se) { public String toString() { return fi +" "+ se ;} } record lp(long fi , long se) { public String toString() { return fi +" "+ se ;} } public double dist(lp p1 , lp p2) { return Math.sqrt((p1.fi - p2.fi) * (p1.fi - p2.fi) + (p1.se - p2.se) * (p1.se - p2.se)); } public int max(int ... a) { int max = -1 ; for(int p : a) max = Math.max(max , p); return max; } public int min(int ... a) { int min = Integer.MAX_VALUE ; for(int p : a) min = Math.min(min , p); return min; } public long max(long ... a) { long max = -1 ; for(long p : a) max = Math.max(max , p); return max; } public long min(long ... a) { long min = Long.MAX_VALUE ; for(long p : a) min = Math.min(min , p); return min; } public int sum(int ... a) { int sum = 0 ; for(int p : a) sum += p ; return sum ;} public long sum(long ... a) { long sum = 0 ; for(long p : a) sum += p ; return sum ;} public int abs(int a , int b) { return (int) Math.abs(a - b) ; } public long abs(long a , long b) { return (long) Math.abs(a - b) ; } public int pow(int a , int b) { return (int) Math.pow(a , b) ; } public long pow(long a , long b) { return (long) Math.pow(a , b) ; } public long rec(long a) { return a == 1 ? 1 : a * rec(a - 1); } public long [] recmod(int a , long MOD) { long [] recMod = new long[1 << 17] ; recMod[1] = 1 ; for(int i = 2 ; i < (1 << 17) ; i ++ ) recMod[i] = (recMod[i - 1] * i) % MOD9; return recMod; } public int [] rev(int [] a) { int [] r = new int[a.length] ; int idx = a.length ; for(int p : a) r[--idx] = p ; return r ; } public long [] rev(long [] a) { long [] r = new long[a.length] ; int idx = a.length ; for(long p : a) r[--idx] = p ; return r ; } public int gcd(int a, int b) { return b == 0 ? a: gcd(b, a % b); } public int lcm(int a, int b) { return a / gcd(a, b) * b; } public long gcd(long a, long b) { return b == 0 ? a: gcd(b, a % b); } public long lcm(long a, long b) { return a / gcd(a, b) * b; } public int gcd(int ... a) { int gcd = 0 ; for(int p : a) gcd = gcd(gcd , p) ; return gcd ; } public long gcd(long ... a) { long gcd = 0L ; for(long p : a) gcd = gcd(gcd , p) ; return gcd ; } public int lcm(int ... a) { int lcm = 1 ; for(int p : a) lcm = lcm(lcm , p) ; return lcm ; } public long lcm(long ... a) { long lcm = 1 ; for(long p : a) lcm = lcm(lcm , p) ; return lcm ; } public char upper(char c) { return (char)('A' + (c - 'a')); } public char lower(char c) { return (char)('a' + (c - 'A')); } public String yn(boolean a) { return a ? yes : no ; } public String rev(String a) { return new StringBuilder(a).reverse().toString(); } public void fill(int [] a , int v) { Arrays.fill(a , v); } public void fill(long [] a , long v) { Arrays.fill(a , v); } public void fill(int [][] a , int v) { for(int [] aa : a) fill(aa , v) ; } public void fill(long [][] a , long v) { for(long [] aa : a) fill(aa , v) ; } public void fill(int [][][] a , int v) { for(int [][] aa : a) fill(aa , v); } public void fill(long [][][] a , long v) { for(long [][] aa : a) fill(aa , v); } public int [] copy(int [] a) { return Arrays.copyOf(a , a.length); } public long [] copy(long [] a) { return Arrays.copyOf(a , a.length); } public String bin(int a , int len) { String b = Integer.toBinaryString(a); while(b.length() < len) b = "0" + b ; return b ; } public void debug(int [] a) { out.println(Arrays.toString(a)); fl();} public void debug(long [] a) { out.println(Arrays.toString(a)); fl();} public void debug(double [] a) { out.println(Arrays.toString(a)); fl();} public void debug(String [] a) { out.println(Arrays.toString(a)); fl();} public void debug(char [] a) { out.println(Arrays.toString(a)); fl();} public void debug(boolean [] a) { char [] c = conv(a); debug(c); fl();} public void debug(int [][] a) { for(int i = 0 ; i < a.length ; i ++ ) out.println(Arrays.toString(a[i])); fl();} public void debug(long [][] a) { for(int i = 0 ; i < a.length ; i ++ ) out.println(Arrays.toString(a[i])); fl();} public void debug(double [][] a) { for(int i = 0 ; i < a.length ; i ++ ) out.println(Arrays.toString(a[i])); fl();} public void debug(String [][] a) { for(int i = 0 ; i < a.length ; i ++ ) out.println(Arrays.toString(a[i])); fl();} public void debug(char [][] a) { for(int i = 0 ; i < a.length ; i ++ ) out.println(Arrays.toString(a[i])); fl();} public void debug(boolean [][] a) { char [][] c = new char [a.length][a[0].length] ; for(int i = 0 ; i < a.length ; i ++ ) c[i] = conv(a[i]) ; debug(c); fl();} private char [] conv(boolean [] a) { char [] c = new char[a.length] ; for(int i = 0 ; i < a.length ; i ++ ) c[i] = a[i] ? 'O' : 'X' ; return c ; } private void fl() { out.flush(); } PrintWriter out = new PrintWriter(System.out); In in = new In(); static final long MOD7 = 1000000007; static final long MOD9 = 998244353; static final int inf = (1 << 30); static final long lnf = (1L << 60); final String yes = "Yes"; final String no = "No" ; final char [] dir = {'U','R','D','L'}; final int [] dy4 = {-1,0,1,0}; final int [] dx4 = {0,1,0,-1}; final int [] dy8 = {-1,-1,-1,0,1,1,1,0}; final int [] dx8 = {-1,0,1,1,1,0,-1,-1}; } class mint { private long value; private final long MOD; mint(long value, long MOD) { this.MOD = MOD; this.value = (value % MOD + MOD) % MOD; } public mint add(mint other) { return new mint((this.value + other.value) % MOD, MOD); } public mint subtract(mint other) { return new mint((this.value - other.value + MOD) % MOD, MOD); } public mint multiply(mint other) { return new mint((this.value * other.value) % MOD, MOD); } public mint inverse() { return new mint(pow(this.value, MOD - 2), MOD); } public mint divide(mint other) { return this.multiply(other.inverse()); } private long pow(long a, long b) { long res = 1; while (b > 0) { if ((b & 1) != 0) res = (res * a) % MOD; a = (a * a) % MOD; b >>= 1; } return res; } public long getVal() { return value; } @Override public String toString() { return String.valueOf(value); } } class In { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) { ptr++; } return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } public char nextChar() { return next().charAt(0); } public int [] IntArray(int n) { final int [] Array = new int [n]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = nextInt(); } return Array; } public int [][] IntArray(int n , int m) { final int [][] Array = new int [n][m]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = IntArray(m); } return Array; } public long [] LongArray(int n) { final long [] Array = new long [n]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = nextLong(); } return Array; } public long [][] LongArray(int n , int m) { final long [][] Array = new long [n][m]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = LongArray(m); } return Array; } public String [] StringArray(int n) { final String [] Array = new String [n]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = next(); } return Array; } public char [] CharArray(int n) { final char [] Array = new char[n]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = next().charAt(0); } return Array; } public char [][] CharArray(int n , int m) { final char [][] Array = new char [n][m]; for(int i = 0 ; i < n ; i ++ ) { Array[i] = next().toCharArray(); } return Array; } public char [][] CharArray2(int n , int m) { final char [][] Array = new char [n][m]; for(int i = 0 ; i < n ; i ++ ) { for(int j = 0 ; j < m ; j ++ ) { Array[i][j] = next().charAt(0); } } return Array; } public List [] Graph(int n) { @SuppressWarnings("unchecked") List [] G = new ArrayList[n]; for(int i = 0 ; i < n ; i ++ ) { G[i] = new ArrayList<>(); } return G ; } }