#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> switches(M, vector<int>(N, 0));
  vector<int> mod_lis(M);
  int sum = 0;
  for (int i = 0; i < M; i++) {
    int switch_count;
    cin >> switch_count;
    for (int j = 0; j < switch_count; j++) {
      int k;
      cin >> k;
      switches[i][k - 1] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> mod_lis.at(i);
  }
  int count = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    int on_count = 0;
    bool all_on = true;
    for (int i = 0; i < M; i++) {
      int mod = mod_lis[i];
      for (int j = 0; j < switches[i].size(); j++) {
        if (switches[i][j] == 1 && (bit & 1 << j)) {
          on_count += 1;
        }
      }
      if (on_count % 2 != mod) {
        all_on = false;
        break;
      }
    }
    if (all_on) {
      count += 1;
    }
  }
  cout << count << endl;
  return 0;
}
