#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(M);
  int k, s;
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> s;
      v[i].push_back(s);
    }
  }
  int p[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int onnum[M];
  int res = 0;
  for (int a = 0; a <= 1; a++) {
    for (int b = 0; b <= 1; b++) {
      for (int c = 0; c <= 1; c++) {
        for (int d = 0; d <= 1; d++) {
          for (int e = 0; e <= 1; e++) {
            for (int f = 0; f <= 1; f++) {
              for (int g = 0; g <= 1; g++) {
                for (int h = 0; h <= 1; h++) {
                  for (int i = 0; i <= 1; i++) {
                    for (int j = 0; j <= 1; j++) {
                      for (int aa = 0; aa < M; aa++) {
                        onnum[aa] = 0;
                      }
                      bool can = true;
                      for (int x = 0; x < M; x++) {
                        for (auto itr : v[x]) {
                          if (a == 1) {
                            if (itr == 1) onnum[x]++;
                          }
                          if (b == 1) {
                            if (itr == 2) onnum[x]++;
                          }
                          if (c == 1) {
                            if (itr == 3) onnum[x]++;
                          }
                          if (d == 1) {
                            if (itr == 4) onnum[x]++;
                          }
                          if (e == 1) {
                            if (itr == 5) onnum[x]++;
                          }
                          if (f == 1) {
                            if (itr == 6) onnum[x]++;
                          }
                          if (g == 1) {
                            if (itr == 7) onnum[x]++;
                          }
                          if (h == 1) {
                            if (itr == 8) onnum[x]++;
                          }
                          if (i == 1) {
                            if (itr == 9) onnum[x]++;
                          }
                          if (j == 1) {
                            if (itr == 10) onnum[x]++;
                          }
                          if (onnum[x] % 2 != p[x]) {
                            can = false;
                            break;
                          }
                        }
                        if (!can) break;
                      }
                      if (can) res++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << res << endl;
}
