#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string, int>;
using T = tuple<string, int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i].push_back(a);
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  ll ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int sum = 0;
    bool flg = true;
    for (int i = 0; i < m; i++) {
      for (auto v : s[i]) {
        if (bit & (1 << v)) sum++;
      }
      if (sum % 2 != p[i]) flg = false;
    }
    if (flg) ans++;
  }
  cout << ans << endl;
  return 0;
}
