#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M,K; cin >> N >> M >> K; vector>> G(N); rep(_,M) { int a,b,c; cin >> a >> b >> c; a--; b--; G[a].push_back({b, c}); G[b].push_back({a, c}); } vector can(N, 1); rep(_,K) { int d; cin >> d; vector nt(N, 0); for(int i = 0; i < N; i++) if(can[i]) for(auto [to, cost] : G[i]) if(cost == d) nt[to] = 1; swap(can, nt); } cout << accumulate(can.begin(), can.end(), 0) << endl; rep(i,N) if(can[i]) cout << i + 1 << " "; }