#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int> > v(m);
  for (int i = 0; i < m; i++) {
    cin >> k.at(i);
    v.at(i).resize(k.at(i));
    for (int j = 0; j < k.at(i); j++) {
      int s;
      cin >> s;
      v.at(i).at(j) = s - 1;
    }
  }
  for (int i = 0; i < m; i++) cin >> p.at(i);
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int ok = 1;
    for (int j = 0; j < m; j++) {
      int on = 0;
      for (int sw = 0; sw < k.at(j); sw++) {
        if ((i >> sw) & 1) on++;
      }
      if (on % 2 != p.at(j)) ok = 0;
    }
    ans += ok;
  }
  cout << ans << endl;
  return 0;
}
