#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  int n,m; cin>>n>>m;
  int k[m]={},s[m][n]={},p[m]={};
  REP(i,m){
    cin>>k[i];
    REP(j,k[i]) cin>>s[i][j];
  }
  REP(i,m) cin>>p[i];
  
  int ans=0;
  REP(bit,1<<n){
    int t[n]={};
    REP(i,n) t[i]=(bit>>i)&1;
    
    bool judge=true;
    int cnt=0;
    REP(i,m){
      REP(j,k[i]) cnt+=t[s[i][j]-1];
      if(cnt%2==p[i]) continue;
      else judge=false;
    }
    if(judge==true) ans++;  
  }
  cout<<ans<<endl;
}