#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int k[M], p[M], s[M][M];
  for (int i(0); i < M; ++i) {
    cin >> k[i];
    for (int j(0); j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i(0); i < M; ++i) {
    cin >> p[i];
  }
  long long ans(0);
  for (int i(0); i < pow(2, N); ++i) {
    int cur[N], tmp(i);
    for (int j(N - 1); j >= 0; --j) {
      if (tmp >= pow(2, j)) {
        cur[N - 1 - j] = 1;
        tmp -= pow(2, j);
      } else
        cur[N - 1 - j] = 0;
    }
    bool sw(true);
    for (int l(0); l < M; ++l) {
      int cnt(0);
      for (int m(0); m < k[l]; ++m) {
        if (cur[s[l][m] - 1] == 1) cnt++;
      }
      if (cnt % 2 != p[l]) sw = false;
    }
    if (sw) ans++;
  }
  cout << ans << endl;
  return 0;
}
