#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int N, M, ans = 0;
  cin >> N >> M;
  vector<int> K(M), P(M);
  vector<vector<int>> vec(M, vector<int>(N));
  for (int i = 0; i < (M); i++) {
    cin >> K[i];
    for (int k = 0; k < (K[i]); k++) cin >> vec[i][k];
  }
  for (int i = 0; i < (M); i++) cin >> P[i];
  for (int bit = 0; bit < (1 << N); ++bit) {
    bool flg = true;
    for (int m = 0; m < M; ++m) {
      int tmp = 0;
      for (int k = 0; k < (K[m]); k++) {
        if (bit & (1 << k)) {
          tmp++;
        }
      }
      if (tmp % 2 != P[m]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ans++;
    }
  }
  cout << ans << "\n";
}
