#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> ks;
vector<int> p;
bool isOK(int bit) {
  bool res = true;
  for (int i = 0; i < (m); ++i) {
    int k_i = ks[i][0];
    int s_cnt = 0;
    for (int j = 1; j <= k_i; j++) {
      int s = ks[i][j];
      if (bit & (1 << s)) s_cnt++;
    }
    if (s_cnt % 2 != p[i]) res = false;
  }
  return res;
}
int main() {
  cin >> n >> m;
  ks.resize(m);
  for (int i = 0; i < (m); ++i) {
    int k_i;
    cin >> k_i;
    ks[i].resize(k_i);
    ks[i][0] = k_i;
    for (int j = 1; j <= k_i; j++) {
      int s_ij;
      cin >> s_ij;
      ks[i][j] = s_ij - 1;
    }
  }
  p.resize(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int cnt = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    if (isOK(bit)) cnt++;
  }
  cout << cnt << endl;
}
