#include <bits/stdc++.h>
using namespace std;
string b(int x) {
  stringstream ss;
  ss << static_cast<bitset<8>>(x);
  return ss.str();
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M);
  int tmp;
  for (int i = 0; i < (int)(M); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> p[i];
  }
  vector<int> state(10);
  string tb;
  int ans = 0;
  bool ok;
  for (int i = 0; i < pow(2, N); i++) {
    tb = b(i);
    reverse(tb.begin(), tb.end());
    ok = true;
    for (int j = 0; j < N; j++) {
      state[j] = (tb[j] - '0');
    }
    for (int m = 0; m < M; m++) {
      tmp = 0;
      for (int sw = 0; sw < k[m]; sw++) {
        tmp += state[s[m][sw] - 1];
      }
      if (tmp % 2 != p[m]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
