#include <bits/stdc++.h>
using namespace std;
void Fast_Read_Out() {
  ios_base::sync_with_stdio(0);
  cin.tie(), cout.tie();
}
void Random() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
unsigned int Time() {
  unsigned int time = clock() / 1000.00;
  return time;
}
const int mod = (int)1e9 + 7;
int id[11][11];
int cur[11];
int ans;
int k[11], p[11];
int main() {
  Fast_Read_Out();
  Random();
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) cin >> id[i][j], id[i][j]--;
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  for (int mask = 0; mask <= (1 << n); mask++) {
    memset(cur, 0, sizeof cur);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 1; j <= m; j++)
        for (int l = 1; l <= k[j]; l++)
          if (id[j][l] == i) cur[j] += ((mask >> i) & 1);
    }
    for (int i = 1; i <= m; i++)
      if (p[i] == cur[i] % 2) cnt++;
    if (cnt == m) ans++;
  }
  cout << ans;
}
