#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) {
  if (x > y)
    return x;
  else
    return y;
}
long long min(long long x, long long y) { return x + y - max(x, y); }
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> k(m);
  vector<vector<long long>> s(m, vector<long long>(10));
  vector<long long> p(m);
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> k[i];
    for (long long j = 0; j < (long long)(k[i]); j++) cin >> s[i][j];
  }
  for (long long i = 0; i < (long long)(m); i++) cin >> p[i];
  int answer = 0;
  int pow2 = 1;
  for (long long i = 0; i < (long long)(n); i++) pow2 *= 2;
  for (long long ii = 0; ii < (long long)(pow2); ii++) {
    bitset<10> ans(ii);
    bool can = true;
    for (long long i = 0; i < (long long)(m); i++) {
      int cnt = 0;
      for (long long j = 0; j < (long long)(k[i]); j++) {
        if (ans.test(j)) cnt++;
      }
      if (cnt % 2 != p[i]) {
        can = false;
        break;
      }
    }
    if (can) answer++;
  }
  cout << answer << endl;
}
