#include <bits/stdc++.h>
using namespace std;
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long power(long long x, long long n, long long mod = MOD) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) {
      (ret *= x) %= mod;
    }
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
vector<long long> make_power(int n, long long base) {
  long long num = 1;
  vector<long long> ret;
  for (int i = 0; i <= n; ++i) {
    ret.push_back(num);
    num *= base;
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<long long> k(m);
  vector<vector<long long>> s(m);
  for (int i = (0); i < (m); i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = (0); j < (k[i]); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<long long> p(m);
  for (int i = (0); i < (m); i++) {
    cin >> p[i];
  }
  long long ans = 0;
  long long all = power(2, n);
  vector<int> push(m, 0);
  bitset<10> b;
  for (int i = (0); i < (all); i++) {
    b = static_cast<bitset<10>>(i);
    for (int j = (0); j < (m); j++) {
      push[j] = 0;
    }
    for (int j = (0); j < (m); j++) {
      for (int l = (0); l < (k[j]); l++) {
        if (b[l] == 1) {
          push[j]++;
        }
      }
    }
    int count = 0;
    for (int j = (0); j < (m); j++) {
      if (push[j] % 2 == p[j]) {
        count++;
      }
    }
    if (count == m) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
