#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;
const llong inf = 1100100100100100ll;
const llong mod = 1e9 + 7;
llong N, M;
vector<vector<llong> > s;
vector<llong> p;
int solve(int now, vector<int> v) {
  if (now == N) {
    bool check = true;
    for (int i = 0; i < M; i++) {
      int sum = 0;
      for (int j = 0; j < M; j++) {
        if (v[j] && *lower_bound(s[i].begin(), s[i].end(), j + 1) == j + 1)
          sum++;
      }
      if (sum % 2 != p[i]) check = false;
    }
    return check;
  }
  llong res = solve(now + 1, v);
  v[now] = 1;
  return res + solve(now + 1, v);
}
int main() {
  cin >> N >> M;
  s.resize(M);
  p.resize(M);
  llong k;
  for (int i = 0; i < M; i++) {
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) cin >> s[i][j];
    sort(s[i].begin(), s[i].end());
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  vector<int> v(N, 0);
  cout << solve(0, v) << endl;
  return 0;
}
