#include <bits/stdc++.h>
using namespace std;
int powint(int x, int y) {
  int res = 1;
  for (int i = 0; i < y; i++) res *= x;
  return res;
}
int countbitsum(int n, int x) {
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (x % 2 == 1) {
      res++;
    }
    x /= 2;
  }
  return res;
}
int main() {
  int n, m, res = 0;
  cin >> n >> m;
  int joutai = powint(2, n);
  int s, lamp[m], k[m], p[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s;
      lamp[i] += powint(2, s - 1);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int loop;
  for (int i = 0; i < joutai; i++) {
    loop = 1;
    for (int j = 0; j < m; j++) {
      if (loop == 1 && countbitsum(n, i & lamp[j]) % 2 != p[j]) {
        res--;
        loop = 0;
      }
    }
    res++;
  }
  cout << res << endl;
}
