#include #include #include #include using namespace std; #define CIN( LL , A ) LL A; cin >> A #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( remove_const::type >::type VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT #include #define MAIN main int MAIN() { UNTIE; constexpr const int bound_N = 11; CIN( int , N ); assert( 0 <= N && N < bound_N ); constexpr const int bound_M = 1 << 10; int ambient = ( 1 << N ) - 1; CIN( int , M ); assert( 0 <= M && M <= ambient ); bool O[bound_M] = {}; int U[bound_M]; int Lm; int Ai; FOR( m , 0 , M ){ int& Um = U[m]; Um = 0; cin >> Lm; assert( Lm > 0 ); REPEAT( Lm ){ cin >> Ai; assert( ( Um & ( 1 << Ai ) ) == 0 ); Um |= 1 << Ai; } assert( ! O[Um] ); O[Um] = true; } int cap; int cup; bool searching; FOR( n , 0 , N ){ cap = ambient; cup = 1 << n; FOR( m , 0 , M ){ if( ( U[m] >> n ) & 1 == 1 ){ cap &= U[m]; } else { cup |= U[m]; } } if( ( ( ~cup ) & cap ) != 0 ){ RETURN( "No" ); } } RETURN( "Yes" ); }