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