M=998244353 n,m=map(int,input().split()) p=[*range(n*m)] c=[1]*n*m def R(x): while x!=p[x]:x=p[x] return x def U(u,v): u,v=R(u),R(v) if u==v:return 499122177 if c[u]