#include<bits/stdc++.h>

using namespace std;
 

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

void Solve(){
  int n,m;
    scanf("%d%d",&n,&m);
  vector<vector<int>> A(m,vector<int>(10));

  for(int i=0;i<m;++i){
    int k;
      scanf("%d",&k);
    for(int j=0;j<k;++j){
      int a;
        scanf("%d",&a);
      A[i][a-1]++;
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;++i){
    scanf("%d",&p[i]);
  }

  int ans=0;
  for(int bit=0;bit<(1<<n);++bit){
    bool b=true;
    for(int i=0;i<m;++i){
      int s=0;
      for(int j=0;j<10;++j){
        if(bit &(1<<j)){
          s+=A[i][j];
        }
      }
      if(s%2!=p[i]){
        b=false;
      }
    }
    if(b){
      ++ans;
    }
  }
  printf("%d\n",ans);
}