#include <bits/stdc++.h>
int main(int argc, char const* argv[]) {
  int n, m;
  std::cin >> n >> m;
  auto sw_info = std::vector<std::vector<int>>(m);
  auto is_on = std::vector<int>(m);
  for (int i = 0; i < m; ++i) {
    int k;
    std::cin >> k;
    auto& l = sw_info[i];
    for (int j = 0; j < k; ++j) {
      int tmp;
      std::cin >> tmp;
      l.push_back(tmp);
    }
  }
  for (int i = 0; i < m; ++i) {
    int p;
    std::cin >> p;
    is_on[i] = p;
  }
  auto all_on_pattern = 0;
  for (int i = 0; i < (1 << n); ++i) {
    auto on_switches = std::vector<int>();
    for (int j = 0; j < n; ++j) {
      if ((i >> j) & 1) {
        on_switches.push_back(j);
      }
    }
    auto is_all_on = true;
    for (int j = 0; j < m; ++j) {
      auto& sw = sw_info[j];
      auto on_num = 0;
      auto on_index = 0;
      for (auto s : sw) {
        if (on_switches.size() <= on_index) {
          break;
        }
        while (true) {
          if (s == on_switches[on_index]) {
            on_index++;
            on_num++;
            break;
          }
          if (s > on_switches[on_index]) {
            on_index++;
          }
          if (s < on_switches[on_index]) {
            break;
          }
        }
      }
      if ((on_num % 2) != is_on[j]) {
        is_all_on = false;
        break;
      }
    }
    if (is_all_on) {
      all_on_pattern++;
    }
  }
  std::cout << all_on_pattern << std::endl;
}
