#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bitset<10>> ss(m);
  for (int i = 0; i < m; i++) {
    bitset<10> bit("0000000000");
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      bit.set(p - 1);
    }
    ss[i] = bit;
  }
  int cnt = 0;
  vector<int> ps(m);
  for (int i = 0; i < m; i++) cin >> ps[i];
  for (int i = 0; i < (1 << n); i++) {
    bitset<10> cmb(i);
    for (int j = 0; j < m; j++) {
      bitset<10> b = ss[j];
      if (!((int)(cmb & b).count() % 2 == ps[j])) break;
      if (j == n - 1) cnt++;
    }
  }
  cout << cnt << endl;
}
