#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N, M;
  cin >> N >> M;
  V<int> who(M);
  for (int i = 0; i < (int)(M); i++) {
    int n;
    cin >> n;
    for (int _ = 0; _ < (int)(n); _++) {
      int x;
      cin >> x;
      x--;
      who[i] |= 1 << x;
    }
  }
  int ans = 0;
  for (int b = 0; b < (int)(1 << N); b++) {
    bool ok = true;
    for (int i = 0; i < (int)(M); i++) {
      if (__builtin_popcount(b & who[i]) % 2 == 0) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
