#include <bits/stdc++.h>
using namespace std;
long long s[15][15], sw[15], p[15], a[15];
int main(void) {
  long long ans = 0, n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  long long cnt = 1 << n;
  for (int i = 0; i <= cnt; i++) {
    long long f = cnt - i, g = 1, v = 1;
    while (f > 0) {
      if (f % 2 == 1) sw[g] = 1;
      f /= 2;
      g++;
    }
    int y = 0;
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < a[j]; k++) {
        if (sw[s[j][k]] == 1) y++;
      }
      if (y % 2 != p[j]) v *= 0;
    }
    if (v == 1) ans++;
    for (int j = 1; j <= n; j++) sw[j] = 0;
  }
  cout << ans << endl;
  return 0;
}
