I,J,R=input,int,range X=I().split() N,Q,P,p=J(X[0]),J(X[1]),998244353,[] def r(i): m=p[i] while i!=m: p[i]=i=p[m] m=p[i] return i n=0 def g(i,j): global n if p[r(i)]!=r(j):p[r(i)],n=r(j),n-1 U=[0]*N while Q>0: V,T,L,s=set(),[],0,1 while Q>0: Q,X=Q-1,I().split() t,A=J(X[0]),T.append if t==3: A((t,)) break else: u,v=J(X[1])-1,J(X[2])-1 V.add(u),V.add(v),A((t,u,v)) for u in V:U[u],L=L,L+1 n=N*2 p=[i for i in R(n)] for l in T: if l[0]==3:print(pow(2,N,P)) else: if s: u,v=U[l[1]],U[l[2]] w=u+L if l[0]==1:g(u,v),g(w,v+L) else:g(w,v),g(u,v+L) if p[r(u)]==p[r(w)]:s=0 print(pow(2,n//2,P)if s else 0)