#P7525. Shelter

Shelter

Description

During her time in space, besides creating freely in the virtual world, Rin also plays an interesting little game every day.

When she first arrived in space, her father left her a non-empty string ss consisting of lowercase English letters, with length nn. Every day, Rin finds the largest integer ii (0i<s0 \le i < |s|) such that the prefix of length ii and the suffix of length ii of the string are the same (note that ii may be 00), and then appends this prefix/suffix to the end of the whole string to form a new string. For example, when the string is mivikismivik, the largest i=5i = 5 (both the prefix and suffix of length 55 are mivik), so Rin appends mivik to the end of the string, forming the new string mivikismivikmivik.

After spending KK days in space, this string has become very long. Rin is suddenly curious about what the length of the string is now. Can you help her? Since the answer may be very large, you only need to output the result modulo 998244353998244353.

Input Format

The first line contains two positive integers n,Kn, K, representing the length of the initial string and the number of days Rin has spent in space.

The second line contains a string ss of length nn consisting of lowercase English letters, representing the string left to Rin by her father.

Output Format

Output one integer in one line, representing the length of the string after KK days modulo 998244353998244353.

7 1
abcdabc
10
5 2
ioioi
11
8 50
idolidol
263923940

Hint

Sample Explanation

Sample 1: After one operation, the string becomes abcdabcabc, with length 1010.

Sample 2: After one operation, the string becomes ioioiioi, and after another operation it becomes ioioiioiioi, with length 1111.

Constraints

For all testdata, 1n21061 \le n \le 2 \cdot 10^6, 1K10181 \le K \le 10^{18}.

Subtask 1 (15 pts): ss consists of only one kind of letter.

Subtask 2 (20 pts): ss has a proper period whose length is not s|s| (i.e. a period whose length is a divisor of s|s|).

Subtask 3 (65 pts): No special constraints.

Translated by ChatGPT 5