#include <bits/stdc++.h>
using namespace std;
long long factor[300];
long long memory[300];
void primefac(long long num) {
  int i = 0, kosuu = 0;
  while (*(factor + i) != 0) {
    while (num % *(factor + i) == 0) {
      num /= *(factor + i);
      memory[*(factor + i)] += 1;
    }
    if (num == 1) break;
    i++;
  }
}
int elast(long long number) {
  long long tmp = 0;
  int flag = 0;
  *factor = 2;
  for (int i = 3; i <= number; i++) {
    flag = 0;
    for (int j = 0; j <= tmp; j++) {
      if (i % (*(factor + j)) == 0) {
        flag = 1;
        break;
      }
    }
    if (flag) continue;
    tmp += 1;
    *(factor + tmp) = i;
  }
  return tmp + 2;
}
long long nCr(long long n, long long r) {
  long long val = 1;
  long long i;
  if (r == 0) return 1;
  for (i = 0; i < n - r; i++) {
    val *= (n - i);
    val /= (i + 1);
  }
  return val;
}
long long nPr(long long n, long long r) {
  long long val = 1;
  long long i;
  for (i = 0; i < r; i++) {
    val *= (n - i);
  }
  return val;
}
template <typename T>
bool chmin(T &a, const T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T &a, const T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
void eraseSame(T &a) {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
}
template <typename T>
bool swapmax(T &a, T &b) {
  T temp;
  temp = a;
  if (a > b) {
    a = b;
    b = temp;
    return false;
  }
  return true;
}
long long gcd(long long x, long long y) { return (x % y) ? gcd(y, x % y) : y; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
template <typename T>
void splitIn(long long N, vector<T> &array) {
  T temp;
  int i = 0;
  if (N == 0) {
    return;
  }
  array.resize(N);
  while (cin >> temp) {
    array[i] = temp;
    i++;
    if (i >= N) {
      break;
    }
  }
  return;
}
int main() {
  long long n, k, m;
  long long ans = 0;
  int s;
  cin >> n >> m;
  int i = 0;
  vector<vector<long long>> v(m);
  vector<long long> p;
  long long tem;
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> tem;
    v[i].resize(tem);
    for (long long s = 0; s < (long long)(tem); s++) cin >> v[i][s];
  }
  splitIn(m, p);
  for (int i = 0; i < (1 << n); i++) {
    vector<int> sw;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        sw.push_back(j);
      } else {
        sw.push_back(0);
      }
    }
    bool flag = false;
    for (int r = 0; r < m; r++) {
      long long sum = 0;
      for (auto kkk : v[r]) {
        sum += sw[kkk - 1];
      }
      if (sum % 2 == p[r])
        flag = true;
      else {
        flag = false;
      }
    }
    if (flag) ans++;
  }
  cout << ans;
  return 0;
}
