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