#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(12, vector<int>(12));
  vector<int> P(M);
  vector<int> K(M);
  int k;
  for (int i = 0; i < (int)(M); i++) {
    cin >> K[i];
    int a = K[i];
    for (int j = 0; j < (int)(a); j++) {
      cin >> S[i][j];
    }
  }
  for (int i = 0; i < (int)(M); i++) cin >> P[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool flag = true;
    for (int i = 0; i < (int)(M); i++) {
      int num = 0;
      int k = K[i];
      for (int j = 0; j < (int)(k); j++) {
        int now = S[i][j - 1];
        if (bit & (1 << now)) num++;
      }
      if (num % 2 != P[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
