#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> c;
  for (auto i = 0; i < M; ++i) {
    vector<int> temp;
    int k;
    cin >> k;
    for (auto j = 0; j < k; ++j) {
      int s;
      cin >> s;
      temp.push_back(s);
    }
    c.push_back(temp);
  }
  vector<int> p;
  for (auto i = 0; i < M; ++i) {
    int temp;
    cin >> temp;
    p.push_back(temp);
  }
  auto limit = 1;
  for (auto i = 0; i < N; ++i) {
    limit *= 2;
  }
  auto result = 0;
  for (auto i = 0; i < limit; ++i) {
    auto on = true;
    for (auto j = 0; j < M; ++j) {
      auto count = 0;
      for (auto k = 0; k < c[j].size(); ++k) {
        if ((i & (1 << k)) != 0) {
          ++count;
        }
      }
      if ((count % 2) != p[j]) {
        on = false;
        break;
      }
    }
    if (on) {
      ++result;
    }
  }
  cout << result << endl;
  return 0;
}
