#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> K(m);
  vector<vector<int> > S(10, vector<int>(10));
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    K[i] = k;
    for (int j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      S[i][j] = s;
    }
  }
  vector<int> P(m);
  for (int i = 0; i < m; i++) cin >> P[i];
  int ans = 0;
  for (int bits = 1; bits < (1 << n); bits++) {
    int num_on = 0;
    for (int i = 0; i < m; i++) {
      int tmp_sum = 0;
      for (int j = 0; j < K[i]; j++) {
        int mask = 1 << S[i][j];
        if (bits & mask) {
          tmp_sum++;
        }
      }
      if (tmp_sum % 2 == P[i]) num_on++;
    }
    if (num_on == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
