406057: GYM102253 B Balala Power!

Memory Limit:128 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Balala Power!time limit per test2 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard output

Talented Mr. Tang has $$$n$$$ strings consisting of only lowercase letters. He wants to charge them with Balala Power (he could change each letter ranged from 'a' to 'z' into any number ranged from $$$0$$$ to $$$25$$$, but every two different letters must not be changed into the same number) so that he could casually calculate the sum of these strings as integers in the base of $$$26$$$.

Mr. Tang wants you to maximize the sum. Note that no string in this problem can have any leading zeros when regarded as integers, except for the string "0". Therefore, he guarantees that at least one type of letter would not appear at the beginning of any given string.

The sum may be quite large, so you should output it modulo $$$(10^9 + 7)$$$ instead.

Input

The input contains multiple (about $$$20$$$) test cases.

For each test case, the first line contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$), indicating the number of strings.

The $$$i$$$-th of the next $$$n$$$ lines contains a string $$$s_i$$$ ($$$1 \leq |s_i| \leq 10^5$$$) consisting of only lowercase letters. It is guaranteed that $$$\sum_{i = 1}^{n}{|s_i|} \leq 10^6$$$ for each test case.

Output

For each test case, output "Case #x: y" in one line (without quotes), where $$$x$$$ indicates the case number starting from $$$1$$$, and $$$y$$$ denotes the answer to the corresponding case.

ExampleInput
1
a
2
aa
bb
3
a
ba
abc
Output
Case #1: 25
Case #2: 1323
Case #3: 18221

加入题单

算法标签: