#include using namespace std; int a[1000], b[1000], c[1000], d[1000]; bool pos[1001][101]; // pos[k][i] := k 回目の移動後に町 i にいる可能性 int main() { int N, M, K; cin >> N >> M >> K; for (int j = 0; j < M; j++) cin >> a[j] >> b[j] >> c[j]; for (int k = 0; k < K; k++) cin >> d[k]; fill(pos[0] + 1, pos[0] + N, true); for (int k = 0; k < K; k++) for (int j = 0; j < M; j++) if (c[j] == d[k]) { int u = a[j], v = b[j]; if (pos[k][u]) pos[k + 1][v] = true; if (pos[k][v]) pos[k + 1][u] = true; } int cnt = 0; for (int i = 1; i <= N; i++) if (pos[K][i]) cnt++; cout << cnt << endl; for (int i = 1; i <= N; i++) if (pos[K][i]) cout << i << ' '; cout << endl; }