#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N, M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(10, 0));
  for (int i = 0; i < M; i++) {
    cin >> k.at(i);
    for (int j = 0; j < k.at(i); j++) {
      cin >> s.at(i).at(j);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p.at(i);
  }
  int count = 0;
  for (int a = 0; a < 2; a++) {
    for (int b = 0; b < 2; b++) {
      for (int c = 0; c < 2; c++) {
        for (int d = 0; d < 2; d++) {
          for (int e = 0; e < 2; e++) {
            for (int f = 0; f < 2; f++) {
              for (int g = 0; g < 2; g++) {
                for (int h = 0; h < 2; h++) {
                  for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                      vector<int> vec(10);
                      vec.at(0) = a;
                      vec.at(1) = b;
                      vec.at(2) = c;
                      vec.at(3) = d;
                      vec.at(4) = e;
                      vec.at(5) = f;
                      vec.at(6) = g;
                      vec.at(7) = h;
                      vec.at(8) = i;
                      vec.at(9) = j;
                      int counted = 0;
                      for (int x = 0; x < M; x++) {
                        int eo = 0;
                        for (int y = 0; y < k.at(x); y++) {
                          if (vec.at(s.at(x).at(y) - 1) == 1) {
                            eo++;
                          }
                        }
                        if (eo % 2 == p.at(x)) {
                          counted++;
                        }
                      }
                      if (counted == M) {
                        count++;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  int tyo = 1;
  for (int i = 0; i < 12 - N; i++) {
    tyo *= 2;
  }
  cout << count / tyo << endl;
}
