#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 60;
const long long MOD = 1e9 + 7;
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s) {
  return f.second > s.second;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> on;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        on.push_back(i);
      }
    }
    int ok = true;
    int ans = 0;
    for (int i = 0; i < m; i++) {
      int oncnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        for (int k = 0; k < on.size(); k++) {
          if (s[i][j] == on[k]) {
            oncnt++;
          }
        }
      }
      if (oncnt % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
