#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<vector<int>> sw(n);
  for (int bl = 0; bl < m; bl++) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      x--;
      sw[x].push_back(bl);
    }
  }
  for (auto &t : p) {
    cin >> t;
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<int> cp = p;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        for (auto x : sw[j]) cp[x] ^= 1;
      }
    }
    int ok = 1;
    for (int j = 0; j < m; j++) {
      ok &= (cp[j]);
    }
    ans += ok;
  }
  cout << ans << endl;
}
