#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; ++j) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < 1 << n; ++i) {
    int on_cnt = 0;
    bool is_ok = true;
    for (int j = 0; j < m; ++j) {
      for (auto on : s[j]) {
        if (i & 1 << on) {
          ++on_cnt;
        }
      }
      is_ok &= on_cnt % 2 == p[j];
    }
    if (is_ok) ++ans;
  }
  cout << ans << endl;
}
