#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;
    vector<int> v(k);
    for (int j = 0; j < k; j++) cin >> v[j];
    s[i] = v;
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  vector<int> sw(n + 1);
  for (int bit = 0; bit < 1 << n; bit++) {
    int wholeCount = 0;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) sw[i] = 1;
    }
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (sw[s[i][j] - 1]) count++;
      }
      if (count % 2 == p[i]) wholeCount++;
    }
    if (wholeCount == m) ans++;
  }
  cout << ans / 2 << endl;
}
