#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
bool is_int_lround(double x) { return std::lround(x) == x; }
int ketasuu(int x) {
  int n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}
ll gcd11(ll x, ll y) {
  long long a = max(x, y), b = min(x, y), c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}
int abs(int x, int y) {
  if (x >= y) {
    return x - y;
  } else if (y > x) {
    return y - x;
  }
}
int fiv(int n) {
  if (n == 0) {
    return 0;
  } else if (n == 1) {
    return 1;
  }
  return fiv(n - 1) + fiv(n - 2);
}
ll conbi(int n, int m) {
  cin >> n >> m;
  vector<ll> a(100);
  a[0] = 1;
  for (int i = 0; i < 14; i++) {
    a[i + 1] = a[i] * (i + 1);
  }
  return a[n] / (a[m] * a[n - m]);
}
int main() {
  int n, m;
  cin >> n >> m;
  vvi s(10, vi(10));
  ;
  for (int i = 0; i < m; i++) {
    cin >> s[i][0];
    for (int j = 1; j <= s[i][0]; j++) {
      cin >> s[i][j];
    }
  }
  vi p(m);
  ;
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<11> light(tmp);
    vi o(m, 0);
    ;
    for (int i = 0; i < m; i++) {
      for (int j = 1; j <= s[i][0]; j++) {
        if (light.test(s[i][j] - 1)) {
          o[i]++;
        }
      }
    }
    bool res = true;
    ;
    for (int i = 0; i < m; i++) {
      if (o[i] % 2 != p[i]) {
        res = false;
      }
    }
    if (res) ans++;
  }
  cout << ans << endl;
}
