#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
bool f(pair<string, int> a, pair<string, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  }
  return a.second > b.second;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> l(m);
  vector<int> p(m);
  for (long long i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (long long j = 0; j < k; ++j) {
      int s;
      cin >> s;
      l[i].push_back(s - 1);
    }
  }
  for (long long i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (long long i = 0; i < 1 << n; ++i) {
    bool ok = true;
    vector<int> s(n);
    for (long long j = 0; j < n; ++j) {
      if (i >> j & 1) s[j] = 1;
    }
    for (long long j = 0; j < m; ++j) {
      int e = 0;
      for (int x : l[j]) e ^= s[x];
      if (e != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
