#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m;
  vector<bitset<10>> a(m);
  vector<int> c(m);
  for (int i = 0; i < (int)(m); ++i) {
    cin >> k;
    int b;
    bitset<10> bs;
    for (int j = 0; j < (int)(k); ++j) {
      cin >> b;
      bs.set(b);
    }
    a[i] = bs;
  }
  for (int i = 0; i < (int)(m); ++i) {
    cin >> c[i];
  }
  int sum = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    for (int i = 0; i < (int)(m); ++i) {
      if (c[i] != (int)(a[i] & (bitset<10>)bit).count() % 2) {
        sum--;
        break;
      }
    }
    sum++;
  }
  cout << sum;
}
