#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch : s) {
    if (ch == delim) {
      if (!item.empty()) elems.push_back(item);
      item.clear();
    } else {
      item += ch;
    }
  }
  if (!item.empty()) elems.push_back(item);
  return elems;
}
bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
  if (get<2>(a) != get<2>(b)) {
    return get<2>(a) > get<2>(b);
  }
}
bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
  if (get<1>(a) != get<1>(b)) {
    return get<1>(a) < get<1>(b);
  } else {
    return get<2>(a) > get<2>(b);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> ks(M);
  for (int i = 0; i < M; i++) {
    int num;
    cin >> num;
    ks[i].reserve(num);
    for (int s = 0; s < num; s++) {
      int ss;
      cin >> ss;
      ks[i][s] = ss - 1;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 >> N); i++) {
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int t = 0;
      for (int k = 0; k < ks[j].size(); k++) {
        cerr << (i >> ks[j][k]) << endl;
        t += (i >> ks[j][k]) & 1;
      }
      if (t % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
