#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  int k[m][n];
  rep(i,m){
    rep(j,n){
      k[i][j]=0;
    }
  }
  rep(i,m){
    int y;
    cin >> y;
    rep(j,y){
      int r;
      cin >> r;
      k[i][r-1]=1;
    }
  }
  int p[m];
  rep(i,m)cin >> p[i];
  int cnt=0;
  rep(i,(1<<n)){
    int c=0;
    rep(j,m){
      int q=0;
      rep(w,n){
        if(k[j][w]==1&&(i&(1<<w))){
          q++;
        }
      }
      if(q%2!=p[j])c=1;
    }
    if(c==0)cnt++;
  }
  cout << cnt << endl;
}  
