#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<sstream>
#include<bitset>

using namespace std;
using ll = long long int;

vector<int> sw;
vector<int> s[10], p, kk;
int n, m;

vector<int> dfs(int a) {
	vector<int> ret;
	stringstream ss;
	ss << bitset<10>(a);
	string tmp = ss.str();
	for (int i = 10 - n; i < 10; i++) {
		ret.push_back(int(tmp[i]) - int('0'));
	}
	return ret;
}

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int ki;
		cin >> ki;
		kk.push_back(ki);
		for (int j = 0; j < ki; j++) {
			int sij;
			cin >> sij;
			s[i].push_back(sij-1);
		}
	}

	for (int j = 0; j < m; j++) {
		int pj;
		cin >> pj;
		p.push_back(pj);
	}

	sw = vector<int>(n, 0);
	int ret = 0;
	for (int i = 0; i < pow(2, n); i++) {
		sw = dfs(i);
		bool flag = true;
		for (int j = 0; j < m; j++) {
			int tmp = 0;
			for (int k = 0; k < kk[j]; k++) {
				tmp += sw[s[j][k]];
			}
			if (tmp % 2 != p[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ret++;
		}
	}
	cout << ret << endl;
	return 0;

}