#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++) {
      int tmp;
      cin >> tmp;
      s[i][j] = --tmp;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int res = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < s[j].size(); k++) {
        if ((i >> s[j][k]) & 1) cnt++;
      }
      if ((cnt % 2) != p[j]) ok = false;
    }
    if (ok) res++;
  }
  cout << res << endl;
}
