#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; template struct edge{ int to; T wt; edge(int to,const T& wt):to(to),wt(wt){} }; template using weighted_graph=vector>>; int main(){ int n,m,k; scanf("%d%d%d",&n,&m,&k); weighted_graph G(n); rep(i,m){ int u,v,c; scanf("%d%d%d",&u,&v,&c); u--; v--; G[u].emplace_back(v,c); G[v].emplace_back(u,c); } bool dp[1001][100]={}; rep(u,n) dp[0][u]=true; rep(t,k){ int d; scanf("%d",&d); rep(u,n) if(dp[t][u]) { for(auto e:G[u]) if(e.wt==d) { dp[t+1][e.to]=true; } } } vector ans; rep(u,n) if(dp[k][u]) ans.emplace_back(u); printf("%lu\n",ans.size()); rep(i,ans.size()) printf("%d%c",ans[i]+1,i+1