#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  std::vector<int> bulb[10];
  std::vector<int> mod;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      bulb[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    mod.push_back(i);
  }
  int result = 0;
  for (int state = 0; state < (1 << n); state++) {
    bool all_on = true;
    for (int i = 0; i < m; i++) {
      std::vector<int> tgt_bulb = bulb[i];
      int on_count = 0;
      for (auto x : tgt_bulb) {
        int mask = 1 << (x - 1);
        if (mask & state) {
          on_count++;
        }
      }
      if (on_count % 2 != mod[i]) {
        all_on = false;
        break;
      }
    }
    if (all_on) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}
