#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = (int)(0); i < (int)(M); i++) {
    int k;
    cin >> k;
    for (int j = (int)(0); j < (int)(k); j++) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  vector<int> p(M);
  for (int i = (int)(0); i < (int)(M); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = (int)(0); bit < (int)(1 << N); bit++) {
    for (int i = (int)(0); i < (int)(N); i++) {
      if (bit & 1 << i) {
        for (int j = (int)(0); j < (int)(M); j++)
          for (int k = (int)(0); k < (int)(S[j].size()); k++) {
            if (S[j][k] == i) S[j][k] = 0;
          }
      }
    }
    bool ok = true;
    for (int i = (int)(0); i < (int)(M); i++) {
      int cnt = 0;
      for (int j = (int)(0); j < (int)(S[i].size()); j++) {
        if (S[i][j] == 0) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
