#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  vector<int> k(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      int sw;
      cin >> sw;
      sw--;
      s[i].push_back(sw);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<10> sw(tmp);
    int sum_m = 0;
    for (int j = 0; j < (int)(M); j++) {
      int sum_k = 0;
      for (int l = 0; l < (int)(k[j]); l++) {
        for (int i = 0; i < (int)(N); i++) {
          if (s[j][l] == i && sw.test((i) == 1)) {
            sum_k++;
          }
        }
      }
      if (sum_k % 2 == p[j]) sum_m++;
    }
    if (sum_m == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
