#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void prime(vector<int>& v, int n) {
  for (int i = 2; i < n; i++) {
    bool fg = false;
    for (auto e : v) {
      if (i % e == 0) {
        fg = true;
      }
    }
    if (fg) {
      continue;
    }
    v.push_back(i);
  }
}
signed main() {
  int n, m;
  cin >> n >> m;
  bool sl[11][11];
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 0, j_mx = k; j < j_mx; j++) {
      int s;
      cin >> s;
      sl[i][s] = true;
    }
  }
  bool p[11];
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  bool swt[11];
  for (int i = 0, i_mx = pow(2, n); i < i_mx; i++) {
    int cpy = i;
    int j = 1;
    while (cpy) {
      swt[j++] = cpy % 2;
      cpy /= 2;
    }
    bool check[11];
    for (int k = 1; k <= m; k++) {
      check[k] = p[k];
    }
    for (int k = 1; k <= n; k++) {
      if (swt[k]) {
        for (int l = 1; l <= m; l++) {
          check[l] ^= sl[l][k] & swt[k];
        }
      }
    }
    bool flg = true;
    for (int k = 1; k <= m; k++) {
      if (check[k]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
