#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int> > vec(m);
  vector<int> p(m);
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int(j) = 0; (j) < (int)(k); ++(j)) {
      cin >> vec[i][j];
      vec[i][j]--;
    }
  }
  for (int(i) = 0; (i) < (int)(m); ++(i)) cin >> p[i];
  for (int(i) = 0; (i) < (int)((1 << n)); ++(i)) {
    bool isON = true;
    for (int(j) = 0; (j) < (int)(m); ++(j)) {
      int cnt = 0;
      for (int(k) = 0; (k) < (int)(sizeof(vec[j])); ++(k))
        if ((i >> vec[j][k]) & 1) cnt++;
      if ((cnt % 2) == p[j]) isON = false;
    }
    if (isON) ans++;
  }
  cout << ans << endl;
  return 0;
}
