#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> vs[m];
  for (int i = 0; i < (m); ++i) {
    long long k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      long long s;
      cin >> s;
      s--;
      vs[i].push_back(s);
    }
  }
  vector<long long> vp;
  for (int i = 0; i < (m); ++i) {
    long long p;
    cin >> p;
    vp.push_back(p);
  }
  long long ans = 0;
  for (long long t = 0; t < (1 << n); t++) {
    long long light_on = 0;
    for (int i = 0; i < (m); ++i) {
      long long count_on = 0;
      if (t & (1 << i)) {
        for (auto& e : vs[i]) {
          if (e == i) {
            count_on++;
            break;
          }
        }
      }
      if (count_on % 2 == vp[i]) {
        light_on++;
      }
    }
    if (light_on == m) ans++;
  }
  cout << ans;
}
