#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> bi(m), pi(m);
  int k, s, ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> k;
    bi[i] = 0;
    for (int j = 0; j < k; j++) {
      cin >> s;
      bi[i] |= (1 << (s - 1));
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> pi[i];
  }
  for (int b = 0; b < (1 << n); b++) {
    bool isAllOn = true;
    for (int i = 0; i < m; i++) {
      if ((bitset<12>((bi[i] & b)).count() % 2) != pi[i]) isAllOn = false;
    }
    if (isAllOn) ans++;
  }
  cout << ans << endl;
  return 0;
}
