#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int N, M;
vector<vector<int>> ss;
vector<int> p;
void dfs(int i, vector<bool> onoff) {
  if (i == N) return;
  dfs(i + 1, onoff);
  onoff[i] = true;
  dfs(i + 1, onoff);
  bool is_valid = true;
  for (int j = 0; j < M; ++j) {
    int cnt = 0;
    for (int k = 0; k < (int)ss[j].size(); ++k) {
      if (onoff[ss[j][k] - 1]) cnt++;
    }
    if (cnt % 2 != p[j]) {
      is_valid = false;
      break;
    }
  }
  if (is_valid) ans++;
}
int main() {
  cin >> N >> M;
  int k;
  for (int i = 0; i < M; ++i) {
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < k; ++j) {
      cin >> s[j];
    }
    ss.push_back(s);
  }
  for (int i = 0; i < M; ++i) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  vector<bool> onoff(N, false);
  dfs(0, onoff);
  cout << ans << endl;
  return 0;
}
