#include <bits/stdc++.h>
using namespace std;
constexpr auto INF = 2147483647;
int n, m, k, p[10], cnt, tmp;
vector<int> lights[10];
bool allPowerON(int bit) {
  for (int i = 0; i < (m); i++) {
    int switch_count = 0;
    for (int j = 0; j < (lights[i].size()); j++) {
      if ((bit >> j) % 2 == 1) switch_count++;
    }
    if (switch_count % 2 != p[i]) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    cin >> k;
    for (int j = 0; j < (k); j++) {
      cin >> tmp;
      lights[i].push_back(tmp);
    }
  }
  for (int i = 0; i < (m); i++) cin >> p[i];
  cnt = 0;
  for (int i = 0; i < 1 << n; i++) {
    if (allPowerON(i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
