#include using namespace std; int main(){ int N, M, K; cin >> N >> M >> K; vector>> E(N); for (int i = 0; i < M; i++){ int a, b, c; cin >> a >> b >> c; a--; b--; E[a].push_back(make_pair(c, b)); E[b].push_back(make_pair(c, a)); } vector d(K); for (int i = 0; i < K; i++){ cin >> d[i]; } vector> dp(K + 1, vector(N, false)); for (int i = 0; i < N; i++){ dp[0][i] = true; } for (int i = 0; i < K; i++){ for (int j = 0; j < N; j++){ if (dp[i][j]){ for (auto P : E[j]){ if (P.first == d[i]){ dp[i + 1][P.second] = true; } } } } } vector ans; for (int i = 0; i < N; i++){ if (dp[K][i]){ ans.push_back(i); } } int cnt = ans.size(); cout << cnt << endl; for (int i = 0; i < cnt; i++){ cout << ans[i] + 1; if (i < cnt - 1){ cout << ' '; } } cout << endl; }