#include using namespace std; #define int long long struct edge{ int to,cost; }; vector< edge > G[200]; signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n,m,k; cin >> n >> m >> k; for(int i = 0; i < m; i++){ int a,b,c; cin >> a >> b >> c; G[a].push_back({b,c}); G[b].push_back({a,c}); } vector< vector > dp(k+1,vector (n+1,false)); for(int i = 1; i <= n; i++) dp[0][i] = true; for(int i = 0; i < k; i++){ int d; cin >> d; for(int u = 1; u <= n; u++){ if(dp[i][u] == false) continue; for(auto v : G[u]){ if(v.cost == d){ dp[i+1][v.to] = true; } } } } vector ans; for(int i = 1; i <= n; i++){ if(dp[k][i] == true) ans.push_back(i); } cout << ans.size() << endl; for(int u : ans){ cout << u << " "; } cout << endl; return 0; }