atcoder#ABC242E. [ABC242E] (∀x∀)
[ABC242E] (∀x∀)
Score : points
Problem Statement
Solve the following problem for test cases.
Given an integer and a string , find the number of strings that satisfy all of the conditions below, modulo .
- is a string of length consisting of uppercase English letters.
- is a palindrome.
- in lexicographical order.- That is, or is lexicographically smaller than .
Constraints
- is an integer between and (inclusive).
- In a single input, the sum of over the test cases is at most .
- is a string of length consisting of uppercase English letters.
Input
Input is given from Standard Input in the following format:
Here, represents the -th test case.
Each test case is in the following format:
Output
Print lines. The -th line should contain the answer for the -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 strings satisfying the conditions are AAA
ABA
ACA
AXA
.
Test case #2: may not be a palindrome.
Test case #3: Be sure to find the count modulo .