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