atcoder#KEYENCE2021F. Keyence Repetition

Keyence Repetition

Score : 10001000 points

Problem Statement

Let ss be the concatenation of NN copies of keyence. Consider deleting zero or more characters from ss and concatenating the remaining characters without changing the order to make a new string ss^{\prime}.

There are 27N2^{7N} ways to choose the positions at which we delete the characters. Among them, how many make ss^{\prime} equal to tt? Find the count modulo 998244353998244353.

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • 1t2.5×1051 \leq |t| \leq 2.5 \times 10^5
  • tt is a string consisting of c, e, k, n, and y.

Input

Input is given from Standard Input in the following format:

NN

tt

Output

Print the number of ways to choose the positions at which we delete the characters so that ss^{\prime} will be equal to tt, modulo 998244353998244353.

2
key
6
  • We have s=s= keyencekeyence.
  • There are six ways to choose the positions at which we delete the characters so that s=s^{\prime}= key.
2
ccc
0
  • There are zero ways to choose the positions at which we delete the characters so that s=s^{\prime}= ccc.
100
keyneeneeeckyycccckkke
275429980
  • Be sure to find the count modulo 998244353998244353.