J. Just Another FFT Problem
time limit per test
0.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Recently, Justin have learned the FFT (Fast Fourier Transform) algorithm. To show his understanding of the related topics, he creates the following problem for you to solve.

You are given two strings $$$S$$$ and $$$T$$$ containing only lowercase English letters. The length of the two strings can be defined as $$$|S|$$$ and $$$|T|$$$, respectively. The indices of $$$S$$$ and $$$T$$$ start at 1. We use $$$S_i$$$ to denote the $$$i^{th}$$$ character of $$$S$$$ and similarly $$$T_i$$$ for the $$$i^{th}$$$ character of $$$T$$$.

Justin defines a new operator $$$\otimes$$$, which can by applied to these two strings. The result of $$$S \otimes T$$$ is an array $$$A$$$ of length $$$|S| + |T| - 1$$$. The value of $$$A_i$$$ for $$$i = 1$$$ to $$$|S| + |T| - 1$$$ is:

$$$$$$ \large A_i = \sum_{k = \max(1, i - |T| + 1)}^{\min(i, |S|)} [S_{k} = T_{i - k + 1}] $$$$$$

Here $$$[...]$$$ is the Iverson bracket. $$$[P]$$$ is defined to be 1 if $$$P$$$ is true, and 0 if it is false.

Justin wants you to calculate the resulting array. For simplicity, he also gives you an integer $$$M$$$ to compress the array, so you only need to output a single integer $$$ans$$$, which can be calculated by the following formula:

$$$$$$ \large ans = (\sum_{k=1}^{|S| + |T| - 1} A_k \cdot M^{k - 1}) \mod 998244353 $$$$$$

Input

The first two lines contain two strings, $$$S$$$ and $$$T$$$ ($$$1 \leq |S|, |T| \leq 5 \times 10^5$$$).

The third line contains one integer $$$M$$$ ($$$1 \leq M \leq 10^6$$$).

Output

Output a single integer, $$$ans$$$.

Examples
Input
puila
tiu
3
Output
54
Input
fft
justforfun
10
Output
110210000
Note

In the first example, there are only two characters appear in both strings:

  • The $$$2^{nd}$$$ character of $$$S$$$ is equal to the $$$3^{rd}$$$ character of $$$T$$$
  • The $$$3^{rd}$$$ character of $$$S$$$ is equal to the $$$2^{nd}$$$ character of $$$T$$$

So $$$A_4 = 2$$$ and $$$ans = 2 \times 3^3 = 54$$$.