def naive (n,m): mod=998244353 dp=[[0]*(m+1) for i in range(n+1)] dp[0][0]=1 for i in range(1,n+1): for x in range(m+1): for y in range(m+1): if x&y==y: dp[i][x]+=dp[i-1][y] dp[i][x]%=mod return sum(dp[n])%mod def sol1(n,m): mod=998244353 memo=dict() def dp(m,k,f): if m==0: if k==0 and f==1:return 1 return 0 if (m,k,f) in memo:return memo[m,k,f] ans=0 for bx in range(2): nf=f if nf==0 and m%2==1 and bx==0:nf=1 if nf==1 and m%2==0 and bx==1:nf=0 ans+=dp(m//2,k-bx,nf) ans%=mod memo[m,k,f]=ans return ans ans=0 for k in range(33): ans+=dp(m,k,1)*pow(n,k,mod)%mod ans%=mod return ans from random import randrange as rd cnt=0 while 0: cnt+=1 print(cnt) n=rd(2,1000) m=rd(1,1000) ans1=naive(n,m) ans2=sol1(n,m) if ans1!=ans2: print(n,m) break n,m=map(int,input().split()) print(sol1(n,m))