#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> S(M);
  for (long long i = 0; i < (long long)M; i++) {
    cin >> k[i];
    for (long long j = 0; j < (long long)k[i]; j++) {
      int tmp;
      cin >> tmp;
      S[i].push_back(tmp);
    }
  }
  vector<int> pair<long long, long long>(M);
  for (long long i = 0; i < (long long)M; i++) {
    cin >> pair<long long, long long>[i];
  }
  int res = 0;
  for (int bit = 0; bit < pow(2, N); bit++) {
    for (long long i = 0; i < (long long)M; i++) {
      int cnt = 0;
      for (long long j = 0; j < (long long)k[i]; j++) {
        if (bit & (1 << (S[i][j] - 1))) {
          cnt++;
        }
        if (cnt % 2 != pair<long long, long long>[i]) {
          break;
        }
      }
      if (i == M - 1) {
        res += 1;
      }
    }
  }
  cout << res << endl;
}
