#include using namespace std; #define REP(i,first,last) for (int i=first;i y ? x : y) #define MIN(x,y) (x < y ? x : y) int N,M,K; int main(){ cin >> N >> M >> K; vector>> town_info(N+1); REP(i,0,M){ int a,b,c; cin >> a >> b >> c; town_info[a][c].push_back(b); town_info[b][c].push_back(a); } vector d_list(K); REP(i,0,K){ cin >> d_list[i]; } set candidate_towns; REP(i,0,N){ candidate_towns.insert(i + 1); } for (int d: d_list) { set rest_towns; for (int c: candidate_towns) { if (town_info[c][d].size() != 0) { for (int t: town_info[c][d]) { rest_towns.insert(t); } } } candidate_towns = rest_towns; } cout << candidate_towns.size() << endl; for (int c: candidate_towns) { cout << c << " "; } cout << endl; }