#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(bit)

using namespace std;

int main(void){
  int N,M,count=0,check=0,ans=0;
  cin >> N >> M;
  int k[M];
  int s,p[M];
  int bit[M]={};
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s;
      bit[i]+=Flag(s-1);
    }
  }
  rep(i,M) cin >> p[i];
  for(int i=0;i<Flag(N);i++){
    count=0,check=0;
    for(int j=0;j<M;j++){
      for(int k=0;k<N;k++){
        if(i&bit[j]&Flag(k)) count++;
      }
      if(count%2!=p[j]){
        check=1;
        break;
      }
    }
    if(check==0) ans++;
  }
  cout << ans << endl;
}