#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> b(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int s;
      cin >> s;
      b[i].push_back(s);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int sw = 0; sw < (int)pow(2, n); sw++) {
    bool all_on = true;
    for (int i = 0; i < m; i++) {
      int on = 0;
      for (int s : b[i]) {
        on += (sw >> (s - 1)) % 2;
      }
      all_on &= (on % 2 == p[i]);
    }
    if (all_on) ans += 1;
  }
  cout << ans << endl;
  return 0;
}
