#include <bits/stdc++.h>
using namespace std;
vector<int> biEdit(int num, vector<int> &swOnOff) {
  int idx = 0;
  while (true) {
    swOnOff.at(idx) = num % 2;
    num = num / 2;
    if (num == 0) {
      break;
    }
    idx++;
  }
  return swOnOff;
}
int main() {
  int N, M, K, swNumber, cnt, sum;
  bool flg;
  cnt = 0;
  sum = 0;
  flg = true;
  cin >> N >> M;
  vector<vector<int>> swtch(M);
  vector<int> p(M, 0);
  vector<int> swOnOff(N, 0);
  vector<int> liFlg(M, false);
  for (int i = 0; i < M; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> swNumber;
      swtch.at(i).push_back(swNumber);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p.at(i);
  }
  for (int bit = 1; bit < (1 << N); bit++) {
    swOnOff = biEdit(bit, swOnOff);
    for (int i = 0; i < swtch.size(); i++) {
      for (int j = 0; j < swtch.at(i).size(); j++) {
        sum += swOnOff.at(swtch.at(i).at(j) - 1);
      }
      if (sum % 2 == p.at(i)) {
        liFlg.at(i) = true;
      } else {
        liFlg.at(i) = false;
      }
      sum = 0;
    }
    for (int x = 0; x < liFlg.size(); x++) {
      if (!liFlg.at(x)) {
        flg = false;
      }
    }
    if (flg) {
      cnt++;
    }
    flg = true;
  }
  cout << cnt << endl;
}
