#include <bits/stdc++.h>
using namespace std;
vector<int> IntegerToVector(int bit, int N) {
  vector<int> S;
  for (int i = 0; i < N; i++) {
    if (bit & (1 << i)) {
      S.push_back(i);
    }
  }
  return S;
}
int main() {
  int n, m;
  cin >> n >> m;
  int k, pp;
  vector<vector<int> > arr(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> pp;
      arr[i][pp - 1]++;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; 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 count = 0;
      for (int k = 0; k < n; k++) {
        if (i & (1 << arr[j][k])) count++;
      }
      if (p[j] != count % 2) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
