#include <bits/stdc++.h>
const double INF = 1e9;
using namespace std;
int binary(int bina) {
  int ans = 0;
  for (int i = 0; bina > 0; i++) {
    ans = ans + (bina % 2) * pow(10, i);
    bina = bina / 2;
  }
  return ans;
}
int exp(int a, int b) {
  int ans = 1;
  for (int i = 0; i < b; i++) {
    ans *= a;
  }
  return ans;
}
int keta(int binarized, int i) { (binarized % exp(10, i)) / exp(10, i); }
int main() {
  int N, M;
  cin >> N >> M;
  int k[M];
  int s[10][10];
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  int p[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < 1024; i++) {
    bool judge = true;
    for (int a = 0; a < M; a++) {
      int sum = 0;
      for (int b = 0; b < k[a]; b++) {
        sum += keta(binary(i), s[a][b]);
      }
      if (sum % 2 != p[a]) {
        judge = false;
      }
    }
    if (judge) {
      ans++;
    }
  }
  cout << ans;
}
