#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, vector<int>(n));
  for (long long i = 0; i < (m); i++) {
    cin >> k.at(i);
    for (long long j = 0; j < (k.at(i)); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (long long i = 0; i < (m); i++) cin >> p.at(i);
  int swi[(1 << n)][n], ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        swi[bit][i] = 1;
      } else
        swi[bit][i] = 0;
    }
    bool ok = true;
    int now = 0;
    for (long long i = 0; i < (m); i++) {
      for (long long j = 0; j < (k.at(i)); j++) {
        now += swi[bit][s[i][j]];
      }
      if (now % 2 != p.at(i)) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
