#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  long long n, m, k, c = 0, a = 0;
  cin >> n >> m;
  vector<vector<long long>> s(m);
  for (long long i = 0; i < m; i++) {
    cin >> k;
    s[i].resize(k);
    for (long long j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<long long> p(m);
  for (long long i = 0; i < m; i++) cin >> p[i];
  for (long long i = 0; i < (1 << n); i++) {
    for (long long j = 0; j < m; j++) {
      for (auto sw : s[j]) {
        if ((i >> sw) & 1) c++;
      }
      if (c % 2 != p[j]) break;
      if (j == m - 1) a++;
      c = 0;
    }
  }
  cout << a << endl;
  return 0;
}
