class Modulo_Vector_Error(Exception): pass class Modulo_Vector: def __init__(self,v): self.vec=[x%Mod for x in v] self.size=len(v) #出力 def __str__(self): return str(self.vec) def __repr__(self): return str(self) def __bool__(self): return any(self.vec) #+,- def __pos__(self): return self def __neg__(self): return self.__scale__(-1) #加法 def __add__(self,other): if self.size!=other.size: raise Modulo_Vector_Error("2つのベクトルのサイズが異なります. ({}, {})".format(self.size,other.size)) v=self.vec w=other.vec return Modulo_Vector([v[i]+w[i] for i in range(self.size)]) #減法 def __sub__(self, other): return self+(-other) def __rsub__(self, other): return (-self)+other #乗法 def __mul__(self,other): pass def __rmul__(self,other): return self.__scale__(other) #スカラー倍 def __scale__(self,r): v=self.vec v=[r*x for x in v] return Modulo_Vector(v) #内積 def inner(self,other): if self.size!=other.size: raise Modulo_Vector_Error("2つのベクトルのサイズが異なります.({},{})".format(self.size,other.size)) X=0 v=self.vec w=other.vec for i in range(self.size): X+=v[i]*w[i]%Mod return X #累乗 def __pow__(self,n): pass #等号 def __eq__(self,other): return (self.vec==other.vec) def __len__(self): return self.size #不等号 def __neq__(self,other): return not(self==other) def __getitem__(self,index): assert isinstance(index,int) return self.vec[index] def __setitem__(self,index,val): assert isinstance(index,int) self.vec[index]=val class Modulo_Vector_Space: def __init__(self, dim): """ 次元が dim のベクトル空間の部分空間を生成する. """ self.dim=dim self.basis=[] self.__ind=[] def __contains__(self, v): for i,u in zip(self.__ind, self.basis): v-=v[i]*u return not bool(v) def add_vectors(self, *S): for v in S: assert len(v)==self.dim for i,u in zip(self.__ind, self.basis): v-=v[i]*u if bool(v): for j in range(self.dim): if v[j]: self.__ind.append(j) break v=pow(v[j], Mod-2, Mod)*v self.basis.append(v) for k in range(len(self.basis)-1): self.basis[k]-=self.basis[k][j]*v def dimension(self): return len(self.basis) def __le__(self, other): for u in self.basis: if u not in other: return False return True def __ge__(self, other): return other<=self def __eq__(self, other): return (self<=other) and (other<=self) def refresh(self): I=sorted(range(len(self.__ind)), key=lambda i:self.__ind[i]) self.basis=[self.basis[i] for i in I] self.__ind=[self.__ind[i] for i in I] def projection(self, v): for i,u in zip(self.__ind, self.basis): v-=v[i]*u return v #================================================== def solve(): N,M=map(int,input().split()) global Mod; Mod=2 V=Modulo_Vector_Space(N) V.add_vectors(Modulo_Vector([1]*N)) for i in range(M): l,*a=list(map(int,input().split())) y=Modulo_Vector([0]*N) for j in a: y[j-1]=1 V.add_vectors(y) return pow(2,V.dimension(),998244353) #================================================== print(solve())