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