#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using Graph = vector<vector<int>>;
int n, m;
int k[10], s[10][10];
int p[10];
long long ans = 0;
void solve() {
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0;
    bool ok = true;
    for (int j = 0; j < m; j++) {
      for (int l = 0; l < k[j]; l++) {
        if (i >> s[j][l] & 1) cnt++;
      }
      if (cnt % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  solve();
}
