#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; int p[1010][110]; int a[1010], b[1010], c[1010], d[1010]; int main(){ int n, m, k; cin >> n >> m >> k; rep(i,0,m) { cin >> a[i] >> b[i] >> c[i]; } rep(i, 0, k)cin >> d[i]; rep(i, 1, n+1)p[0][i] = 1; rep(i, 1, k+1)rep(j,0,m) { if (d[i-1] == c[j]) { if (p[i - 1][a[j]])p[i][b[j]] = 1; if (p[i - 1][b[j]])p[i][a[j]] = 1; } } int ans = 0; rep(i, 1, n+1)ans += p[k][i]; cout << ans << endl; rep(i, 1, n+1) { if (p[k][i]) { cout << i << " "; } } cout << endl; return 0; }