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