#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define F first #define S second using namespace std; vector> edge[110]; vector ok; int d[1010]; int main() { int N,M,K; cin>>N>>M>>K; REP(i,0,M){ int a,b,c; cin>>a>>b>>c; a--;b--; edge[a].push_back({b,c}); edge[b].push_back({a,c}); } REP(i,0,K) cin>>d[i]; REP(i,0,N) ok.push_back(i); REP(k,0,K){ vector tmp; for(auto next:ok){ REP(j,0,edge[next].size()){ if(edge[next][j].S==d[k]) tmp.push_back(edge[next][j].F); } } tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end()); ok=tmp; } cout<