#include using namespace std; int N, M, K; int a[101], b[101], c[101]; int d[1001]; bool nex[101]; bool now[101]; int main(void) { cin >> N >> M >> K; for (int i = 0; i < M; i++) { cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; } for (int i = 0; i < K; i++) cin >> d[i]; for (int i = 0; i < N; i++) { now[i] = true; nex[i] = false; } for (int i = 0; i < K; i++) { for (int j = 0; j < M; j++) { if (c[j] != d[i]) continue; nex[a[j]] |= now[b[j]]; nex[b[j]] |= now[a[j]]; } for (int j = 0; j < N; j++) { now[j] = nex[j]; nex[j] = false; } } int count = 0; for (int i = 0; i < N; i++) { if (now[i]) count++; } cout << count << endl; for (int i = 0; i < N; i++) { if (!now[i]) continue; if (--count) cout << i + 1 << " "; else cout << (i + 1) << endl; } return 0; }