#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> km(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    km[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> km[i][j];
      km[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int cmb = 0;
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0;
    bool cortCombi = true;
    for (int j = 0; j < m; j++) {
      for (int swi : km[j]) {
        if ((i >> swi) & 1) {
          cnt++;
        }
      }
      cnt %= 2;
      if (cnt != p[j]) {
        cortCombi = false;
      }
    }
    if (cortCombi) {
      cmb++;
    }
  }
  cout << cmb << endl;
  return 0;
}
