#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using graph = vector<vector<int>>;
int main() {
  int n, m;
  cin >> n >> m;
  graph v(m);
  for (ll i = 0; i < (ll)(m); i++) {
    int k;
    cin >> k;
    for (ll j = 0; j < (ll)(k); j++) {
      int s;
      cin >> s;
      s--;
      v[i].push_back(s);
    }
  }
  vector<int> p(m);
  for (ll i = 0; i < (ll)(m); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> bs(tmp);
    int c = 0;
    bool b = true;
    for (ll i = 0; i < (ll)(m); i++) {
      for (int j : v[i]) {
        c += bs[j];
      }
      c %= 2;
      if (c != p[i]) {
        b = false;
        break;
      }
    }
    if (b) {
      ans++;
    }
  }
  int x = pow(2, 10 - n);
  cout << ans / x;
}
