#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> k(m);
  vector<long long> p(m);
  vector<vector<long long>> s(m);
  for (int i = 0; i < (m); i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = 0; j < (k[i]); j++) cin >> s[i][j];
  }
  for (int i = 0; i < (m); i++) cin >> p[i];
  long long ans = 0;
  for (int bit = 0; bit < (1ll << n); bit++) {
    bool ok = true;
    for (int i = 0; i < (m); i++) {
      long long count = 0;
      for (int j = 0; j < (n); j++) {
        if (bit & (1ll << j)) {
          if (s[i][j]) count++;
        }
      }
      if (count % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans;
  return 0;
}
