#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int switchValue;
      cin >> switchValue;
      switchValue--;
      s[i].push_back(switchValue);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  long answer = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool isLightOn = true;
    for (int i = 0; i < M; i++) {
      int onSwitchCount = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (bit & (1 << j)) {
          onSwitchCount++;
        }
      }
      if (onSwitchCount % 2 != p[i]) {
        isLightOn = false;
      }
    }
    if (isLightOn) {
      answer++;
    }
  }
  cout << answer << endl;
}
