#P6695. 谷歌翻(sheng)译(cao)机(加强版)

谷歌翻(sheng)译(cao)机(加强版)

Description

Note: For convenience, in the following, all strings are 1-indexed, i.e. positions start from 11.

Xiao L treats the original text before each meme-making and the result after meme-making as two strings AA and BB, both consisting only of lowercase letters.

We define a “split sequence” and “split substring” as follows:

  • For a string of length nn, a “split sequence” is defined as: there exists a sequence pp of length k+2k+2 such that 0=p0<p1<p2<...<pk<pk+1=n+10=p_0<p_1<p_2<...<p_k<p_{k+1}=n+1. For a split sequence, its “split substrings” are the substrings formed by the characters from position pi+1p_i+1 to pi+11p_{i+1}-1 (i[0,k]i \in[0,k]) (they can be empty strings). Clearly, for a split sequence of length k+2k+2, there are k+1k+1 split substrings in total.

  • For the same string, two split sequences (pp and qq) are different if and only if the lengths of the two sequences are different (k1k2k_1\neq k_2), or there exists an ii such that piqip_i\neq q_i.

Different people may have different interpretation methods for the same original text and result. We define an interpretation method as follows:

  • For strings AA and BB, we find one split sequence for each of them (pp and qq). These two split sequences must satisfy:
  1. The two split sequences have the same length (k1=k2k_1=k_2).
  2. For any ii, A[pi]=B[qi]A[p_i]=B[q_i], i.e. the character at position pip_i in AA is the same as the character at position qiq_i in BB.
  • Define the “meme level” (shengcao degree) of this interpretation method as the sum of the tt-th powers of the lengths of all split substrings in the two strings, i.e. $\sum\limits_{i=0}^{k_1}(p_{i+1}-p_i-1)^t+\sum\limits_{i=0}^{k_2}(q_{i+1}-q_i-1)^t$.

  • Two interpretation methods are different if and only if their pp are different, or their qq are different.

Xiao L wants to know the sum of the meme levels over all interpretation methods. Since he (also) does not like the number 998244353998244353, he does not want you to tell him the result as that number, so you need to take the result modulo 998244353998244353.

Input Format

The first line contains three positive integers n,m,tn,m,t.

The next line contains a string of length nn, representing string AA.

The next line contains a string of length mm, representing string BB.

Output Format

One line containing one integer, the answer modulo 998244353998244353.

3 4 2
abc
bacb

74
7 8 5
ccbbacb
bbbdadba
337322
3 4 1000000
abc
bacb

424285944

Hint

For Sample 1, there are the following interpretation methods:

  • p={0,4},q={0,5}p=\{0,4\},q=\{0,5\}, meme level is 2525.
  • p={0,1,4},q={0,2,5}p=\{0,1,4\},q=\{0,2,5\}, meme level is 99.
  • p={0,2,4},q={0,1,5}p=\{0,2,4\},q=\{0,1,5\}, meme level is 1111.
  • p={0,2,4},q={0,4,5}p=\{0,2,4\},q=\{0,4,5\}, meme level is 1111.
  • p={0,3,4},q={0,3,5}p=\{0,3,4\},q=\{0,3,5\}, meme level is 99.
  • p={0,1,2,4},q={0,2,4,5}p=\{0,1,2,4\},q=\{0,2,4,5\}, meme level is 33.
  • p={0,1,3,4},q={0,2,3,5}p=\{0,1,3,4\},q=\{0,2,3,5\}, meme level is 33.
  • p={0,2,3,4},q={0,1,3,5}p=\{0,2,3,4\},q=\{0,1,3,5\}, meme level is 33.

The total meme level is 7474.

Constraints

“This problem uses bundled subtasks.”

  • Subtask 1 ( 20%20\% ): n,m50,t2n,m\leq 50,t\leq 2.
  • Subtask 2 ( 30%30\% ): n,m200,t2n,m\leq 200,t\leq 2.
  • Subtask 3 ( 20%20\% ): t10t\leq 10.
  • Subtask 4 ( 30%30\% ): no special restrictions.

For 100%100\% of the testdata, n,m1000,t1000000n,m\leq 1000,t\leq 1000000, and AA and BB contain only lowercase letters.

Translated by ChatGPT 5