#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
deque<int> l[11];
int p[11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  cin >> N >> M;
  int k, second;
  for (int i = 0; i < (M); ++i) {
    cin >> k;
    deque<int> n;
    for (int j = 0; j < (k); ++j) {
      cin >> second;
      n.push_back(second);
    }
    l[i] = n;
  }
  for (int i = 0; i < (M); ++i) cin >> p[i];
  int n = pow(2, 10) - 1;
  queue<string> q;
  q.push("0000000001");
  int num = 0;
  int total = 0;
  int count = 0;
  for (int t = 0; t < (1 << N); t++) {
    for (int i = 0; i < (M); ++i) {
      num = 0;
      for (int j = 0; j < (l[i].size()); ++j) {
        if (t & (1 << (l[i].at(j) - 1))) num++;
      }
      if (num % 2 == p[i]) total++;
    }
    if (total == M) count++;
  }
  cout << count;
  return 0;
}
