#include #include #include #include using namespace std; int N, M, K; vector> > fee(1000); int d[1000] = {0}; int main() { cin >> N >> M >> K; for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; fee[a-1][b-1].push_back(c); fee[b-1][a-1].push_back(c); } for (int i = 0; i < K; i++) { cin >> d[i]; } set candidate; for (int i = 0; i < N; i++) { candidate.insert(i); } for (int i = 0; i < K; i++) { set new_candidate; for (int now: candidate) { for (auto next: fee[now]) { for (int f: next.second) { if (d[i] == f) { new_candidate.insert(next.first); } } } } candidate = new_candidate; } cout << candidate.size() << endl; for (auto itr = candidate.begin(); itr != candidate.end(); itr++) { cout << *itr + 1; if (itr != --candidate.end()) { cout << " "; } else { cout << endl; } } }