#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<vector<int>> swi(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      swi[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> s_c(m);
    for (int j = 0; j < n; j++) {
      if (bit >> j & 1) {
        for (int i = 0; i < m; i++) {
          for (int k = 0; k < swi[i].size(); k++) {
            if (swi[i][k] == j + 1) s_c[i]++;
          }
        }
      }
    }
    for (int i = 0; i < m; i++) {
      s_c[i] %= 2;
      if (s_c[i] != p[i])
        break;
      else {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
