#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 1000000;
const double PI = 3.14159265359;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(m);
  for (long long i = 0; i < (m); i++) {
    long long a;
    cin >> a;
    for (long long j = 0; j < (a); j++) {
      long long b;
      cin >> b;
      v[i].push_back(--b);
    }
  }
  bool p[m];
  for (long long i = 0; i < (m); i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < ((1 << n)); bit++) {
    bool e = true;
    for (long long i = 0; i < (m); i++) {
      long long count = 0;
      cout << i << ":" << v[i].size() << endl;
      for (long long j = 0; j < (v[i].size()); j++) {
        if (bit & (1 << v[i][j])) count++;
      }
      if (count % 2 != p[i]) e = false;
    }
    if (e) ans++;
  }
  cout << ans << endl;
  return 0;
}
