#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N,M;cin>>N>>M;
  vector<vector <ll> > s(M);
  vector<ll> p;
  ll i,j,k,l;
  ll ans=0;
  rep(i,M){
    ll a;cin>>a;
    rep(j,a){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  rep(i,M){
    ll b;cin>>b;
    p.pb(b);
  }
  rep(i,1<<N){
    bool ok = true;
    rep(j,M){
      int cnt=0;
      rep(k,s[j].length()){
        if((i>>s[j][k])&1) cnt++;
      }
      if(cnt %2 != p.at(j)) ok=false;
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}
