#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int llint; const int INF = 1000000; const llint LINF = 100000000; //何番目 int black[10000] = { 0 }, bn, wn; int white[10000] = { 0 }; llint dp[INF]; bool now[101]; bool nex[101]; int main() { for (int i = 0; i < 101; i++) { now[i] = 1; nex[i] = 0; } llint n, m, k; cin >> n >> m >> k; vectorb(m); vectora(m); vectorc(m); vectord(k); for (int i = 0; i < m; i++) { cin >> a[i]; cin >> b[i]; cin >> c[i]; a[i]--; b[i]--; } for (int i = 0; i < k; i++) { cin >> d[i]; } for (int i = 0; i < k; i++) { for (int j = 0; j < m; j++) { if (c[j] != d[i])continue; else { 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] = 0; } } int ans = 0; for (int i = 0; i < n; i++) { ans += now[i]; } cout << ans << endl; for (int i = 0; i < n; i++) { if (now[i]) { if(--ans)cout << i + 1 << " "; else cout << i + 1 << endl; } } //cin >> n; return 0; }