#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m], s[11][11];
  for (int i = 0; i < (m); i++) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); j++) {
      cin >> s[i][j];
    }
  }
  int p[m];
  for (int i = 0; i < (m); i++) cin >> p[i];
  int S[11] = {};
  int cnt = 0;
  for (S[1] = 0; S[1] <= 1; S[1]++) {
    for (S[2] = 0; S[2] <= 1; S[2]++) {
      for (S[3] = 0; S[3] <= 1; S[3]++) {
        for (S[4] = 0; S[4] <= 1; S[4]++) {
          for (S[5] = 0; S[5] <= 1; S[5]++) {
            for (S[6] = 0; S[6] <= 1; S[6]++) {
              for (S[7] = 0; S[7] <= 1; S[7]++) {
                for (S[8] = 0; S[8] <= 1; S[8]++) {
                  for (S[9] = 0; S[9] <= 1; S[9]++) {
                    for (S[10] = 0; S[10] <= 1; S[10]++) {
                      int cnt_s[m];
                      for (int i = 0; i < (m); i++) {
                        for (int j = 0; j < (k[i]); j++) {
                          if (S[s[i][j]] == 1) cnt_s[i]++;
                        }
                      }
                      bool light = true;
                      for (int i = 0; i < (m); i++) {
                        if (cnt_s[i] % 2 != p[i]) light = false;
                      }
                      if (light == true) cnt++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << cnt / pow(2, 10 - n - 1) << endl;
}
