#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int N, M, K; vector g[100]; bool dp[2][100]; int main() { cin >> N >> M >> K; REP(i, M) { int a, b, c; scanf("%d %d %d", &a, &b, &c); a--; b--; g[a].push_back(pii(b, c)); g[b].push_back(pii(a, c)); } memset(dp[0], -1, sizeof(dp[0])); REP(i, K) { int d; scanf("%d", &d); int now = i % 2; int next = !now; memset(dp[next], 0, sizeof(dp[next])); REP(j, N) if (dp[now][j]) { REP(k, g[j].size()) if (g[j][k].second == d) { dp[next][g[j][k].first] = true; } } } vector ans; REP(i, N) if (dp[K % 2][i]) ans.push_back(i + 1); cout << ans.size() << endl; REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' '); return 0; }