#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);



int main(){
  faster();
  int n,m,s,ans=0;
  cin >> n >> m;
  vvi cond(m,vi(m,-1));
  vi p(m),k(m);
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> cond[i][j];
    }
  }
  rep(i,m) cin >> p[i];

  for(int i=0;i<(1<<n);i++){
    bool flag = true;
    rep(j,m){
      int cnt=0;
      rep(l,k[j]){
        if(i&(1<<cond[j][l])) cnt++;
      }
      if(p[j]==0){
        if(cnt%2!=0) flag = false;
      }
      if(p[j]==1){
        if(cnt%2==0) flag = false;
      }
    }
    if(flag) ans++;
  }

  cout << ans << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

