#include using namespace std; #define rep(i,N) for(int (i)=0;(i) < (N); (i)++) using Graph = vector>>; int main(){ int N,M,K; cin >> N >> M >> K; Graph G(N+1); rep(i,M){ int a,b,c; cin >> a >> b >> c; G[a].push_back({b,c}); G[b].push_back({a,c}); } set vtx; for(int i=1;i<=N;i++) vtx.insert(i); rep(i,K){ int d; cin >> d; set nvtx; for(auto& v : vtx){ for(auto& e : G[v]){ if(d == e.second) nvtx.insert(e.first); } } vtx = nvtx; } cout << vtx.size() << endl; for(auto v : vtx) cout << v << " "; cout << endl; }