#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int n, m;
int k[11] = {}, s[11][11] = {{}}, p[11] = {};
int on[11] = {};
void solve(int on[], int x) {
  if (x < n) {
    int on2[11];
    for (int i = 0; i < m; i++) on2[i] = on[i];
    solve(on2, x + 1);
    on2[x]++;
    solve(on2, x + 1);
  } else {
    bool end = true;
    int a;
    for (int i = 0; i < m; i++) {
      a = 0;
      for (int j = 0; j < k[i]; j++) a += on[s[i][j] - 1];
      if (a % 2 != p[i]) end = false;
    }
    if (end) ans++;
  }
}
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];
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  solve(on, 0);
  cout << ans << endl;
  return 0;
}
