#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
inline void my_io() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cout << fixed << setprecision(16);
}
signed main() {
  ll n, m, k, s, p;
  ll x;
  ll cnt = 0;
  cin >> n >> m;
  vector<vector<ll>> v(m, vector<ll>(10, -1));
  vector<ll> vv;
  for (ll i = (0), __last_i = (m); i < __last_i; i++) {
    cin >> k;
    for (ll j = (0), __last_j = (k); j < __last_j; j++) {
      cin >> s;
      v[i][j] = s;
    }
  }
  for (ll i = (0), __last_i = (m); i < __last_i; i++) {
    cin >> p;
    vv.push_back(p);
  }
  ll ans = 0;
  x = pow(2, n);
  ll now, y;
  bool flag;
  while (cnt != x) {
    bitset<10> b(cnt);
    flag = true;
    for (ll i = (0), __last_i = (m); i < __last_i; i++) {
      now = 0;
      y = 0;
      while (v[i][now] > 0) {
        if (b[now]) {
          y++;
        }
        now++;
      }
      if (y % 2 != vv[i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
    cnt++;
  }
  cout << ans << endl;
}
