#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < (m); i++) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < (k); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (n); i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < 1 << n; i++) {
    bool ok = true;
    for (int j = 0; j < (m); j++) {
      int c = 0;
      for (int h = 0; h < s[j].size(); h++) {
        if ((i >> s[j][h]) & 1) {
          c++;
        }
      }
      c %= 2;
      if (p[j] != c) {
        ok = false;
      }
    }
    if (ok == true) {
      ans++;
    }
  }
  cout << ans << endl;
}
