#ABC242E. [ABC242E] (∀x∀)

[ABC242E] (∀x∀)

Score : 500500 points

Problem Statement

Solve the following problem for TT test cases.

Given an integer NN and a string SS, find the number of strings XX that satisfy all of the conditions below, modulo 998244353998244353.

  • XX is a string of length NN consisting of uppercase English letters.
  • XX is a palindrome.
  • XSX \le S in lexicographical order.- That is, X=SX=S or XX is lexicographically smaller than SS.

Constraints

  • 1T2500001 \le T \le 250000
  • NN is an integer between 11 and 10610^6 (inclusive).
  • In a single input, the sum of NN over the test cases is at most 10610^6.
  • SS is a string of length NN consisting of uppercase English letters.

Input

Input is given from Standard Input in the following format:

TT

case1\mathrm{case}_1

case2\mathrm{case}_2

\vdots

caseT\mathrm{case}_T

Here, casei\mathrm{case}_i represents the ii-th test case.

Each test case is in the following format:

NN

SS

Output

Print TT lines. The ii-th line should contain the answer for the ii-th test case as an integer.

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.