#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<vector<long long>> g;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> vs(n, vector<long long>());
  vector<long long> p(n);
  for (int i = 0; i < m; ++i) {
    long long k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      long long s;
      cin >> s;
      s--;
      vs[i].push_back(s);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  long long ret = 0;
  for (int i = 0; i < (1ll << n); ++i) {
    bool f = 1;
    for (int j = 0; j < vs.size(); ++j) {
      long long tmp = 0;
      for (int k = 0; k < vs[j].size(); ++k) {
        if ((1ll << vs[j][k]) & i) {
          tmp++;
        }
      }
      if ((tmp % 2) != p[j]) {
        f = 0;
        break;
      }
    }
    if (f) {
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}
