#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;


#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back

int main(){
    ll n, m, tmp; cin >> n >> m;
    vector<ll> sw(n);
		rep(i,m) {
			ll k;
			cin >> k;
			rep(j,k) {
				int s;
				cin >> s;
				s--;
				sw[s] |= 1<<i;
			}
		}
    
    ll p = 0;
    rep(i, m) {
		int x;
		cin >> x;
		p |= x<<i;
	}
 
	ll ans = 0;
    for (int s = 0; s < (1<<n); s++) {
		int t = 0;
		for (int i = 0; i < n; i++) {
				if (s>>i & 1) t ^= sw[i];
		}
		if (t == p) ans++;
	}
 
	cout << ans << endl;
} namespace std;
using ll = long long;
using P = pair<ll, ll>;


#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back

int main(){
    ll n, m, tmp; cin >> n >> m;
    vector<ll> sw(n);
		rep(i,m) {
			ll k;
			cin >> k;
			rep(j,k) {
				int s;
				cin >> s;
				s--;
				sw[s] |= 1<<i;
			}
		}
    
    ll p = 0;
    rep(i, m) {
		int x;
		cin >> x;
		p |= x<<i;
	}
 
	ll ans = 0;
    for (int s = 0; s < (1<<n); s++) {
		int t = 0;
		for (int i = 0; i < n; i++) {
				if (s>>i & 1) t ^= sw[i];
		}
		if (t == p) ans++;
	}
 
	cout << ans << endl;
}