#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> ar(100, vector<int>());
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      ar[i].push_back(x);
    }
  }
  vector<int> p(100);
  for (int i = 0; i < m; i++) cin >> p[i];
  int res = 0;
  for (int i = 0; i <= (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int sum = 0;
      for (int x : ar[j]) {
        if (i & (1 << (x - 1))) sum++;
      }
      if (sum % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      res++;
    }
  }
  cout << res;
  return 0;
}
