DMPG '19 G6 - Pairs
View as PDFA string  of length 
 is given. Alice has written all 
 ordered pairs 
 of substrings of 
. For each pair, she computes the length of the longest common prefix of the two substrings. How many times does she write down each number from 
 to 
? As these numbers may be large, please output them modulo 
.
Constraints
 contains only lowercase English letters.
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [20%]
Subtask 4 [50%]
Input Specification
The first line contains a single integer .
The next line contains the string .
Output Specification
Output  lines. On the 
 line, print the number of pairs of substrings which have a longest common prefix of length 
, modulo 
.
Sample Input 1
3
ccc
Sample Output 1
0
27
8
1
Sample Input 2
4
dmpg
Sample Output 2
70
16
9
4
1
                    
Comments