#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,K;
string s,t;

signed main()
{
	IOS();
	cin>>N>>M;
	int ans = 0;
	int k[M][N]={};
	rep(i,0,M){
		int t ;
		cin>>t;
		rep(j,0,t){
			int tt;
			cin>>tt;
			k[j][tt-1]=true;
		}
	}
	vector<int>p(M);
	for(int i = 0;i < M;i++){
		cin>>p[i];
	}
	rep(i,0,1ll<<N){
		int flg = 1;
		rep(l,0,M){
			int cnt = 0;
			rep(j,0,N){
				if((i&(1ll<<j))&&k[l][j])cnt++;
			}
			if(cnt%2!=p[l]){
				flg = 0;
				break;
			}
		}
		if(flg)ans++;
	}
	cout<<ans<<endl;
}