#include <iostream>
#include <cstdio>
#include <vector>
#define N 15
using namespace std;

int n, m, k, c, ans, p[N];
vector<int> s[N];
int main()
{
	int i, j, x, t;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d", &k);
		for (j = 0; j < k; j++) {
			scanf("%d", &t);
			s[i].push_back(t - 1);
		}
	}
	for (i = 0; i < m; i++) scanf("%d", &p[i]);
	for (x = 0; x < 1 << n; x++) {
		for (i = 0; i < m; i++) {
			c = 0;
			for (j = 0; j < s[i].size(); j++) {
				if (x & (1 << s[i][j])) c++;
			}
			if (c % 2 != p[i]) break;
		}
		if (i == m) ans++;
	}
    cout << ans << endl;
    return 0;
}