#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M);
  for (int i = 0; i < M; ++i) {
    cin >> k[i];
    s[i] = vector<int>(k[i]);
    copy_n(istream_iterator<int>(cin), k[i], s[i].begin());
  }
  vector<int> p(M);
  copy_n(istream_iterator<int>(cin), M, p.begin());
  int result = 0;
  int pattern_num = 1 << N;
  for (int onoff = 0; onoff < pattern_num; ++onoff) {
    int shine = true;
    for (int i = 0; i < M; ++i) {
      int chk = 0;
      for (int j = 0; j < k[i]; ++j) {
        chk += ((onoff >> j) & 1);
      }
      if ((chk & 1) != p[i]) {
        shine = false;
        break;
      }
    }
    result += shine;
  }
  cout << result << endl;
  return 0;
}
