#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      --s;
      a[s] |= 1 << i;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    --x;
    p[i] |= x << i;
  }
  int ans = 0;
  for (int i = 0; i < 1 << n; ++i) {
    int t;
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) t ^= a[j];
    }
    if (t == p[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}
