#arc171f. F - Both Reversible

F - Both Reversible

Score: 11001100 points

问题陈述

当一个字符串 TT 满足以下条件时,我们称它为一个好字符串

  • 存在一对字符串 (A,B)(A, B) 满足以下所有条件:
    • AABB 都不为空。
    • A+B=TA + B = T
    • A+rev(B)A + \mathrm{rev}(B)rev(A)+B\mathrm{rev}(A) + B 都是回文。

这里,A+BA + B 表示按顺序连接字符串 AABB 形成的字符串。 同时,rev(A)\mathrm{rev}(A) 表示将字符串 AA 中的字符顺序反转形成的字符串。

存在一个长度为 NN 的字符串 SS,由小写英文字母和字符 ? 组成。 在将 SS 中的 ? 替换为小写英文字母的 26(number of ?s)26^{(\text{number of ?s})} 种方式中,有多少种会得到一个好字符串?找出这个计数,并对 998244353998244353 取模。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

A string TT is called a good string when it satisfies the following condition:

  • There is a pair of strings (A,B)(A, B) that satisfies all of the following:
    • Both AA and BB are non-empty.
    • A+B=TA + B = T.
    • Both A+rev(B)A + \mathrm{rev}(B) and rev(A)+B\mathrm{rev}(A) + B are palindromes.

Here, A+BA + B denotes the string formed by concatenating strings AA and BB in this order.
Also, rev(A)\mathrm{rev}(A) denotes the string formed by reversing the order of the characters in string AA.

There is a string SS of length NN consisting of lowercase English letters and the character ?.
Among the 26(number of ?s)26^{(\text{number of ?s})} ways to replace the ?s in SS with lowercase English letters, how many result in a good string? Find the count modulo 998244353998244353.

Constraints

  • 2N5×1042 \leq N \leq 5 \times 10^4
  • SS is a string of length NN consisting of lowercase English letters and ?.

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print the number, modulo 998244353998244353, of ways to replace the characters that satisfy the condition in the problem statement.

Sample Input 1

4
?ba?

Sample Output 1

1

The string abab is good, because if we set A=A = ab and B=B = ab, then A+B=A + B = abab, and both A+rev(B)=A + \mathrm{rev}(B) = abba and rev(A)+B=\mathrm{rev}(A) + B = baab are palindromes.
Among the strings that can be formed by replacing the ?s in SS with lowercase English letters, there is only one good string, which is abab.

Sample Input 2

10
?y?x?x????

Sample Output 2

676

Sample Input 3

30
???a?????aab?a???c????c?aab???

Sample Output 3

193994800

Sample Input 4

36
????????????????????????????????????

Sample Output 4

363594614