/*************************
author : coldbeer
2019-05-26 05:46:46 PM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

typedef long long ll;
vector<set<ll>> bulb(11,set<ll>());
vector<ll> sw(10,0);
vector<ll> sub[1<<11];
vector<ll> p(11,0);

ll main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n,m; cin >> n >> m;
	for(ll i = 0;i < n;i++) sw[i] = i + 1;
	for(ll i = 0;i < m;i++){
		ll k; cin >> k;
		for(ll j = 0;j < k;j++){
			ll item;
			cin >> item;
			bulb[i + 1].insert(item);
		}
	}

	for(ll i = 0;i < (1<<n);i++){
		vector<ll> temp;
		for(ll j = 0;j < n;j++){
			if(i & (1 << j))
				temp.push_back(sw[j]);
		}
		if(temp.size())
			sub[i] = temp,temp.clear();
	}

	for(ll i = 0;i < m;i++) cin >> p[i + 1];

	ll ans = 0;
	for(ll i = 0;i < (1 << n);i++){
		if(sub[i].size()){
			vector<ll> cnt(11,0);
			for(ll x : sub[i]){
				for(ll cx = 1;cx < m + 1;cx++){
					if(bulb[cx].count(x)){
						cnt[cx]++;
					}
				}
			}
			ll ctr = 0;
			for(ll z = 1;z < m + 1;z++)
				if((cnt[z] % 2)== p[z]) ctr++;
			if(ctr == m) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
