#include int num_zadani; int num_hercu; int num_roli; int num_nemuze; char herci[100][100]; int role_count[100]; char nemuze[100][100]; char role[100][100]; char herci_role[100][100][100]; int main ( int argc,char** argv) { int i; char herec [ 100 ]; int roli; int j, r, h; char nemuze[100]; char buf_role[100]; int found; scanf ( "%d", &num_zadani ); while ( num_zadani-- ) { scanf ( "%d %d %d", &num_hercu, &num_roli, &num_nemuze ); for ( i = 0; i < num_hercu; i++ ) { scanf ( "%s", herci[i] ); role_count[i] = 0; } for ( i = 0; i < num_roli; i++ ) scanf ( "%s", role[i] ); /* printf ( "%d %d %d\n", num_hercu, num_roli, num_nemuze );*/ for ( i = 0; i < num_hercu; i++ ) { scanf ( "%s %d", herec, &roli ); /* printf ( "%s %d\n", herec, roli );*/ for ( h = 0; h < num_hercu; h++ ) { if ( !strcmp ( herci[h], herec ) ) { for ( r = 0; r < roli; r++ ) { scanf ( "%s", buf_role ); strcpy ( herci_role[h][r], buf_role ); } role_count[h] = roli; break; } } } for ( i = 0; i < 2;i++ ) { scanf ( "%s", nemuze ); for ( j = 0; j < num_hercu; j++ ) { if ( !strcmp ( nemuze, herci[j] ) ) herci[j][0] = 0; } } for ( i = 0; i < num_roli; i++ ) { found = 0; for ( j = 0; j < num_hercu; j++ ) { if (herci[j][0] ) { for ( r = 0; r < role_count[j]; r++ ) { if ( !strcmp ( herci_role[j][r], role[i] ) ) { found = 1; break; } } } if ( found ) break; } if (!found) break; } if ( !found || ( (num_hercu - num_nemuze) < num_roli ) ) printf ( "Zatraceni demonstranti!\n" ); else printf ( "Premiera bude!\n"); } return 0; }