Embeddings

길이 10^6 이하의 문자열에서 서로 엄격히 포함되는 회문 부분문자열의 중첩 수열 개수를 998244353으로 나눈 나머지를 구한다.

어려움9문자열동적 계획법문자열 매칭조합론아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Given a string AA of length nn. Consider palindromic substrings of this string. Each palindromic substring is defined by its starting position ss and its end ee (1sen1 \le s \le e \le n) such that letters in AA starting at position ss and ending at position ee, inclusive, form a palindrome (i.e. A\[s+i]=A\[ei]A\[s+i]=A\[e-i] for any integer ii between 0 and ese-s, inclusive).

Let's define an embedding of depth k1k \ge 1 as a sequence of kk palindromic substrings of AA with the following property: s_1<<s_ks\_1 < \ldots < s\_k and e_1>>e_ke\_1 > \ldots > e\_k, i.e. palindromes in the embedding are strictly contained in each other like the Russian dolls.

Given AA, count the number of possible embeddings. Since this number can be too large, calculate it modulo 998,244,353998\\,244\\,353.

입력

The input consists of a single line containing the string AA. The string is non-empty and consists of no more than 10610^6 lowercase English letters.

출력

Print the number of possible embeddings modulo 998,244,353998\\,244\\,353.

힌트

For the sample input 1, we have nine embeddings of depth 1 (1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 2-4, 4-6, 1-5), six embeddings of depth 2 (3-3 in 2-4, 5-5 in 4-6, 2-2 in 1-5, 3-3 in 1-5, 4-4 in 1-5, 2-4 in 1-5), and one embedding of depth 3 (3-3 in 2-4 in 1-5), with 9+6+1=169+6+1=16  embeddings in total.