#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int *k = new int[m];
  vector<vector<int>> s;
  int *p = new int[m];
  int max = 1;
  for (int i = 0; i < n; i++) max *= 2;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    vector<int> ss;
    for (int j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      ss.emplace_back(x);
    }
    s.emplace_back(ss);
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int flag = 0;
  int pattern = 0;
  for (int i = 0; i < max; i++) {
    int onNum = 0;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int ii = 0; ii < k[j]; ii++) {
        int f = flag;
        if ((f >> (s[j][ii] - 1)) % 2 == 1) {
          count++;
        }
      }
      if (count % 2 == p[j]) continue;
      onNum++;
    }
    if (onNum == m) pattern++;
    flag++;
  }
  cout << pattern << '\n';
  delete[] k;
  delete[] p;
  return 0;
}
