#include <bits/stdc++.h>
using namespace std;
using INT64 = long long;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<bitset<11>> d;
  for (int i = 0; i < m; i++) {
    bitset<11> bs(0);
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      bs.set(s - 1);
    }
    d.push_back(bs);
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  unsigned int sw = 1 << (n);
  int ans = 0;
  for (unsigned int i = 1; i < sw; i++) {
    bitset<11> ssw(i);
    cerr << ssw << endl;
    bool flag = true;
    for (int j = 0; j < m; j++) {
      bitset<11> sk = d[j];
      sk &= ssw;
      int count = sk.count();
      if (count % 2 != p[j]) {
        flag = false;
        break;
      }
      if (!flag) break;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
