#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int> > s(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int input_s;
      cin >> input_s;
      s[i].push_back(input_s);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<bool> switches;
    for (int j = 0; j < n; j++) {
      switches.push_back((i >> j) & 1);
    }
    for (int j = 0; j < m; j++) {
      int cnt = 0;
      for (int l = 0; l < k[l]; l++) {
        cnt += switches[s[j][l] - 1];
      }
      if (p[j] != cnt % 2) {
        j = m;
      }
      if (j == m - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
