#include using namespace std; template istream &operator>>(istream &is,vector &a){ for(auto &v : a) cin >> v; return is; } template ostream &operator<<(ostream &os,const vector &a){ if(a.size() == 0) return os; cout << a.at(0); for(int i=1; i> N >> M >> K; map>> Cs; while(M--){ int a,b,c; cin >> a >> b >> c; a--,b--,c--; Cs[c].push_back({a,b}); } vector OK(N,true); while(K--){ int d; cin >> d; d--; vector next(N); for(auto [a,b] : Cs[d]){ if(OK.at(b)) next.at(a) = true; if(OK.at(a)) next.at(b) = true; } swap(OK,next); } int ok = 0; for(int i=0; i