#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m);
  for (int i = (0); i < (int)(m); i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = (0); j < (int)(k[i]); j++) cin >> s[i][j];
  }
  for (int i = (0); i < (int)(m); i++) cin >> p[i];
  int ans = 0;
  for (int i = (0); i < (int)(1 << n); i++) {
    bool ok = true;
    for (int j = (0); j < (int)(m); j++) {
      int c = 0;
      for (int id : s[j]) {
        if (i >> id & 1) ++c;
      }
      if (c % 2 != p[j]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans;
}
