#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s = 0;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int r;
      cin >> r;
      v[i].push_back(r);
    }
  }
  for (int i = 0; i < m; ++i) cin >> p[i];
  for (int i = 0; i < 1 << n; ++i) {
    bool b = 1;
    for (int j = 0; j < m; ++j) {
      int a = 0;
      for (int l = 0; l < v[j].size(); ++l)
        if (i & 1 << v[j][l]) ++a;
      if (a % 2 != p[j]) b = 0;
    }
    if (b) ++s;
  }
  cout << s << endl;
  return 0;
}
