#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;
int main() {
  int n, m;
  cin >> n >> m;
  vi k(m);
  Mat s(m);
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) {
      int s_;
      cin >> s_;
      s[i].push_back(s_);
    }
  }
  vi p(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  bool can = true;
  int ans;
  for (int t = 0; t < (1 << n); ++t) {
    can = true;
    bitset<10> ss = t;
    for (int i = 0; i < m; ++i) {
      int sum = 0;
      for (int j = 0; j < k[i]; ++j) {
        if (ss.test(s[i][j] - 1)) sum += 1;
      }
      if (p[i] != sum % 2) {
        can = false;
        break;
      }
    }
    if (can) ans += 1;
  }
  cout << ans << endl;
  return 0;
}
