#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int x;
  int k;
  cin >> n >> m;
  int sw[m][n];
  int jou[m];
  int ans = 0;
  bool flag;
  int nishin[n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      sw[m][n] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> x;
      sw[i][x] = 1;
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < int(pow(2, n)); i++) {
    int z = i;
    flag = true;
    for (int j = 0; j < m; j++) {
      jou[j] = 0;
    }
    for (int j = 0; j < n; j++) {
      nishin[j] = z % 2;
      z = z / 2;
    }
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        jou[k] += nishin[j] * sw[k][j];
      }
    }
    for (int j = 0; j < m; j++) {
      if (jou[j] % 2 != p[j]) flag = false;
    }
    if (flag == true) ans += 1;
  }
  cout << ans << endl;
}
