#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int k[12];
  int s[12][12];
  int p[12];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  int check;
  int ch[12];
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 1; j <= n; j++) {
      if ((i >> (j - 1)) & 1) {
        ch[j] = 1;
      } else {
        ch[j] = 0;
      }
    }
    check = 1;
    long long pres = 0;
    for (int j = 1; j <= m; j++) {
      for (int l = 1; l <= k[j]; l++) {
        if (ch[s[j][l]]) {
          pres++;
        }
      }
      if (p[j] != pres % 2) {
        check = 0;
        goto EXIT;
      }
    }
  EXIT:
    if (check) ans++;
  }
  cout << ans << endl;
}
