#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m);
  int t;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> t;
      s[i].push_back(t);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int u = 0;
  for (int i = 0; i < (1 << n); i++) {
    t = 0;
    u = 0;
    for (int j = 0; j < m; j++) {
      for (int l = 0; l < k[j]; l++) {
        if (((i >> (s[j][l] - 1)) & 1) == 1) {
          u++;
        }
      }
      if (p[j] == u % 2) {
        t++;
      }
    }
    if (t == m) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
