#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MOD = 1000000007;
int main() {
  int n, m, k;
  long long ans = 0;
  cin >> n >> m;
  vector<int> p(m), l(m);
  vector<vector<int>> s(m);
  for (int i = 0; i < (m); ++i) {
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int temp;
      cin >> temp;
      temp--;
      s[i].push_back(temp);
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> sw(n, 0);
    bool ok = true;
    for (int i = 0; i < (n); ++i) {
      if (bit & (1 << i)) sw[i] = 1;
    }
    for (int i = 0; i < (m); ++i) {
      int cnt = 0;
      for (int id : s[i]) {
        if (sw[s[i][id]]) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
