#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  int s[m][n];
  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 ans = 0;
  bool ok = true;
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < m; i++) {
      int c = 0;
      for (int j = 0; j < k[i]; j++) {
        if ((1 << (s[i][j] - 1)) & bit) c++;
      }
      if (c % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
