#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int mod = 1e+9 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> a(m, vector<long long>(100));
  vector<long long> p(n);
  for (int i = 0; i < (m); ++i) {
    long long k;
    cin >> k;
    a[i].resize(k);
    for (int j = 0; j < (k); ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  long long A = 0;
  for (long long tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> b(tmp);
    long long cnt = 0;
    long long ans = 0;
    for (int i = 0; i < (m); ++i) {
      for (int j = 0; j < (a[i].size()); ++j) {
        if (b.test(a[i][j] - 1)) cnt++;
      }
      if (cnt % 2 == p[i]) ans++;
    }
    if (ans == m) A++;
  }
  cout << A << endl;
}
