#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
bool checkL(vector<int> on, int p, set<int> s) {
  int cnt = 0;
  for (auto &o : on) {
    if (s.find(o) != s.end()) cnt++;
  }
  return cnt % 2 == p;
}
bool checkLL(int M, vector<int> on, vector<int> pp, vector<set<int>> ss) {
  for (int(i) = 0; (i) < (M); (i)++) {
    if (!checkL(on, pp[i], ss[i])) return false;
  }
  return true;
}
int main() {
  int N, M, k, s, p, result = 0;
  cin >> N >> M;
  vector<int> pp;
  vector<set<int>> ss;
  for (int(i) = 0; (i) < (M); (i)++) {
    set<int> sst;
    cin >> k;
    for (int(j) = 0; (j) < (k); (j)++) {
      cin >> s;
      sst.insert(s);
    }
    ss.push_back(sst);
  }
  for (int(i) = 0; (i) < (M); (i)++) {
    cin >> p;
    pp.push_back(p);
  }
  for (int(bit) = 0; (bit) < (1 << N); (bit)++) {
    vector<int> on;
    for (int(i) = 0; (i) < (M); (i)++) {
      if (bit & (1 << i)) on.push_back(i + 1);
    }
    if (checkLL(M, on, pp, ss)) result++;
  }
  cout << result << '\n';
  return 0;
}
