#define MD 998244353 Mint@++n,a,x=1;ll@++k;rrep(i,31)if(k>>i&1)a+=n**i*x,x*=n-1;wt(a);