Interesting language
While studying the ancient Bytrussian language, scientists discovered an interesting phenomenon: the language utilizes only the first 12 letters of the modern Latin alphabet, resulting in many pairs of words that are quite similar. As they prepared their research report, the scientists encountered the following task.
Consider all the words in the language to be numbered starting from 1. Let the i-th word be denoted as S_i, with its length represented as L_i. The task is to count the number of quadruples of indices (i, j, a, b) that satisfy the following conditions:
i < j,
L_a > L_i,
L_b > L_j,
The first L_i characters of the string S_a must form the string S_i,
The first L_j characters of the string S_b must form the string S_j,
If the first L_i and L_j characters are removed from the strings S_a and S_b respectively, the remaining parts of the strings must be identical.
Refer to the example for further clarification.
Assist the scientists in calculating the required statistics.
Input
The first line contains an integer N - the number of words in the ancient Bytrussian language.
The following N lines contain the words of the Bytrussian language, one per line. Each word is non-empty and consists only of lowercase Latin letters from "a" to "l" inclusive. All words are distinct. The total length of all words does not exceed 10^6.
Output
Output a single number - the count of quadruples of indices that meet the specified conditions.