#include <bits/stdc++.h>
using namespace std;
void bin_vecadd(vector<int> &input) {
  int N = input.size();
  input[0]++;
  for (int i = 0; i < N; i++) {
    if (input[i] == 2) {
      input[i] = 0;
      input[i + 1]++;
    }
  }
}
int main(int argc, char const *argv[]) {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > mat;
  vector<int> switch_param(M, 0);
  int k = 0;
  for (int i = 0; i < M; i++) {
    cin >> k;
    vector<int> vec(k, 0);
    for (int j = 0; j < k; j++) {
      cin >> vec[j];
    }
    mat.push_back(vec);
  }
  for (int i = 0; i < M; i++) {
    cin >> switch_param[i];
  }
  int count = 0;
  int loop = int(pow(2, N));
  vector<int> switch_vec(N, 0);
  int ans_num = 0;
  int check_signal = 1;
  int light_sum = 0;
  for (int i = 0; i < loop; i++) {
    for (int j = 0; j < M; j++) {
      for (int k = 0; k < mat[j].size(); k++) {
        light_sum += switch_vec[mat[j][k] - 1];
      }
      if (light_sum % 2 != switch_param[j]) {
        check_signal = 0;
      }
      light_sum = 0;
    }
    if (check_signal == 1) {
      ans_num++;
    } else {
      check_signal = 1;
    }
    bin_vecadd(switch_vec);
  }
  cout << ans_num;
  return 0;
}
