#define rep1( i, n ) for( int i = 1; i <= n; i++ ) #include using namespace std; struct Root { int a; int b; int c; }; Root R[ 1010 ]; int d[ 1010 ]; bool bPre[ 110 ]; bool b[ 110 ]; int main() { int i; int j; int m; int N; int M; int K; int iCnt; cin >> N; cin >> M; cin >> K; rep1( i, M ) { cin >> R[ i ].a; cin >> R[ i ].b; cin >> R[ i ].c; } rep1( m, K ) cin >> d[ m ]; rep1( i, N ) bPre[ i ] = true; rep1( m, K ) { rep1( i, N ) b[ i ] = false; rep1( j, M ) { if( d[ m ] != R[ j ].c ) continue; if( bPre[ R[ j ].a ] ) b[ R[ j ].b ] = true; if( bPre[ R[ j ].b ] ) b[ R[ j ].a ] = true; } rep1( i, N ) bPre[ i ] = b[ i ]; } iCnt = 0; rep1( i, N ) { if( b[ i ] ) iCnt++; } cout << iCnt << endl; rep1( i, N ) { if( b[ i ] ) cout << i << " "; } cout << endl; return 0; }