#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)

int n;
int m;
int k[15];
int s[15][15];
int p[15];

int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> k[i];
		rep(j, k[i]) cin >> s[i][j];
	}
	rep(i, m) cin >> p[i];
	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		bool G = true;
		rep(i, m) {
			int sum = 0;
			rep(j, k[i]) {
				if (bit & (1 << s[i][j] - 1)) {
					sum++;
				}
			}
			if (sum % 2 != p[i]) G = false;
		}
		if (G) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
