#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> switchList(M, vector<int>(0));
  for (int i = 0; i < M; i++) {
    int tk;
    cin >> tk;
    for (int j = 0; j < tk; j++) {
      int ts;
      cin >> ts;
      switchList.at(i).push_back(ts - 1);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p.at(i);
  int temp = 1;
  for (int i = 0; i < N; i++) temp *= 2;
  vector<vector<int>> allList(temp, vector<int>(N, 0));
  for (int i = 0; i < temp; i++) {
    int tr = temp;
    for (int j = 0; j < N; j++) {
      tr /= 2;
      int tq = i % (tr * 2);
      if (tq / tr == 1) allList.at(i).at(j) = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < temp; i++) {
    bool isAllOn = true;
    for (int j = 0; j < M; j++) {
      int ts = 0;
      for (int k = 0; k < switchList.at(j).size(); k++) {
        ts += allList.at(i).at(k);
      }
      if (ts % 2 != p.at(j)) {
        isAllOn = false;
        break;
      }
    }
    if (isAllOn) ans++;
  }
  cout << ans << endl;
}
