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