#include <bits/stdc++.h>
using namespace std;
int count_bit(int chk_bit, int bit_num) {
  int count = 0;
  for (int i = 0; i < bit_num; i++) {
    if (chk_bit & (1 << i)) count++;
  }
  return count;
}
int main(void) {
  int N, M = 0;
  int pattern = 0;
  cin >> N >> M;
  std::vector<int> light_flag(M);
  std::vector<int> p_i(M);
  int k = 0;
  int tmp_sij_bit = 0;
  for (int light_i = 0; light_i < M; light_i++) {
    cin >> k;
    light_flag[light_i] = 0;
    for (int j = 0; j < k; j++) {
      cin >> tmp_sij_bit;
      light_flag[light_i] |= (1 << (tmp_sij_bit - 1));
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p_i[i];
  }
  for (int chk_sij_bit = 1; chk_sij_bit < pow(2, N); chk_sij_bit++) {
    int flag = 0;
    for (int light_i = 0; light_i < M; light_i++) {
      if ((count_bit((light_flag[light_i] & chk_sij_bit), N)) % 2 ==
          p_i[light_i]) {
        flag++;
      } else {
        break;
      }
    }
    if (flag == M) {
      pattern++;
    }
  }
  cout << pattern << endl;
  return 0;
}
