#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (i = 0; i < m; ++i) {
    cin >> k.at(i);
    for (j = 0; j < k.at(i); ++j) {
      cin >> s.at(i).at(j);
    }
  }
  vector<int> p(m);
  for (i = 0; i < m; ++i) {
    cin >> p.at(i);
  }
  int bit;
  int ans = 0;
  vector<int> t(n);
  int l, x;
  int temp = 0;
  bool bitflag;
  for (bit = 0; bit < (1 << n); ++bit) {
    for (i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        t.at(i) = 1;
      } else {
        t.at(i) = 0;
      }
    }
    temp = 0;
    for (l = 0; l < m; ++l) {
      for (x = 0; x < k.at(l); ++x) {
        if (t.at(s.at(l).at(x) - 1) == 1) {
          ++temp;
        }
      }
      if (temp % 2 == p.at(l)) {
        bitflag = true;
        continue;
      } else {
        bitflag = false;
        break;
      }
    }
    if (bitflag) {
      ++ans;
    } else {
      continue;
    }
  }
  cout << ans << endl;
  return 0;
}
