#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int data[11][11];
  for (int i = 0; i < M; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int S;
      cin >> S;
      data[i][S - 1] = 1;
    }
  }
  vector<int> p;
  for (int i = 0; i < M; i++) {
    int P;
    cin >> P;
    p.push_back(P);
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool okay = true;
    for (int i = 0; i < M; i++) {
      int on = 0;
      for (int j = 0; j < N; j++) {
        if ((bit & (1 << j)) && data[i][j] == 1) on++;
      }
      if (on % 2 != p.at(i)) {
        okay = false;
        break;
      }
    }
    if (okay) ans++;
  }
  cout << ans << endl;
}
