#include <bits/stdc++.h>
using namespace std;
struct Solver {
  void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> sw(M);
    for (int i = 0; i < M; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        int s;
        cin >> s;
        sw[i].push_back(s - 1);
      }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) {
      cin >> p[i];
    }
    int ans = 0;
    for (int bt = 1; bt < (1 << N); ++bt) {
      int on = 0;
      for (int i = 0; i < M; ++i) {
        int sc = 0;
        for (int s : sw[i]) {
          if (bt & (1 << s)) {
            sc += 1;
          }
        }
        if ((sc & 1) == p[i]) {
          on += 1;
        }
      }
      if (on == M) {
        ans += 1;
      }
    }
    cout << ans << endl;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solver().solve();
  return 0;
}
