#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
template <typename T>
T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v) {
  for (size_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (size_t k = 1; k < v.size(); k++) {
    for (size_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}
ll repeat_squaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    ll t = repeat_squaring(n, p / 2, m);
    return t * t % m;
  }
  return n * repeat_squaring(n, p - 1, m);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (size_t i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (size_t j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (int)m; i++) cin >> p[i];
  size_t ans = 0;
  for (size_t bit = 0; bit < pow(2, n) + 1; bit++) {
    vector<bool> v(n, false);
    for (size_t i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        v[i] = true;
      }
    }
    bool is_ok = true;
    for (size_t i = 0; i < m; i++) {
      int tmp = 0;
      for (size_t j = 0; j < s[i].size(); j++) {
        tmp += v[s[i][j]];
      }
      if (tmp % 2 != p[i]) {
        is_ok = false;
        break;
      }
    }
    if (is_ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
