#include <bits/stdc++.h>
using namespace std;
int dfs(int n, int m, vector<vector<int> > &svv, vector<int> &pv,
        vector<int> &state, int level, int use) {
  if (level == n - 1) {
    state[level] = use;
    int sum;
    for (int i = 0; i < m; i++) {
      sum = 0;
      for (auto svi = svv[i].begin(); svi != svv[i].end(); svi++) {
        sum += state[*svi - 1];
      }
      if (sum % 2 != pv[i]) {
        return 0;
      }
    }
    return 1;
  } else {
    if (level != -1) state[level] = use;
    return dfs(n, m, svv, pv, state, level + 1, 0) +
           dfs(n, m, svv, pv, state, level + 1, 1);
  }
}
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n;
  cin >> m;
  int ki;
  int s;
  vector<vector<int> > svv;
  for (int i = 0; i < n; i++) {
    vector<int> sv;
    cin >> ki;
    for (int j = 0; j < ki; j++) {
      cin >> s;
      sv.push_back(s);
    }
    svv.push_back(sv);
  }
  vector<int> pv;
  vector<int> state;
  int p;
  for (int i = 0; i < m; i++) {
    cin >> p;
    pv.push_back(p);
    state.push_back(0);
  }
  cout << dfs(n, m, svv, pv, state, -1, 0);
  return 0;
}
