#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll n,m;
vector<ll> v[22];
ll p[22];
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
      ll k;cin>>k;
      for(int j=0;j<k;j++){
	  ll x;cin>>x;
	  v[i].push_back(x-1);
      }
  }
  for(int i=0;i<m;i++)cin>>p[i];
  ll ans=0;
  for(int i=0;i<(1<<n);i++){
      bool ok=1;
      for(int j=0;j<m;j++){
	  ll cnt=0;
	  for(auto t:v[j]){
	      if((1<<t)&i)cnt++;
	  }
	  if(cnt%2!=p[j])ok=0;
      }
      ans+=ok;
  }
  cout<<ans<<endl;
  return 0;
}
