Gromah is playing PingPong with PJ King. However, Gromah is poor at PingPong and it's difficult for him to beat PJ King in the normal way. So Gromah has to cheat and steal, which is to let PJ King send some points and then change the winning points in one game after the end of the match.
Gromah and PJ King have played

times totally, and the results were all recorded as a string

only containing "W"(denoting Gromah wins this point) and "L"(denoting PJ King wins this point). Now Gromah wants to know that for all

, how many games he can win if the winning point equals

in one game(denoted by
)
), and you can determine
)
in following procedure:
(1). Check if there is any prefix in current

satisfying
%20%5Cge%20i%2C%20%7Ccnt_W%20-%20cnt_L%7C%20%5Cge%202)
where

denotes the number of "W"s and "L"s in the prefix respectively.
(2). If no such prefix exists, terminate the procedure regardless of the remaining results.
(3). If exists, choose the shortest prefix among all valid prefixes(denoting one game), and add 1 to
)
iff

. Then remove the chosen prefix from

and turn back to step (1).
Since the output is too large, you should only print one integer
%20%5Ctimes%20(%7CS%7C%20%2B%201)%5E%7Bi-1%7D%20%5Cpmod%7B998244353%7D)
.