#include <bits/stdc++.h>
using namespace std;
int main() {
  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(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << m) - 1; ++i) {
    vector<int> cnt(n, 0);
    for (int l = 0; l < m; ++l) {
      if (i & (1 << l)) {
        for (int x : s[l]) cnt[x]++;
      }
    }
    bool flag = 0;
    for (int j = 0; j < n; ++j) {
      if (cnt[j] % 2 != p[j]) flag = 1;
    }
    if (!flag) ans++;
  }
  cout << ans << endl;
}
