#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) {
    return x;
  } else {
    return gcd(y, x % y);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  int s[11][11];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    cout << k[i] << endl;
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bits = 0; bits < (1 << n); bits++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < k[i]; j++) {
        if (bits & (1 << (s[i][j] - 1))) {
          count++;
        }
      }
      if (count % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
