import math import sys readline=sys.stdin.readline mod=998244353 def NTT(polynomial0,polynomial1): """ if len(polynomial0)*len(polynomial1)<=50: poly=[0]*(len(polynomial0)+len(polynomial1)-1) for i in range(len(polynomial0)): for j in range(len(polynomial1)): poly[i+j]+=polynomial0[i]*polynomial1[j]%mod poly[i+j]%=mod return poly """ if mod==998244353: prim_root=3 prim_root_inve=332748118 else: prim_root=Primitive_Root(mod) prim_root_inve=MOD(mod).Pow(prim_root,-1) def DFT(polynomial,n,inverse=False): if inverse: for bit in range(1,n+1): a=1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<=0: x,y=1,0 else: x,y=-1,0 for i in range(len(stack)-1,-1,-1): n,m=stack[i] x,y=y,x-(n//m)*y return x,y class MOD: def __init__(self,p,e=None): self.p=p self.e=e if self.e==None: self.mod=self.p else: self.mod=self.p**self.e def Pow(self,a,n): a%=self.mod if n>=0: return pow(a,n,self.mod) else: assert math.gcd(a,self.mod)==1 x=Extended_Euclid(a,self.mod)[0] return pow(x,-n,self.mod) def Build_Fact(self,N): assert N>=0 self.factorial=[1] if self.e==None: for i in range(1,N+1): self.factorial.append(self.factorial[-1]*i%self.mod) else: self.cnt=[0]*(N+1) for i in range(1,N+1): self.cnt[i]=self.cnt[i-1] ii=i while ii%self.p==0: ii//=self.p self.cnt[i]+=1 self.factorial.append(self.factorial[-1]*ii%self.mod) self.factorial_inve=[None]*(N+1) self.factorial_inve[-1]=self.Pow(self.factorial[-1],-1) for i in range(N-1,-1,-1): ii=i+1 while ii%self.p==0: ii//=self.p self.factorial_inve[i]=(self.factorial_inve[i+1]*ii)%self.mod def Fact(self,N): if N<0: return 0 retu=self.factorial[N] if self.e!=None and self.cnt[N]: retu*=pow(self.p,self.cnt[N],self.mod)%self.mod retu%=self.mod return retu def Fact_Inve(self,N): if self.e!=None and self.cnt[N]: return None return self.factorial_inve[N] def Comb(self,N,K,divisible_count=False): if K<0 or K>N: return 0 retu=self.factorial[N]*self.factorial_inve[K]%self.mod*self.factorial_inve[N-K]%self.mod if self.e!=None: cnt=self.cnt[N]-self.cnt[N-K]-self.cnt[K] if divisible_count: return retu,cnt else: retu*=pow(self.p,cnt,self.mod) retu%=self.mod return retu def Tonelli_Shanks(N,p): if pow(N,p>>1,p)==p-1: retu=None elif p%4==3: retu=pow(N,(p+1)//4,p) else: for nonresidue in range(1,p): if pow(nonresidue,p>>1,p)==p-1: break pp=p-1 cnt=0 while pp%2==0: pp//=2 cnt+=1 s=pow(N,pp,p) retu=pow(N,(pp+1)//2,p) for i in range(cnt-2,-1,-1): if pow(s,1<>1+i,p) s%=p retu*=pow(nonresidue,p>>2+i,p) retu%=p return retu def FFT(polynomial0,polynomial1,digit=10**5): def DFT(polynomial,n,inverse=False): if inverse: primitive_root=[math.cos(-i*2*math.pi/(1<self.max_degree+1: self.polynomial=polynomial[:self.max_degree+1] else: self.polynomial=polynomial self.mod=mod self.eps=eps def __eq__(self,other): if type(other)!=Polynomial: return False if len(self.polynomial)!=len(other.polynomial): return False for i in range(len(self.polynomial)): if self.epsself.max_degree+1: prod=prod[:self.max_degree+1] while prod and abs(prod[-1])<=self.eps: prod.pop() prod=Polynomial(prod,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return prod def __pow__(self,other): if other==0: prod=Polynomial([1],max_degree=self.max_degree,eps=self.eps,mod=self.mod) elif other==1: prod=Polynomial([x for x in self.polynomial],max_degree=self.max_degree,eps=self.eps,mod=self.mod) else: prod=[1] doub=self.polynomial if self.mod: convolve=NTT convolve_Pow=NTT_Pow else: convolve=FFT convolve_Pow=FFT_Pow while other>=2: if other&1: prod=convolve(prod,doub) if self.max_degree!=-1: prod=prod[:self.max_degree+1] doub=convolve_Pow(doub,2) if self.max_degree!=-1: doub=doub[:self.max_degree+1] other>>=1 prod=convolve(prod,doub) if self.max_degree!=-1: prod=prod[:self.max_degree+1] prod=Polynomial(prod,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return prod def __truediv__(self,other): if type(other)==Polynomial: assert other.polynomial for n in range(len(other.polynomial)): if self.epsn for i in range(n): assert abs(self.polynomial[i])<=self.eps self_polynomial=self.polynomial[n:] other_polynomial=other.polynomial[n:] if self.mod: inve=MOD(self.mod).Pow(other_polynomial[0],-1) else: inve=1/other_polynomial[0] quot=[] for i in range(len(self_polynomial)-len(other_polynomial)+1): if self.mod: quot.append(self_polynomial[i]*inve%self.mod) else: quot.append(self_polynomial[i]*inve) for j in range(len(other_polynomial)): self_polynomial[i+j]-=other_polynomial[j]*quot[-1] if self.mod: self_polynomial[i+j]%=self.mod for i in range(max(0,len(self_polynomial)-len(other_polynomial)+1),len(self_polynomial)): if self.eps>bit,self.mod) U=[1] for _ in range(a): U.append(U[-1]*x%self.mod) for i in range(1<>bit,self.mod) U=[1] for _ in range(a): U.append(U[-1]*x%self.mod) for i in range(1<self.eps: for i in range(len(quot)): quot[i]*=other if self.mod: quot[i]%=self.mod quot=Polynomial(quot,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return quot def __floordiv__(self,other): assert type(other)==Polynomial quot=[0]*(len(self.polynomial)-len(other.polynomial)+1) rema=[x for x in self.polynomial] if self.mod: inve=MOD(self.mod).Pow(other.polynomial[-1],-1) for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve%self.mod for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] rema[i+j]%=self.mod else: inve=1/other.polynomial[-1] for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] quot=Polynomial(quot,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return quot def __mod__(self,other): assert type(other)==Polynomial quot=[0]*(len(self.polynomial)-len(other.polynomial)+1) rema=[x for x in self.polynomial] if self.mod: inve=MOD(self.mod).Pow(other.polynomial[-1],-1) for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve%self.mod for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] rema[i+j]%=self.mod else: inve=1/other.polynomial[-1] for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] while rema and abs(rema[-1])<=self.eps: rema.pop() rema=Polynomial(rema,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return rema def __divmod__(self,other): assert type(other)==Polynomial quot=[0]*(len(self.polynomial)-len(other.polynomial)+1) rema=[x for x in self.polynomial] if self.mod: inve=MOD(self.mod).Pow(other.polynomial[-1],-1) for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve%self.mod for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] rema[i+j]%=self.mod else: inve=1/other.polynomial[-1] for i in range(len(self.polynomial)-len(other.polynomial),-1,-1): quot[i]=rema[i+len(other.polynomial)-1]*inve for j in range(len(other.polynomial)): rema[i+j]-=quot[i]*other.polynomial[j] while rema and abs(rema[-1])<=self.eps: rema.pop() quot=Polynomial(quot,max_degree=self.max_degree,eps=self.eps,mod=self.mod) rema=Polynomial(rema,max_degree=self.max_degree,eps=self.eps,mod=self.mod) return quot,rema def __neg__(self): if self.mod: nega=Polynomial([(-x)%self.mod for x in self.polynomial],max_degree=self.max_degree,eps=self.eps,mod=self.mod) else: nega=Polynomial([-x for x in self.polynomial],max_degree=self.max_degree,eps=self.eps,mod=self.mod) return nega def __pos__(self): posi=Polynomial([x for x in self.polynomial],max_degree=self.max_degree,eps=self.eps,mod=self.mod) return posi def __bool__(self): return self.polynomial def __getitem__(self,n): if type(n)==int: if n<=len(self.polynomial)-1: return self.polynomial[n] else: return 0 else: return Polynomial(polynomial=self.polynomial[n],max_degree=self.max_degree,eps=self.eps,mod=self.mod) def __setitem__(self,n,a): if self.mod: a%=self.mod if self.max_degree==-1 or n<=self.max_degree: if n<=len(self.polynomial)-1: self.polynomial[n]=a elif self.eps=self.eps: n0=self.polynomial[cnt0]**.5 if n0==None: sqrt=None else: def f(prev): if self.mod: return NTT_Pow(prev,2)+[0] else: return FFT_Pow(prev,2)+[0] def differentiated_f(prev): retu=[0]*(2*len(prev)-1) for i in range(len(prev)): retu[i]+=2*prev[i] if self.mod: retu[i]%self.mod return retu sqrt=[0]*(cnt0//2)+Polynomial(self.polynomial[cnt0:],max_degree=self.max_degree-cnt0//2,mod=self.mod).Newton(n0,f,differentiated_f).polynomial sqrt=Polynomial(sqrt,max_degree=self.max_degree,eps=self.eps,mod=self.mod) else: sqrt=Polynomial([],max_degree=self.max_degree,eps=self.eps,mod=self.mod) return sqrt def exp(self): assert not self.polynomial or abs(self.polynomial[0])<=self.eps def f(prev,poly): newton=Polynomial(prev,max_degree=2*len(prev)-1,eps=self.eps,mod=self.mod).log().polynomial newton+=[0]*(2*len(prev)-len(newton)) for i in range(min(len(poly),len(newton))): newton[i]-=poly[i] if self.mod: for i in range(len(newton)): newton[i]%=self.mod if self.mod: return NTT(prev,newton)[:2*len(prev)] else: return FFT(prev,newton)[:2*len(prev)] return Polynomial(self.polynomial,max_degree=self.max_degree,mod=self.mod).Newton(1,f) def Degree(self): return len(self.polynomial)-1 N=int(readline()) mod=998244353 MD=MOD(mod) MD.Build_Fact(N-2) poly=Polynomial([(c+1)*MD.Fact_Inve(c)%mod for c in range(N-1)],max_degree=N-2,mod=mod) poly=poly.log() for i in range(len(poly)): poly[i]*=N poly[i]%=mod poly=poly.exp() ans=poly[N-2]*MD.Fact(N-2)%mod*pow(N,(mod-2)*(N-2),mod)%mod print(ans)