#include <bits/stdc++.h>
using namespace std;
struct switches {
  long k;
  vector<long> s;
};
int main() {
  long n, m, ii, jj, tmp;
  vector<switches> sw;
  vector<long> light;
  cin >> n >> m;
  sw.resize(n);
  light.resize(m);
  for (ii = 0; ii < n; ii++) {
    cin >> sw[ii].k;
    sw[ii].s.resize(n);
    for (jj = 0; jj < n; jj++) {
      sw[ii].s[jj] = 0;
    }
    for (jj = 0; jj < sw[ii].k; jj++) {
      cin >> tmp;
      sw[ii].s[tmp - 1] = 1;
    }
  }
  for (ii = 0; ii < m; ii++) {
    cin >> light[ii];
  }
  vector<long> state;
  long kk, ll, swstate, res = 0;
  state.resize(n);
  for (ii = 0; ii < pow(2, n); ii++) {
    tmp = ii;
    for (jj = 0; jj < n; jj++) {
      state[jj] = tmp % 2;
      tmp = tmp / 2;
    }
    long arr[m];
    for (ll = 0; ll < m; ll++) {
      arr[ll] = 0;
    }
    swstate = 0;
    for (kk = 0; kk < n; kk++) {
      if (state[kk] == 1) {
        for (ll = 0; ll < n; ll++) {
          if (sw[kk].s[ll] == 1) {
            arr[ll]++;
          }
        }
      }
    }
    tmp = 0;
    for (kk = 0; kk < n; kk++) {
      if ((light[kk] % 2) == (arr[kk] % 2)) {
        tmp++;
      }
    }
    if (tmp == m) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}
