#include <iostream>
using namespace std;

int n, m, k[11], s[11], t, p[11], ans;
bool f;

int numberOfSetBits(int i){
	if (i <= 1) return i;
	else return numberOfSetBits(i >> 1) + (i % 2);
}

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

	ans = 0;
	for (int i = 0; i < (1 << n); ++i){
		f = true;
		for (int j = 0; j < m; ++j){
			if (numberOfSetBits(s[j] & i) % 2 != p[j]){
				f = false;
				break;
			}
		}
		if (f) ans++;
	}
	cout << ans;
}