#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  int s[12][12];
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) cin >> s[i][j];
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int answer = 0;
  int count = 0;
  int ok;
  for (int a = 0; a < ((1 << n)); ++a) {
    ok = 1;
    for (int b = 0; b < (m); ++b) {
      count = 0;
      for (int c = 0; c < (k[b]); ++c) {
        if (a >> c & 1) count++;
      }
      if (count % 2 != p[b]) ok = 0;
    }
    if (ok) answer++;
  }
  cout << answer << endl;
}
