#include <bits/stdc++.h>
using namespace std;
int N = 0, M = 0, k = 0;
long long ans = 0;
int main() {
  cin >> N >> M;
  vector<vector<int>> S(M, vector<int>(M));
  int K[M];
  int P[M];
  for (int m = 0; m < (int)(M); m++) {
    cin >> K[m];
    for (int i = 0; i < (int)(K[m]); i++) {
      cin >> S[m][i];
    }
  }
  for (int m = 0; m < (int)(M); m++) {
    cin >> P[m];
  }
  for (int mask = 0; mask < (int)(1 << N); mask++) {
    bool flag[N];
    for (int n = 0; n < (int)(N); n++) {
      if (mask & (1 << n))
        flag[n] = true;
      else
        flag[n] = false;
    }
    bool check = true;
    for (int m = 0; m < (int)(M); m++) {
      int sum_flag = 0;
      for (int idx = 0; idx < (int)(K[m]); idx++) {
        sum_flag += flag[S[m][idx] - 1];
      }
      if (sum_flag % 2 != P[m]) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
}
