#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
signed main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  vector<long long> s[14];
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long a;
      cin >> a;
      s[a - 1].push_back(i);
    }
  }
  long long p[14];
  for (long long i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (long long i = 0; i < (1 << n); i++) {
    long long bit[114];
    for (long long j = 0; j < n; j++) {
      bit[j] = i / (1 << j) % 2;
    }
    long long cnt[14];
    fill(cnt, cnt + m, 0);
    for (long long j = 0; j < n; j++) {
      if (bit[j] == 1) {
        for (long long k = 0; k < s[j].size(); k++) {
          if (cnt[k] == 1)
            cnt[k] = 0;
          else
            cnt[k] = 1;
        }
      }
    }
    bool bou = true;
    for (long long i = 0; i < m; i++) {
      if (cnt[i] != p[i]) {
        bou = false;
        break;
      }
    }
    if (bou) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
