#include <bits/stdc++.h>
using namespace std;
bool compare_by_b(pair<string, int> a, pair<string, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  int k[M + 10];
  int s[M + 10][N + 10];
  int p[M + 10];
  for (int i = 1; i < M + 1; i++) {
    cin >> k[i];
    for (int j = 1; j < k[i] + 1; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i < M + 1; i++) {
    cin >> p[i];
  }
  int answer = 0;
  for (int i = 0; i < pow(2, N); i++) {
    bool flag = true;
    for (int j = 1; j < M + 1; j++) {
      int sum = 0;
      for (int q = 1; q < k[j] + 1; q++) {
        sum += (i >> s[j][q]) % 2;
      }
      if (sum % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      answer += 1;
    }
  }
  cout << answer << endl;
}
