#include <bits/stdc++.h>
using namespace std;
int n, m, k[10], p[10];
int main() {
  int a, an, ans;
  cin >> n >> m;
  int i, j;
  int s[i][j];
  for (i = 0; i < m; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
    j = 0;
  }
  for (int d = 0; d < m; d++) {
    cin >> p[d];
  }
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int b = 0; b < m; b++) {
      for (int c = 0; c < k[b]; c++) {
        if (bit & (1 << (s[b][c] - 1))) {
          a++;
        }
      }
      if (a % 2 == p[b]) {
        an++;
      }
    }
    if (an == m) {
      ans++;
    }
    an = 0;
  }
  cout << ans << endl;
}
