N=int(input()) D={};mod=998244353 D['U']=[];D['F']=[];D['W']=[];D['P']=[] def xgcd(a, b): x0, y0, x1, y1 = 1, 0, 0, 1 while b != 0: q, a, b = a // b, b, a % b x0, x1 = x1, x0 - q * x1 y0, y1 = y1, y0 - q * y1 return a, x0, y0 def modinv(a, m): g, x, y = xgcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m al=0;A=[] for _ in range(N): x,y=input().split() y=int(y) al+=y D[x].append(y) a,b,c=0,0,0 zz=modinv(N-1,mod) for u in D['U']: x=pow(N-1,u,mod) y=pow(N-2,u,mod) z=pow(zz,u,mod) d=(x-y)*z%mod a+=d a%=mod for u in D['F']: x=pow(N-1,u,mod) y=pow(N-2,u,mod) z=pow(zz,u,mod) d=(x-y)*z%mod b+=d b%=mod for u in D['W']: x=pow(N-1,u,mod) y=pow(N-2,u,mod) z=pow(zz,u,mod) d=(x-y)*z%mod c+=d c%=mod d=pow(N-1,al,mod) ans=a ans*=b ans%=mod ans*=c ans%=mod ans*=d ans%=mod ans*=len(D['P']) ans%=mod print(ans)