#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; struct edge { int from,to; int cost; edge(int t,int c) : to(t),cost(c) {} edge(int f,int t,int c) : from(f),to(t),cost(c) {} bool operator<(const edge &e) const { return cost < e.cost; } }; vector G[105]; vector v,ans; int n,m,k; void dfs(int now,int j) { if(j == k) { ans.push_back(now); return; } rep(i,G[now].size()) { edge e = G[now][i]; if(e.cost == v[j]) { dfs(e.to,j+1); } } } int main() { cin >> n >> m >> k; rep(i,m) { int a,b,c; cin >> a >> b >> c; a--; b--; G[a].push_back(edge(b,c)); G[b].push_back(edge(a,c)); } v.resize(k); rep(i,k) cin >> v[i]; rep(i,n) { dfs(i,0); } ans.erase(unique(ans.begin(),ans.end()),ans.end()); sort(ans.begin(),ans.end()); cout << ans.size() << endl; rep(i,ans.size()) { cout << ans[i]+1; if(i == ans.size()-1) cout << endl; else cout << " "; } return 0; }