#include using namespace std; struct edge{ int to, cost; edge(int a, int b){ to = a, cost = b; } }; int N, M, K, d[1010], dp[1010][110]; //dp[k][v] := k回目にvにいる時到達可能かどうか; bool ans[110]; vector> G; void dfs(int v, int pv, int k = 0){ if(dp[k][v] != 0) return ; if(k == K){ ans[v] = true; dp[k][v] = 1; return ; } bool ng = true; for(auto nv : G[v]){ if(d[k] != nv.cost) continue; dfs(nv.to, v, k + 1); dp[k][v] = dp[k+1][nv.to]; ng = false; } if(ng) dp[k][v] = -1; } int main(){ cin >> N >> M >> K; G.assign(N, vector()); for(int i = 0; i < M; i++){ int a, b, c; cin >> a >> b >> c; a--, b--; G[a].emplace_back(b, c); G[b].emplace_back(a, c); } for(int i = 0; i < K; i++) cin >> d[i]; for(int i = 0; i < N; i++){ dfs(i, -1); } cout << count(ans, ans+N, true) << endl; for(int i = 0; i < N; i++){ if(ans[i]){ cout << i + 1 << " "; } } cout << endl; return 0; }