#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[10], s[10][10], p[10];
int next_combination(int combi) {
  const int x = combi & -combi;
  const int y = x + combi;
  return y | (((combi & ~y) / x) >> 1);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int temp;
      cin >> temp;
      s[i][temp - 1] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int count = 0; count < 1 << N; count++) {
    int state[10] = {0};
    for (int i = 0, temp = count; i < N; i++) {
      if (temp & 1) {
        for (int j = 0; j < M; j++) {
          if (s[i][j]) {
            state[j] = (state[j] + 1) % 2;
          }
        }
      }
      temp >>= 1;
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (state[j] != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
