#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> k(n);
  std::vector<std::vector<int> > s(m);
  for (int i = 0; i < m; i++) {
    std::cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int a;
      std::cin >> a;
      s[i].push_back(a);
    }
  }
  std::vector<int> p(m);
  for (int i = 0; i < m; i++) {
    std::cin >> p[i];
  }
  int on = 0;
  int count = 0;
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    on = 0;
    count = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < s[i].size(); j++) {
        if (bit & (1 << (s[i][j] - 1))) {
          on++;
        }
      }
      if (on % 2 == p[i])
        count++;
      else
        break;
    }
    if (count == m) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}
