#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a par, siz; UnionFind(int N) : par(N), siz(N,1){ rep(i,N) par[i] = i; } int root(int x){ if(par[x]==x) return x; return par[x] = root(par[x]); } bool unite(int x,int y){ x = root(x); y = root(y); if(x==y) return false; if(siz[x]> n >> m; vector> bit(1000); rep(i,n) bit[i].flip(); rep(i,m){ int l; cin >> l; vector> a(2); vector ok(n, false); rep(j,l){ int k; cin >> k; ok[k-1] = true; } rep(j,n) a[ok[j]].push_back(j); for(int x:a[0]){ for(int y:a[1]){ bit[x][y] = bit[y][x] = 0; } } } UnionFind uf(n); int s = n; rep(i,n) rep(j,n) if(bit[i][j]) s -= uf.unite(i,j); cout << mpow(2, s) << '\n'; return 0; }