#include <bits/stdc++.h>
using namespace std;
int s[12][12];
int p[12];
int z[12];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a;
    cin >> a;
    while (a--) {
      int b;
      cin >> b;
      s[i][b] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) cin >> p[i];
  for (int i = 1; i < (1 << n); i++) {
    memset(z, 0, sizeof(z));
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) z[j + 1] = 1;
    }
    int q = 0;
    for (int j = 1; j <= m; j++) {
      int pp = 0;
      for (int k = 1; k <= n; k++)
        if (s[j][k] && z[k]) pp++;
      if (pp % 2 != p[j]) q = 1;
    }
    if (!q) ans++;
  }
  cout << ans << endl;
  return 0;
}
