#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  int swi[(1 << n)][n];
  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;
    }
  }
  vector<int> k(m), p(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> k.at(i);
    s[i].resize(k.at(i));
    for (int j = 0; j < k.at(i); j++) {
      cin >> s[i].at(j);
    }
  }
  for (int i = 0; i < m; i++) cin >> p.at(i);
  for (int bit = 0; bit < (1 << n); bit++) {
    int sum = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < k.at(i); j++) {
        sum += swi[bit][s[i][j] - 1];
      }
      if (sum % 2 != p.at(i)) break;
      if (i == m - 1) ans++;
    }
  }
  cout << ans;
}
