#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int sw;
      cin >> sw;
      s[i].push_back(sw);
    }
  }
  for (int i = 0; i < m; ++i) {
    int pw;
    cin >> pw;
    p[i] = pw;
  }
  auto onCount = [](int state, vector<int> s) {
    int cnt = 0;
    for (const auto& e : s) {
      if (state & (1 << (e - 1))) cnt++;
    }
    return cnt;
  };
  int cnt = 0;
  for (int i = 0; i <= (1 << n - 1); ++i) {
    int j = 0;
    for (; j < m; ++j) {
      int count = onCount(i, s[j]);
      if (count % 2 != p[j]) break;
    }
    if (j == m) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
