#include <bits/stdc++.h>
using namespace std;
struct LB {
  int NumofSw;
  int sw = 0;
  bool isOnwhenOdd = 0;
};
int bitcount(int bits) {
  bits = (bits & 0x5555) + (bits >> 1 & 0x5555);
  bits = (bits & 0x3333) + (bits >> 2 & 0x3333);
  bits = (bits & 0x0f0f) + (bits >> 4 & 0x0f0f);
  bits = (bits & 0x00ff) + (bits >> 8 & 0x00ff);
  return bits;
}
int main() {
  int N, M;
  cin >> N >> M;
  bool AllOn = false;
  vector<LB> LBs(M);
  int temp;
  for (int i = 0; i < M; i++) {
    cin >> LBs[i].NumofSw;
    for (int j = 0; j < LBs[i].NumofSw; j++) {
      cin >> temp;
      LBs[j].sw |= (1 << (temp - 1));
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> LBs[i].isOnwhenOdd;
  }
  int looptime = 1;
  for (int i = 0; i < N; i++) {
    looptime *= 2;
  }
  int count = 0;
  for (int i = 0; i < looptime; i++) {
    int tempcount = 0;
    for (int j = 0; j < M; j++) {
      if (bitcount(LBs[j].sw & i) % 2 == LBs[j].isOnwhenOdd) tempcount++;
    }
    if (tempcount == M) count++;
  }
  cout << count << endl;
  return 0;
}
