#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int S[10][10];
  int P[10];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int index;
      cin >> index;
      index--;
      S[i][index] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<10> bit(tmp);
    bool true_f = true;
    for (int i = 0; i < M; i++) {
      int on_switch_Count = 0;
      for (int j = 0; j < N; j++) {
        if (bit[j]) {
          on_switch_Count += S[i][j];
        }
      }
      true_f &= (on_switch_Count % 2 == P[i]);
    }
    if (true_f) {
      ans++;
    }
  }
  cout << ans << endl;
}
