#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> sw(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vector<int> x(k);
    for (int j = 0; j < k; j++) {
      int num;
      cin >> num;
      num--;
      x[i] = num;
    }
    sw[i] = x;
  }
  vector<int> m(M);
  for (int i = 0; i < M; i++) {
    cin >> m[i];
  }
  int cnt = 0;
  for (int i = 0; i <= (1 << N); i++) {
    bool al = true;
    for (int j = 0; j < M; j++) {
      int num = 0;
      for (int k : sw[j]) {
        if (i & (1 << k)) {
          num++;
        }
      }
      if (num % 2 != m[j]) {
        al = false;
        break;
      }
    }
    if (al) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
