#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  vector<int> K(m);
  vector<vector<int>> s(m);
  vector<int> p(m);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    K[i] = k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    bool check = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < K[i]; j++) {
        if (mask & (1 << s[i][j])) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        check = false;
        break;
      }
    }
    if (check == true) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
