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