I,J,R=input,int,range X=I().split() N,Q,P,p,w=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 i,j=r(i),r(j) if i!=j: if w[i]==w[j]:w[j]+=1 if w[i]0: for l in R(L):V[W[l]]=0 M,L,s=0,0,1 while Q>0: Q,X=Q-1,I().split() t=J(X[0]) if t==3: T[M],M=((t,)),M+1 break else: u,v=J(X[1])-1,J(X[2])-1 if V[u]==0:U[u],V[u],W[L],L=L,1,u,L+1 if V[v]==0:U[v],V[v],W[L],L=L,1,v,L+1 T[M],M=((t,u,v)),M+1 n=N*2 p=[i for i in R(n)] w=[0]*n for l in T[:M]: if l[0]==3:print(f) else: if s: u,v=U[l[1]],U[l[2]] t=u+L if l[0]==1:g(u,v),g(t,v+L) else:g(t,v),g(u,v+L) if p[r(u)]==p[r(t)]:s=0 print(pow(2,n//2,P)if s else 0)