#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long> > a(m);
  for (int(i) = 0; (i) < (m); (i)++) {
    int k;
    cin >> k;
    for (int(j) = 0; (j) < (k); (j)++) {
      int s;
      cin >> s;
      a[n].push_back(s);
    }
  }
  vector<long long> p(m);
  for (int(i) = 0; (i) < (m); (i)++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool f = true;
    for (int(i) = 0; (i) < (m); (i)++) {
      int count = 0;
      for (auto v : a[i]) {
        if (bit & (1 << v)) count++;
      }
      if (count % 2 != p[i]) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
}
