#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> sw(n, 0);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      sw[s] |= (1 << i);
    }
  }
  int p = 0;
  for (int i = 0; i < m; i++) {
    int temp;
    cin >> temp;
    p |= (i << i) * temp;
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int state = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        state ^= sw[j];
      }
    }
    if (state == p) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
