#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>());
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      int S;
      cin >> S;
      s[i].push_back(S);
    }
  }
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  int ans = 0;
  int bit = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int cnt = 0;
    for (int i = 0; i < (int)(m); i++) {
      int cnton = 0;
      for (int j = 0; j < (int)(k[i]); j++) {
        int shift = s[i][j] - 1;
        if (bit & (1 << shift)) cnton++;
      }
      if (cnton % 2 == p[i]) cnt++;
    }
    if (cnt == n) ans++;
  }
  cout << ans << endl;
  return 0;
}
