#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> sw(n, 0);
  long long p, ans = 0;
  for (long long i = 0; i < m; i++) {
    long long x;
    cin >> x;
    for (long long j = 0; j < x; i++) {
      long long y;
      cin >> y;
      y--;
      sw[y] += 1 << i;
    }
  }
  for (long long i = 0; i < m; i++) p += 1 << i;
  for (long long bit = 0; bit < 1 << n; bit++) {
    long long tmp = 0;
    for (long long i = 0; i < n; i++) {
      if (bit >> i & 1) tmp ^= sw[i];
    }
    if (tmp == p) ans++;
  }
  cout << ans << endl;
}
