#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int N, M;
  vector<int> k;
  cin >> N >> M;
  vector<vector<int>> s;
  vector<int> p;
  k.resize(M);
  p.resize(M);
  s.resize(M, vector<int>(N));
  for (int i = 0; i < (M); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < (M); ++i) cin >> p[i];
  vector<vector<int>> s_onoff;
  s_onoff.resize(M, vector<int>(N));
  for (int i = 0; i < (M); ++i) {
    for (int j = 0; j < (N); ++j) {
      s_onoff[i][j] = -1;
    }
  }
  for (int i = 0; i < (M); ++i) {
    for (int j = 0; j < (k[i]); ++j) {
      s_onoff[i][s[i][j] - 1] = 0;
    }
  }
  queue<int> q_s;
  int num, val;
  int l;
  int count_patern = 0;
  bool result = true;
  for (int i = 0; i < (pow(2, N)); ++i) {
    num = i;
    while (num >= 1) {
      q_s.push(num % 2);
      num /= 2;
    }
    while (q_s.size() < N) {
      q_s.push(0);
    }
    l = 0;
    while (!q_s.empty()) {
      val = q_s.front();
      q_s.pop();
      for (int j = 0; j < (M); ++j) {
        if (s_onoff[j][l] != -1) {
          s_onoff[j][l] = val;
        }
      }
      l++;
    }
    int count_on = 0;
    for (int j = 0; j < (M); ++j) {
      for (int o = 0; o < (N); ++o) {
        if (s_onoff[j][o] == 1) {
          count_on++;
        }
      }
      if (count_on % 2 != p[j]) {
        result = false;
        break;
      }
    }
    if (result) {
      count_patern++;
    } else {
      result = true;
    }
  }
  cout << count_patern << endl;
}
