#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> s[11];
int k[11];
int p[11];
int on[11];
int ans = 0;
void comb(int t, int sw) {
  if (t == 0) {
    for (int i = 1; i <= n; i++) {
      int count = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (on[s[i][j]] == 1) {
          count++;
        }
      }
      if (count % 2 != p[i]) return;
    }
    ans++;
    return;
  }
  on[t] = sw;
  comb(t - 1, 0);
  comb(t - 1, 1);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  comb(n + 1, 0);
  cout << ans / 2 << endl;
  return 0;
}
