#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<unsigned int> vi;
vector<unsigned int> vp;
bool check(unsigned int arg) {
  int ans = 0, cnt;
  bool flag = true;
  if (arg == 0) return false;
  for (int i = 0; i < (m); ++i) {
    cnt = __builtin_popcount(vi[i] & arg);
    if (cnt % 2 != vp[i]) {
      flag = false;
      break;
    }
  }
  return flag;
}
int dfs(int idx, unsigned int arg) {
  if (idx == n) {
    return check(arg);
  }
  int ans = dfs(idx + 1, arg);
  arg |= (1 << idx);
  ans += dfs(idx + 1, arg);
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  vi.resize(m);
  vp.resize(m);
  for (int i = 0; i < (m); ++i) {
    int k, l;
    cin >> k;
    unsigned int t = 0;
    for (int j = 0; j < (k); ++j) {
      cin >> l;
      t |= (1 << (--l));
    }
    vi[i] = t;
  }
  for (int i = 0; i < (m); ++i) {
    cin >> vp[i];
  }
  cout << dfs(0, 0) << endl;
  return 0;
}
