#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI = acos(-1);
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(M);
  for (int i = 0; i < (M); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); j++) {
      int s;
      cin >> s;
      s--;
      A[i].push_back(s);
    }
  }
  vector<int> pair<int, int>;
  for (int i = 0; i < (M); i++) {
    int p;
    cin >> p;
    pair<int, int>.push_back(p);
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> C(M, 0);
    for (int m = 0; m < (M); m++) {
      for (int i = 0; i < (A[m].size()); i++) {
        if (bit & (1 << i)) {
          C[m]++;
        }
      }
    }
    bool t = true;
    for (int i = 0; i < (M); i++) {
      if (C[i] % 2 != pair<int, int>[i]) t = false;
    }
    if (t) ans++;
  }
  cout << ans << endl;
}
