#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int ans=0;
int on[11];
int n,m;
void dfs(int i,vvi v,int c){
  if(c==2){
    bool b=true;
    rep(j,m){
      if(on[j]%2==1){
        b=false;
        break;
      }
    }
    if(b)ans++;
  }
  if(c==1){
    rep(j,v[i].size()){
      on[v[i][j]]++;
    }
  }
  if(i==n-1)dfs(i+1,v,2);
  if(i<n-1){
    dfs(i+1,v,1);
    dfs(i+1,v,0);
  }
}
int main(){
  cin>>n>>m;
  vector<int> v;
  rep(i,m){
    int k;
    cin>>k;
    rep(j,k){
      int a;cin>>a;
      v[a-1].push_back(i);
    }
  }
  rep(i,m){
    cin>>on[i];
  }
  dfs(-1,v,0);
  cout<<ans<<endl;
}