#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include <numeric>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k(m), p(m);
	vector<vector<int>> s(m);
	rep(i, m) {
		cin >> k[i];
		s[i].resize(k[i]);
		rep(j, k[i]) {
			cin >> s[i][j]; --s[i][j];
	}
	rep(i, m)cin >> p[i];
	int ans = 0;
	rep(i, 1 << n) {
		bool ok = true;
		rep(j, m) {
			int c = 0;
			for (int id : s[j]) {
				if (i >> id & 1)++c;
			}
			if (c % 2 != p[j]) ok = false;
		}
		if (ok)++ans;
	}
	cout << ans;
}
	