#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, k, s, p, ans = 0, count = 0;
  cin >> N >> M;
  vector<vector<int>> switches(M);
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> s;
      switches[i].push_back(--s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p;
    ans += (p << i);
  }
  int hoge;
  bool ok;
  for (int i = 0; i < (2 << (N - 1)); i++) {
    hoge = 0;
    ok = true;
    for (int j = 0; j < M; j++) {
      for (int s : switches[j]) {
        hoge += ((i >> s) & 1);
      }
      if ((hoge & 1) != ((ans >> j) & 1)) {
        ok = false;
        break;
      };
    }
    if (ok) count++;
  }
  cout << count << endl;
}
