#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 k; int N; int M; int K; int iCnt; cin >> N; cin >> M; cin >> K; for( i = 1; i <= M; i++ ) { cin >> R[ i ].a; cin >> R[ i ].b; cin >> R[ i ].c; } for( i = 1; i <= K; i++ ) cin >> d[ i ]; for( i = 1; i <= N; i++ ) bPre[ i ] = true; for( i = 1; i <= K; i++ ) { for( k = 1; k <= N; k++ ) b[ k ] = false; for( j = 1; j <= M; j++ ) { if( d[ i ] != R[ j ].c ) continue; if( bPre[ R[ j ].a ] ) b[ R[ j ].b ] = true; if( bPre[ R[ j ].b ] ) b[ R[ j ].a ] = true; } for( k = 1; k <= N; k++ ) bPre[ k ] = b[ k ]; } iCnt = 0; for( k = 1; k <= N; k++ ) { if( b[ k ] ) iCnt++; } cout << iCnt << endl; for( i = 1; i <= N; i++ ) { if( b[ i ] ) cout << i << endl; } return 0; }