P29212 [洛谷] [Wdcfr-1] CONsecutive and CONcat (Hard Version)
提高-
题目描述

Problem Description

Lily White is playing with strings. Being a yousei, she is not capable of complex speech. Thus, she likes strings that only contain one kind of letter, she calls such strings of length $x$ a "$x$-CON string". For example, qqqq is a "$4$-CON string", while aaab is not any type of "CON string".

Lily White composed an array $a$. It contains $n$ strings of length $m$ that she will use to herald spring. For each permutation of $1,2,\ldots, n$, let us denote the current permutation as $p=\{p_1,p_2,\cdots,p_n\}$. Lily White concatenates all the strings in array $a$ in the order of $a_{p_1},a_{p_2},\cdots,a_{p_n}$ into a string $s$ of length $nm$.

As she likes $k$-CON strings, she wants to know the sum of the number of "$k$-CON string" in all non-empty substrings of $s$ composed by all $n!$ permutations. Since the answer may be enormous, just print the answer taken modulo $998,244,353$ (a large prime).

Input Format

The first line contains three integers $n, m, k$.

Then $n$ lines follow, each line contains a string of length $m$. The string in the $(i+1)$-th line represents $a_i$.

Output Format

Print a single integer - the answer taken modulo $998,244,353$.

Sample Input and Output

Input Sample #1

3 3 5
aaa
baa
baa

Output Sample #1

4

Input Sample #2

3 3 2
xyz
qaq
aba

Output Sample #2

0

Input Sample #3

5 3 2
cca
cbb
acb
bbb
acb

Output Sample #3

600

Input Sample #4

5 3 5
aba
bbb
bbb
aba
bcb

Output Sample #4

120

Notes/Hints

Explanation

Sample #1

  • For permutation $1,2,3$, the formed $s$ is aaabaabaa, none of the non-empty substrings in this string are "$5$-CON string".
  • For permutation $1,3,2$, the formed $s$ is aaabaabaa, none of the non-empty substrings in this string are "$5$-CON string".
  • For permutation $2,1,3$, the formed $s$ is baaaaabaa, this string has one substring aaaaa which is a "$5$-CON string".
  • For permutation $2,3,1$, the formed $s$ is baabaaaaa, this string has one substring aaaaa which is a "$5$-CON string".
  • For permutation $3,1,2$, the formed $s$ is baaaaabaa, this string has one substring aaaaa which is a "$5$-CON string".
  • For permutation $3,2,1$, the formed $s$ is baabaaaaa, this string has one substring aaaaa which is a "$5$-CON string".

In summary, the answer is $0+0+1+1+1+1=4$.

Sample #2

In all of the full permutations of length $3$, there will be six different $s$: xyzqaqaba, xyzabaqaq, qaqxyzaba, qaqabaxyz, abaqaqxyz, and abaxyzqaq. None of these has a non-empty substring which is a "$2$-CON string". So the answer is $0$.

Constraints

$2 \le k \le n \cdot m \le 10^6; \ 1 \le m \le 100$. $a_i$ contains only lowercase English letters.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 5 aaa baa baa
样例输出
4