#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s[M];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      s[j].push_back(x - 1);
    }
  }
  int p[M];
  for (int l = 0; l < M; l++) {
    cin >> p[l];
  }
  int num = 0;
  for (int b = 0; b < (1 << N); b++) {
    bool good = true;
    for (int c = 0; c < M; c++) {
      int sum = 0;
      for (int sw : s[c]) {
        if (b & (1 << sw)) {
          ++sum;
        }
      }
      sum %= 2;
      if (sum != p[c]) {
        good = false;
      }
    }
    if (good) {
      num++;
    }
  }
  cout << num << endl;
}
