#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0;
  int k[10 + 1];
  int s[10 + 1][10 + 1] = {};
  int q[10 + 1];
  int index;
  int ans = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> index;
      s[i][index - 1] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> q[i];
  }
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bool true_f = true;
    bitset<10 + 1> bit(tmp);
    for (int i = 0; i < m; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        cout << bit[j] << endl;
        if (bit[j]) {
          sum += s[i][j];
        }
      }
      true_f &= (sum % 2 == q[i]);
    }
    if (true_f) {
      ans++;
    }
  }
  cout << ans << endl;
}
