#include <bits/stdc++.h>
using namespace std;
int counter_function(int x) {
  if (x == 0) {
    return 0;
  }
  return counter_function(x >> 1) + (x & 1);
}
int main() {
  int N, M, k, on_switch_cnt, on_light_cnt, all_light;
  vector<vector<int>> s;
  vector<int> p;
  cin >> N >> M;
  s.resize(M);
  p.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  all_light = 0;
  for (int bits = 0; bits <= (1 << N); bits++) {
    on_light_cnt = 0;
    for (int i = 0; i < M; i++) {
      on_switch_cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if ((bits >> (s[i][j] - 1)) & 1) {
          on_switch_cnt++;
        }
      }
      if (on_switch_cnt % 2 == p[i]) {
        on_light_cnt++;
      }
    }
    if (on_light_cnt == M) {
      all_light++;
    }
  }
  cout << all_light << endl;
  return 0;
}
