#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;

int m
ain() {
	int n, m;
	cin >> n >> m;
	vector<vector<int> > vec(m);
	vector<int> P(m);
	rep(i, m) {
		int k;
		cin >> k;
		vector<int> S(k);
		rep(i, k) cin >> S.at(i);
		vec.at(i) = S;
	}
	rep(i, m) cin >> P.at(i);

	int ans = 0;
	rep(k, pow(2, n)) {
		bool counter = true;
		rep(i, m) {
			int sum = 0;
			rep(j, vec.at(i).size()) {
				if ((1<<vec.at(i).at(j)-1) & k) sum++;
			}
			if (sum%2!=P.at(i)) counter = false;
		}
		if (counter==true) ans += 1;
	}
	cout << ans << endl;
}