#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M][N], k[M], p[M];
  for (int i = 0; i < M; i++)
    for (int j = 0; j < N; j++) s[i][j] = -1;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  int many = 0, done = 1, q = 0;
  for (int val = 0; val < pow(2, N); val++) {
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < k[i]; j++) {
        if (val & 1 << j) q ^= 1;
      }
      if (p[i] != q) {
        done = 0;
        break;
      }
    }
    many += done;
    done = 1;
    q = 0;
  }
  cout << many;
}
