#include<bits/stdc++.h>
#define REP(i,n) fot(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
typedef long long LL;
const double INF = 1e9;
using namespace std;
int binary(int bina){
  int ans =0;
  for(int i=0;bina>0;i++){
    ans = ans+(bina%2)*pow(10,i);
    bina = bina/2;
  }
  return ans;
}
int main(){
  int N,M;
  cin>>N>>M;
  int k[M];
  int s[10][10];
  REP(int i,M){
  cin>>k[i];
  for(int j=0;j<k[i];j++){
  cin>>s[i][j];
  }
}
  int p[M];
  REP(int i,M){
    cin>>p[i];
  }
  int ans=0;
  REP(int i,1024){
    bool judge = true;
    REP(int a,M){
      int sum=0;
      REP(int b,k[a]){
        sum+=(binary[i]%pow(10,s[a][b]))/pow(10,s[a][b]);
      }
      if(sum%2!=p[a]){
        judge=false;
      }
    }
    if(judge){
      ans++;
    }
  }
  cout<<ans;
}
    
        