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