#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[100][100];
  int p[100];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int r;
      cin >> r;
      s[i][j] = r - 1;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool t = true;
    for (int i = 0; i < M; i++) {
      int counter = 0;
      for (int j : s[i]) {
        if (bit & (1 << j)) counter++;
      }
      if (counter % 2 == p[i])
        t = true;
      else {
        t = false;
        break;
      }
    }
    if (t) res++;
  }
  cout << res << endl;
}
