#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, cnt, tmp, ans = 0;
  scanf("%d", &n), scanf("%d", &m);
  vector<vector<int> > vec(m);
  vector<int> e(m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &k), vec[i].resize(k);
    for (int j = 0; j < k; j++) scanf("%d", &vec[i][j]);
  }
  for (int i = 0; i < m; i++) scanf("%d", &e[i]);
  for (int i = 1; i < (1 << n); i++) {
    cnt = 0;
    for (int j = 0; j < m; j++) {
      tmp = 0;
      for (const auto &x : vec[j]) {
        if (i & (1 << (x - 1))) tmp++;
      }
      if (tmp % 2 == e[j]) cnt++;
    }
    if (cnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
