#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<vector<bool> > s(m, vector<bool>(n + 1, false));
	vector<int> p(m);
	for (int i = 0; i < m; ++i) {
		int k; cin >> k;
		for (int j = 0; j < k; ++j) {
			int t; cin >> t;
			s[i][t] = true;
		}
	}
	for (int i = 0; i < m; ++i) cin >> p[i];

	int ans = 0;
	vector<int> swio (n);
	for (int i = 0; i < (int)pow(2, n); ++i) {
		int tmp = i;
		for (int j = 0; j < n; ++j) {
			swio[j] = tmp % 2;
			tmp /= 2;
		}
		bool flag = true;
		for (int j = 0; j < m; ++j) {
			int cnt = 0;
			for (int k = 1; k <= n; ++k) {
				if (swio[k - 1] && s[j][k]) cnt++;
			}
			if (cnt % 2 != p[j]) {
				flag = false;
				break;
			}
		}
		if (flag) ans++;
	}
	cout << ans << endl;


	return 0;
}