#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,k[10],s[10][10],p[10],A[10],ans=0;
  cin>>n>>m;
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]) cin>>s[i][j];
  }
  rep(i,m) cin>>p[i];
  rep(i,pow(2,n)){
    int x=i,y=0;
    rep(j,n) A[j+1]=x%2,x=x/2;
    rep(j,m){
      int z=0;
      rep(K,n){
        rep(l,k[j]) if(A[K+1]&&s[j][l]==K+1) z++;
      }
      if(z%2==p[j]) y++;
    }
    if(y==m) ans++;
  }
  cout<<ans;
}
