#include <bits/stdc++.h>
using namespace std;
const long long mei = (long long)1e9 + 7;
int main() {
  long long n, m, a, b;
  cin >> n >> m;
  vector<vector<long long>> c(m, vector<long long>(0));
  vector<long long> d(m);
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> a;
    for (long long j = 0; j < (long long)(a); j++) {
      cin >> b;
      c[i].push_back(b - 1);
    }
  }
  a = 0;
  bool h;
  for (long long i = 0; i < (long long)(m); i++) cin >> d[i];
  for (long long te = 0; te < (long long)(1 << 10); te++) {
    bitset<10> s(te);
    h = true;
    for (long long i = 0; i < (long long)(m); i++) {
      b = 0;
      for (long long j = 0; j < (long long)(c[i].size()); j++) {
        if (s.test(c[i][j])) b++;
      }
      if (b % 2 != d[i]) h = false;
    }
    if (h) a++;
  }
  cout << a;
  cout << endl;
}
