#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m;
	int k[10], s[10][10], p[10];
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int i = 0; i < pow(2, n); i++) {
		bool on = true;
		for (int j = 0; j < m; j++) {
			int num = 0;
			for (int n = 0; n < k[j]; n++) {
				int tmp;
				tmp = i & (int)pow(2,s[j][n]);
				if (tmp != 0)num++;
			}
			if (num % 2 != p[j]) {
				on = false;
				break;
			}
		}
		if (on) ans++;
	}

	cout << ans << endl;

}