#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s[M];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  vector<int> flag(N);
  fill(flag.begin(), flag.end(), 0);
  int limit = pow(2, N);
  for (int i = 0; i < limit; i++) {
    int tmp = i;
    for (int j = 0; j < N; j++) {
      flag[j] = tmp % 2;
      tmp /= 2;
    }
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int sumation = 0;
      for (int s_num = 0; s_num < s[j].size(); s_num++) {
        if (flag[s_num] == 1) sumation++;
      }
      if (sumation % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
