#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int sj;
      cin >> sj;
      sj--;
      s[i][sj]++;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < 1 << n; bit++) {
    vector<int> ons(n);
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        ons[i]++;
      }
    }
    int onsum = 0;
    for (int i = 0; i < m; i++) {
      int temp = 0;
      for (int j = 0; j < n; j++) {
        if (s[i][j] > 0 & ons[j] > 0) {
          temp++;
        }
      }
      if (p[i] == temp % 2) onsum++;
    }
    if (onsum == m) {
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
