#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const double PI = 3.14159265358979323846;
ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ss(m, 0);
  for (ll i = 0; i < (ll)(m); i++) {
    int k;
    cin >> k;
    for (ll j = 0; j < (ll)(k); j++) {
      int s;
      cin >> s;
      ss[i] |= s;
    }
  }
  vector<int> p(m);
  for (ll i = 0; i < (ll)(m); i++) cin >> p[i];
  int ans = 0;
  int max = pow(2, n);
  for (ll i = 0; i < (ll)(max); i++) {
    int cnt = 0;
    for (ll j = 0; j < (ll)(m); j++) {
      if (p[j] == bitset<32>(i & ss[j]).count() % 2) {
        cnt++;
      }
    }
    if (cnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
