#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vvs;
  vector<int> vp;
  vector<int> vc;
  for (int i = 1; i <= m; i++) {
    vector<int> vs;
    for (int j = 0; j < n; j++) {
      vs.push_back(0);
    }
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      vs[s - 1] = 1;
    }
    vvs.push_back(vs);
  }
  for (int i = 1; i <= m; i++) {
    int p;
    cin >> p;
    vp.push_back(p);
    vc.push_back(0);
  }
  int s = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < m; j++) {
      vc[j] = 0;
    }
    int idx = 0;
    int tmpI = i;
    while (idx < n) {
      if (tmpI & 1) {
        for (int j = 0; j < m; j++) {
          if (vvs[j][idx]) {
            vc[j] += 1;
          }
        }
      }
      tmpI >>= 1;
      idx++;
    }
    bool isOn = true;
    for (int j = 0; j < m; j++) {
      isOn = isOn && (vp[j] == (vc[j] % 2));
    }
    if (isOn) {
      s++;
    }
  }
  cout << s << endl;
  return 0;
}
