#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, p[11], ans = 0;
  set<int> a[11];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      a[x].insert(i);
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  int lim = 1 << n;
  int swit[11], time[11];
  for (int i = 0; i < lim; i++) {
    int tmp = i, cnt = m, flag = 1;
    for (int j = 0; j < 11; j++) {
      swit[j] = time[j] = 0;
    }
    while (tmp) {
      swit[cnt--] = tmp % 2;
      tmp >>= 1;
    }
    for (int j = 1; j <= m; j++) {
      if (swit[j]) {
        for (auto p : a[j]) {
          time[p]++;
        }
      }
    }
    for (int j = 1; j <= m; j++) {
      if (time[j] % 2 != p[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
