#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T>& s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
int n, m;
vector<int> k;
vector<vector<int>> s;
vector<int> p;
int solve(int t, vector<bool> sel) {
  if (t == n) {
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      int su = 0;
      for (int j = 0; j < k[i]; ++j) {
        if (sel[s[i][j]]) su++;
      }
      if (su % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok)
      return 1;
    else
      return 0;
  } else {
    int res = solve(t + 1, sel);
    sel[t] = 1;
    res += solve(t + 1, sel);
    sel[t] = 0;
    return res;
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m;
  k.resize(m);
  s.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  p.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  vector<bool> sel(m);
  cout << solve(0, sel) << endl;
}
