#include <bits/stdc++.h>
using namespace std;
int N, M, H, W, K, A, B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
  cin >> N >> M;
  vector<vector<bool> > vecs(M, vector<bool>(10, false));
  int s;
  for (int i = 0; i < M; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> s;
      vecs.at(i).at(j) = true;
    }
  }
  vector<int> p(M, 0);
  for (int i = 0; i < M; i++) cin >> p.at(i);
  int one_ofN = 1;
  for (int i = 0; i < N; i++) one_ofN *= 2;
  int onoff;
  vector<int> nowswitch(N, 0);
  int temp, ans = 0;
  bool flash;
  int tempi;
  for (int i = 0; i < one_ofN; i++) {
    flash = true;
    tempi = i;
    for (int x = 0; x < N; x++) {
      onoff = tempi & 1;
      nowswitch.at(x) = onoff;
      tempi >>= 1;
    }
    for (int j = 0; j < M; j++) {
      temp = 0;
      for (int k = 0; k < 10; k++) {
        if (vecs.at(j).at(k)) temp += nowswitch.at(k);
      }
      temp = (temp + 2) % 2;
      if (temp != p.at(j)) {
        flash = false;
        break;
      }
    }
    if (flash) ans++;
  }
  cout << ans << endl;
}
