#include <vector>
#include <bitset>
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;

	vector<bitset<10>> combs(m, bitset<10>(0));

	for (int i = 0; i < m; i++) {
		int cnt;
		cin >> cnt;

		for (int j = 0; j < cnt; j++) {
			int toggle;
			cin >> toggle;

			combs[i][toggle-1] = 1;
		}
	}

	vector<int> cong(m, 0);
	for (int i = 0; i < m; i++) {
		cin >> cong[i];
	}

	int cnt = 0;
	int maxNum = pow(2, n) - 1;
	for (int i = 0; i <= maxNum; i++) {
		bitset<10> test(i);
		int onCnt = 0;
		for (int j = 0; j < m; j++) {
			int switchOn = 0;
			for (int k = 0; k < n; k++) {
				if (test[k] == 1 && combs[j][k] == 1) switchOn++;
			}

			if (switchOn % 2 == cong[j]) onCnt++;
		}

		if (onCnt == m) cnt++;
	}

	cout << cnt;

	return 0;
}