#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long double PI = acos(-1.0);
const long long MAX = 9000000000000000000;
const long long MIN = -9000000000000000000;
const long double DMAX = 4500;
const long double DMIN = -4500;
const long long MOD = 1000000007;
template <typename T>
void fin(T a) {
  cout << a << endl;
  exit(0);
}
long long ans = 0;
void Main() {
  long long n, m;
  cin >> n >> m;
  long long S = 0;
  for (long long i = 0; i < (n); ++i) {
    S += pow(2, i);
  }
  vector<long long> k(m);
  vector<vector<long long>> X(m);
  vector<long long> p(m);
  for (long long i = 0; i < (m); ++i) {
    cin >> k[i];
    for (long long j = 0; j < (k[i]); ++j) {
      long long K;
      cin >> K;
      K--;
      X[i].push_back(K);
    }
  }
  for (long long i = 0; i < (m); ++i) {
    cin >> p[i];
  }
  while (S) {
    long long s = S;
    S--;
    vector<long long> F(m, 0);
    vector<bool> flag(n, false);
    long long now = 0;
    while (s) {
      if (s % 2 == 1) flag[now] = true;
      now++;
      s /= 2;
    }
    long long L = 0;
    for (long long i = 0; i < (m); ++i) {
      long long J = 0;
      for (long long j = 0; j < (k[i]); ++j) {
        long long K = X[i][j];
        if (flag[K] == true) J++;
      }
      if (J % 2 == p[i]) L++;
    }
    if (L == m) ans++;
  }
  fin(ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}
