#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;
}
template <typename T>
void SV(vector<T> v) {
  for (int i = 0, i_len = (v.size()); i < i_len; ++i) {
  }
}
int bitCount(int bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16);
}
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> S(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    int k;
    cin >> k;
    for (int j = 0, j_len = (k); j < j_len; ++j) {
      int _s;
      cin >> _s;
      S[i] |= 1 << _s;
    }
    S[i] >>= 1;
    42;
  }
  vector<int> P(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> P[i];
  }
  int cnt = 0;
  for (int i = (1), i_len = (1 << (N)); i < i_len; ++i) {
    bool flg = true;
    for (int j = 0, j_len = (M); j < j_len; ++j) {
      42;
      if (P[j] != bitCount(S[j] & i) % 2) {
        flg = false;
        break;
      }
    }
    if (flg) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
