#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, m;
int lights[10][10];
int sw[10];
int conds[10];
int ans;
void count() {
  int i, j, sum;
  for (i = 0; i < m; i++) {
    sum = 0;
    j = 0;
    while (lights[i][j] != 0) {
      if (sw[lights[i][j] - 1] == 1) sum++;
      j++;
    }
    if (sum % 2 != conds[i]) return;
  }
  ans++;
  return;
}
void solve(int i) {
  if (i == n - 1)
    count();
  else {
    i++;
    sw[i] = 0;
    solve(i);
    sw[i] = 1;
    solve(i);
  }
}
int main(void) {
  int i, j, k;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> k;
    for (j = 0; j < k; j++) {
      cin >> lights[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> conds[i];
  }
  sw[0] = 0;
  solve(0);
  sw[0] = 1;
  solve(0);
  cout << ans << endl;
  return 0;
}
