#include <bits/stdc++.h>
using namespace std;
auto SOLUTION_FUNCTION(void) -> void {
  int n, m;
  cin >> n >> m;
  int comb = (1 << n);
  vector<vector<int>> v(m + 1);
  for (int i = 1; i <= m; ++i) {
    int k;
    cin >> k;
    v[i].resize(k);
    for (int j = 0; j < k; ++j) {
      int temp;
      cin >> temp;
      v[i][j] = temp;
    }
  }
  vector<int> p(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < comb; ++i) {
    bool ok = true;
    for (int j = 1; j <= m; ++j) {
      int counter = 0;
      for (int k = 0; k <= (int)v[j].size() && ok; ++k) {
        if ((i << v[j][k]) & 1) {
          ++counter;
        }
      }
      counter %= 2;
      if (counter != p[i]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans << '\n';
  return;
}
int main(void) {
  int testcase = 1;
  while (testcase--) {
    SOLUTION_FUNCTION();
  }
  return 0;
}
