#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)

int main(){

  ll n,m;
  cin>>n>>m;
  vector<ll> k(m),p(m);
  vector<set<ll>> s(m);
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]){
      ll x;
      cin>>x;
      x--;
      s[i].insert(x);
    }
  }
  rep(i,m)cin>>p[i];

  ll ans=0;
  for(ll b=0;b<(1LL<<n);++b){
    bitset<16> bit(b);
    vector<ll> a(m);
    rep(k,12){
      if(bit[k]){
        rep(i,m){
          if(s[i].find(k)!=s[i].end())a[i]++;
        }
      }
    }
    rep(i,m)a[i]%=2;
    if(p==a)ans++;
  }
  cout<<(ans)<<endl;

}