#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const double pi = acos(-1.0);
int main(void) {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> s;
  for (int i = 0; i < (m); ++i) {
    long long k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      long long a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<long long> p(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      long long cnt = 0;
      for (auto on : s[i]) {
        if (1 & (1 << on)) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans << endl;
  return 0;
}
