#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m][10], k[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  int p[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  int l = 1;
  for (int i = 0; i < n; i++) l *= 2;
  int t[l][10];
  int u[10];
  u[0] = -1;
  for (int i = 0; i < l; i++) {
    u[0] += 1;
    for (int j = 0; j < 9; j++) {
      if (u[j] == 1) {
        u[j] = 0;
        u[j + 1] += 1;
        t[i][j] = u[j];
      }
    }
    t[i][9] = u[9];
  }
  int count = 0;
  for (int i = 0; i < l; i++) {
    int b = 0;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (int a = 0; a < k[j]; a++) {
        if (t[i][s[j][a]] == 1) {
          c += 1;
        }
      }
      if (c % 2 != p[j]) {
        break;
      }
      b += 1;
    }
    if (b == m) count += 1;
  }
  cout << count << endl;
  return 0;
}
