#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;

  int s[N] = {0};
  int d[M][N] = {0};
  int p[M];
  int k;
  int ins;
  int count = 0;
  int sum;
  int tmp;
  int flug;
  int max;

  for(int i=0;i<M;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> ins;
      d[i][ins] = 1;
    }
  }

  for(int i=0;i<M;i++){
    cin >> p[i];
  }
  max = pow(2,N);

  for(int i=0;i<max;i++){
    tmp = i;
    flug = 1;
    for(int j=0;j<N;j++){
      s[j] = tmp % 2;
      tmp /= 2;

    }

    for(int j=0;j<M;j++){
      sum = 0;
      for(int k=0;k<N;k++){
        if(d[j][k] == 1){
          sum += s[k];
        }
      }
      if(sum%2 != p[j]) {
        flug = 0;
        break;
      }

    }

    if(flug == 1) count++;
  }

  cout << count << endl;

}