#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, K; cin >> N >> M >> K; vector>> G(N); for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; G[a].emplace_back(make_pair(b, c)); G[b].emplace_back(make_pair(a, c)); } vector D(K); for (auto &&e : D) { cin >> e; } set st; for (int i = 0; i < N; i++) { st.insert(i); } for (int k = 0; k < K; k++) { set nst; for (auto &u : st) { for (auto &[v, c] : G[u]) { if (D[k] == c) nst.insert(v); } } swap(st, nst); } cout << st.size() << '\n'; for (const auto &e : st) { cout << e + 1 << ' '; } cout << '\n'; return 0; }