#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int n,m;
	cin>>n>>m;
	int dp[10][10]={};
	rep(i,m){
		int k;
		cin>>k;
		rep(j,k){
			int s;
			cin>>s;
			dp[s-1][i]=1;
		}
	}
	int p[m]={};
	rep(i,m)cin>>p[m];
	int res=0;
	rep(i,(1<<n)){
		int d[m]={};
		rep(j,n){
			if((i&(1<<j))>0){
				rep(k,m){
					d[k]+=dp[j][k];
				}
			}
		}
		bool flg=true;
		rep(k,m){
			if(p[k]!=(d[k]%2))flg=false;
		}
		if(flg)res++;

	}
	cout<<res<<endl;
	return 0;
}
