#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; map > g; int main() { cin >> n >> m >> k; REP(i, m) { int a, b, c; scanf("%d %d %d", &a, &b, &c); a--; b--; g[c].push_back(pii(a, b)); g[c].push_back(pii(b, a)); } set cv; REP(i, n) cv.insert(i); REP(i, k) { int d; scanf("%d", &d); vector &gn = g[d]; set now; for (set::iterator it = cv.begin(); it != cv.end(); ++it) { REP(j, gn.size()) if (gn[j].first == *it) now.insert(gn[j].second); } cv = now; } vector ans; for (set::iterator it = cv.begin(); it != cv.end(); ++it) ans.push_back(*it + 1); cout << ans.size() << endl; REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' '); return 0; }