#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int k[m],p[m];
  rep(i,m){
    cin>>k[i];
    int s[i][k[i]];
    rep(j,k[i]){
      cin>>s[i][j];
    }
  }
  rep(i,m){
    cin>>p[i];
  }
  int memo[n];
  int ans=0;
  rep(i,pow(2,n)){
    int cri=1;
    rep(j,n){
      memo[j]=i^(int)(pow(2,j));
    }
    rep(j,m){
      int count=0;
      rep(l,k[j]){
        count+=memo[s[j][l]];
      }
      if(count%2!=p[j]){
        cri=0;
      }
    }
    if(cri){
      ans++;
    }
  }
  cout<<ans;
}
