#include <bits/stdc++.h>
using namespace std;
int n, m;
int k[11];
int s[11][11];
int p[11];
bool check(vector<int> v) {
  bool on[11] = {false};
  bool ok = true;
  for (int i = 0; i < (int)v.size(); ++i) {
    on[v[i]] = true;
    ok = true;
  }
  for (int i = 0; i < m; i++) {
    int count;
    for (int j = 0; j < k[i]; j++) {
      if (on[s[i][j]]) {
        count++;
      }
    }
    if (count % 2 != p[i]) {
      ok = false;
      break;
    }
  }
  return ok;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j] = s[i][j] - 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<int> S;
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        S.push_back(i);
      }
    }
    if (check(S) == true) {
      ans++;
    }
  }
  cout << ans << endl;
}
