#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int ans,N,M;
vector<int>P;
vector<int>denki;
vector<vector<int>>K;
void kai(int a,int i){
  if(i==N){
    int kensa=0;
    rep(j,M){
      int x=0;
      rep(k,K[j].size()){
        if(denki[K[j][k]-1]==1){
          x++;
        }
      }
      if(x%2==P[j]) kensa++;
    }
    if(kensa==M)ans++;
  }
  else{
    denki[i]=a;
    kai(0,i+1);
    kai(1,i+1);
  }
}
int main (){
  cin>>N>>M;
  vector<vector<int>>Alo(M);
  P.assign(M,0);
  rep(i,M){
    int x;
    cin>>x;
    rep(j,x){
      int y;
      cin>>y;
      Alo[i].push_back(y);
    }
  }
  K=Alo;
  rep(i,M) cin>>P[i];
  denki.assign(N,-1);
  kai(1,0);
  cout<<ans/2;
}
