//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,m;cin>>n>>m;
  vl k(m);
  vvl s(m,vl);
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]){
      ll t;cin>>t;
      t--;
      s[i].push_back(t);
    }
  }
  vl p(m);
  rep(i,m)cin>>p[i];
  ll count=0;
  rep(bit,1<<n){
    ll part=0;
    rep(i,m){
      ll sum=0;
      rep(j,k[i]){
        if(1<<s[i][j]&bit)sum+=1;
      }
      if(sum%2==p[i])part++;
    }
    if(part==m)count++;
  }
  cout<<count<<endl;
}
      
  
  