#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { a / gcd(a, b) * b; }
const long long mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int rep = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (auto v : s[i]) {
        if (bit < (1 << v)) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) rep++;
  }
  cout << rep << endl;
}
