#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  int k[10];
  int s[10][10];
  for (int denkyu_i = 0; denkyu_i < M; denkyu_i++) {
    cin >> k[denkyu_i];
    for (int j = 0; j < k[denkyu_i]; j++) {
      cin >> s[denkyu_i][j];
    }
  }
  int p[10];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  short state = 0;
  int answer = 0;
  int tmp = pow(2, N);
  for (state = 0; state < tmp; state++) {
    int count = 0;
    int on_switch_num = 0;
    for (int denkyu_i = 0; denkyu_i < M; denkyu_i++) {
      for (int switch_j = 0; switch_j < k[denkyu_i]; switch_j++) {
        on_switch_num += ((state >> (s[denkyu_i][switch_j] - 1)) & 1);
      }
      if (on_switch_num % 2 == p[denkyu_i]) {
        count++;
      }
    }
    if (count == M) {
      answer++;
    }
  }
  std::cout << answer;
}
