#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
bool fuck(char c) {
  return (c == 'a' || c == 't' || c == 'c' || c == 'o' || c == 'd' ||
          c == 'e' || c == 'r' || c == '@');
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> s;
  for (long long i = (0); i < (m); i++) {
    long long k;
    cin >> k;
    vector<long long> tmp;
    for (long long j = (0); j < (k); j++) {
      long long t;
      cin >> t;
      t--;
      tmp.push_back(t);
    }
    s.push_back(tmp);
  }
  long long p[m];
  for (long long i = (0); i < (m); i++) cin >> p[i];
  long long res = 0;
  for (long long i = (0); i < ((1 << n) + 1); i++) {
    vector<long long> v;
    for (long long j = (0); j < (n); j++)
      if (i >> j & 1) v.push_back(j);
    long long light[m];
    for (long long j = (0); j < (m); j++) light[j] = 0;
    for (long long j = (0); j < (v.size()); j++) {
      for (long long l = (0); l < (m); l++) {
        for (long long k = (0); k < (s[l].size()); k++)
          if (s[l][k] == v[j]) light[l]++;
      }
    }
    bool f = true;
    for (long long j = (0); j < (m); j++) {
      if (light[j] % 2 != p[j]) {
        f = false;
        break;
      }
    }
    if (f) res++;
  }
  cout << res << endl;
}
