#include <bits/stdc++.h>
using namespace std;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];
int main() {
  int n, m, tmp;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (int)(k); j++) {
      cin >> tmp;
      connect[i].set(tmp);
    }
  }
  int res = 0;
  for (int i = 0; i < (int)(m); i++) cin >> flag[i];
  for (int i = 0; i < (int)(1 << n); i++) {
    bitset<10> target(i);
    bool isok = true;
    for (int j = 0; j < (int)(m); j++)
      if ((target & connect[j]).count() % 2 != flag[j]) {
        isok = false;
        break;
      }
    if (isok) res++;
  }
  cout << res << endl;
  return 0;
}
