#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, n_pow = 0, ans = 0;
  cin >> n >> m;
  vector<vector<int> > s(m);
  vector<int> p(m);
  for (auto &ss : s) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int tmp;
      cin >> tmp;
      ss.push_back(tmp - 1);
    }
  }
  for (auto &tp : p) cin >> tp;
  n_pow = (1 << n);
  for (int i = 0; i < n_pow; ++i) {
    bitset<10> bs(i);
    int index = 0;
    bool fail = false;
    for (auto &ss : s) {
      int t = 0;
      for (auto &ts : ss) t += (int)bs[ts];
      if (t % 2 != p[index++]) {
        fail = true;
        break;
      }
      ans += !fail;
    }
  }
  cout << ans << endl;
}
