#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[20];
int s[20][20];
int p[20];
bool bulb[20] = {false};
int Count = 0;
void bfs(int num, bool onoff) {
  if (onoff == true)
    bulb[num] = true;
  else
    bulb[num] = false;
  if (num == N - 1) {
    bool flag = true;
    for (int i = 0; i < M; i++) {
      int bulbCount = 0;
      for (int j = 0; j < k[i]; j++) {
        if (bulb[j] == true) {
          bulbCount++;
        }
      }
      if (bulbCount % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) Count++;
    return;
  }
  bfs(num + 1, false);
  bfs(num + 1, true);
  return;
}
int main() {
  cin >> N >> M;
  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];
  }
  bfs(0, true);
  bfs(0, false);
  cout << Count << endl;
}
