#include <bits/stdc++.h>
using namespace std;
string decimal_to_string(int a, int b) {
  string c = "";
  while (a / 2) {
    c += to_string(a % 2);
    a = a / 2;
  }
  a % 2 == 1 ? c += to_string(a % 2) : c += "";
  for (int i = 0; i < b - c.size() + 1; ++i) {
    c += "0";
  }
  for (int i = 0; i < b / 2; i++) {
    swap(c[i], c[b - i - 1]);
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int N, M, k, a;
  cin >> N >> M;
  int arr[N][M];
  int p[M];
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      arr[i][j] = 0;
    }
  }
  for (int i = 0; i < M; ++i) {
    cin >> k;
    while (k--) {
      cin >> a;
      arr[i][a - 1] = 1;
    }
  }
  for (int i = 0; i < M; ++i) {
    cin >> p[i];
  }
  int power = (int)pow(2, N);
  int ans = 0;
  for (int h = 0; h < power; ++h) {
    string c = decimal_to_string(h, N);
    bool cumple = 1;
    for (int j = 0; j < M && cumple; ++j) {
      int suma = 0;
      for (int i = 0; i < N; ++i) {
        a = c[i] == '1' ? 1 : 0;
        suma += arr[j][i] * a;
      }
      if (suma % 2 != p[j]) {
        cumple = 0;
      }
    }
    if (cumple) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
