logo AlgoBeat OnlineJudge
登录 注册

#207209. 「Wdcfr-1」CONsecutive and CONcat (easy version)

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

In easy version, It is guaranteed that any string in array contains at least two different letters.

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 a "-CON string". For example, qqqq is a "-CON string", while aaab is not any type of "CON string".

Lily White composed an array . It contains strings of length that she will use to herald spring. For each permutation of , let us denote current permutation as . Lily White concatenates all the string in array in the order of into a string of length .

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

输入格式

The first line contains three integers .

Then lines follow, each line contains a string of length . The string in the-th line represents .

输出格式

Print a single integer - the answer taken modulo .

样例

样例输入 1

3 3 4
aab
baa
baa

样例输出 1

4

样例输入 2

3 3 2
xyz
qaq
aba

样例输出 2

0

数据范围与提示

Explanation

Sample #1

  • For permutation , the formed is aabbaabaa, none on the non-empty substring in this string are "-CON string".
  • For permutation , the formed is aabbaabaa, none on the non-empty substring in this string are "-CON string".
  • For permutation , the formed is baaaabbaa, this string has one substring aaaa which is a "-CON string".
  • For permutation , the formed is baabaaaab, this string has one substring aaaa which is a "-CON string".
  • For permutation , the formed is baaaabbaa, this string has one substring aaaa which is a "-CON string".
  • For permutation , the formed is baabaaaab, this string has one substring aaaa which is a "-CON string".

In summary, the answer is .

Sample #2

In all of the full permutation of length , there will be six different : xyzqaqaba, xyzabaqaq, qaqxyzaba, qaqabaxyz, abaqaqxyz, and abaxyzqaq. None of these has a non-empty substrings which is a "-CON string". So the answer is .

Constraints

. contains only lowercase English letters.

In easy version, we ensure that any string in array contains at least two different letters.