Time Limit: 2 sec / Memory Limit: 1024 MB
TT\mathrm{case}_1case1\mathrm{case}_2case2\vdots⋮\mathrm{case}_TcaseTHere, \mathrm{case}_icasei represents the ii-th test case.
NNSS
5
3
AXA
6
ABCZAZ
30
QWERTYUIOPASDFGHJKLZXCVBNMQWER
28
JVIISNEOXHSNEAAENSHXOENSIIVJ
31
KVOHEEMSOZZASHENDIGOJRTJVMVSDWW
24
29
212370247
36523399
231364016
This input contains five test cases.
Test case #1:
The 2424 strings satisfying the conditions are AAA,, ABA,, ACA,...,,..., AXA.
Test case #2:
SS may not be a palindrome.
Test case #3:
Be sure to find the count modulo 998244353998244353.