#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define LONG_INF 100000000000000 vector> vertex[10000]; bool can_be[2000][10000] = {}; int main() { iostream::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; REP(i, m) { int a, b, c; cin >> a >> b >> c; vertex[a].push_back(make_pair(c, b)); vertex[b].push_back(make_pair(c, a)); } REP(i, 2000) { can_be[i][0] = true; } for (int i = 0;i < k;++i) { int d; cin >> d; for (int q = 1;q <= n;++q) { if (can_be[q][i] == true) { for (int j = 0;j < vertex[q].size();++j) { if (vertex[q][j].first == d) { can_be[vertex[q][j].second][i + 1] = true; } } } } } vector nya; for (int i = 0;i <= n;++i) { if (can_be[i][k]) { nya.push_back(i); } } cout << nya.size() << endl; for (int i = 0;i < nya.size();++i) { cout << nya[i] << " "; } cout << endl; return 0; }