Language: C++

// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_NM 10
int N,M;
int K[MAX_NM];
int S[MAX_NM][MAX_NM];
int P[MAX_NM];
int Sbits[MAX_NM];

int numofbits(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	FOR(m,M) {
		cin >> K[m];
		FOR(k,K[m]) {
			cin >> S[m][k];
			Sbits[m] |= (1 << S[m][k]);
		}
	}
	FOR(m,M) {
		cin >> P[m];
	}
	int count = 0;
	for(int i=1; i<pow(2,N); i++) {
		int switches = i<<1;
		int ok=true;
		FOR(m,M) {
			if(numofbits(switches&Sbits[m])%2!=P[m]) {
				DOUT << "[NG] switches = " << bitset<12>(switches) << ", Sbits="<< bitset<12>(Sbits[m]) << endl;
				ok = false;
				break;
			}
		}
		if(ok) {
			DOUT << "[OK] switches = " << bitset<12>(i)<< endl;
			count++;
		}
	}
	cout << dec << count << endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:82:63: error: 'bitset' was not declared in this scope
   82 |                                 DOUT << "[NG] switches = " << bitset<12>(switches) << ", Sbits="<< bitset<12>(Sbits[m]) << endl;
      |                                                               ^~~~~~
a.cc:16:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   15 | #include <string.h>
  +++ |+#include <bitset>
   16 | // #include <limits.h>
a.cc:82:84: error: invalid operands of types 'int' and 'const char [9]' to binary 'operator<<'
   82 |                                 DOUT << "[NG] switches = " << bitset<12>(switches) << ", Sbits="<< bitset<12>(Sbits[m]) << endl;
      |                                                                         ~~~~~~~~~~ ^~ ~~~~~~~~~~
      |                                                                          |            |
      |                                                                          int          const char [9]
a.cc:82:121: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   82 |                                 DOUT << "[NG] switches = " << bitset<12>(switches) << ", Sbits="<< bitset<12>(Sbits[m]) << endl;
      |                                                                                                              ~~~~~~~~~~~^~~~~~~
a.cc:88:55: error: 'bitset' was not declared in this scope
   88 |                         DOUT << "[OK] switches = " << bitset<12>(i)<< endl;
      |                                                       ^~~~~~
a.cc:88:55: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
a.cc:88:68: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   88 |                         DOUT << "[OK] switches = " << bitset<12>(i)<< endl;
      |                                                                 ~~~^~~~~~~