#include <bits/stdc++.h>
constexpr int kMod = 1000000007;
struct Cond {
  int k;
  std::vector<int> s;
  int p;
};
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<Cond> cs;
  for (int m = 0; m < M; ++m) {
    Cond c;
    std::cin >> c.k;
    for (int i = 0; i < c.k; ++i) {
      int v;
      std::cin >> v;
      c.s.push_back(v);
    }
    cs.push_back(c);
  }
  for (int m = 0; m < M; ++m) {
    std::cin >> cs[m].p;
  }
  int cnt = 0;
  for (int i = 1; i < pow(2, N); ++i) {
    std::string p;
    bool success = true;
    int b = pow(2, N - 1);
    while (b > 0) {
      if (i & b)
        p += '1';
      else
        p += '0';
      b >>= 1;
    }
    for (auto c : cs) {
      int on_cnt = 0;
      for (int v : c.s) {
        if (p[v - 1] == '1') ++on_cnt;
      }
      if (on_cnt % 2 != c.p) {
        success = false;
        break;
      }
    }
    if (success) ++cnt;
  }
  std::cout << cnt << std::endl;
}
