1524 - [POI2006]Pal

给出n个回文串s1, s2, …, sn 求如下二元组(i, j)的个数 si + sj 仍然是回文串 规模 输入串总长不超过2M bytes

输入

The first line of input file contains the number of strings n. The following n lines describe each string: The i+1-th line contains the length of the i-th string li, then a single space and a string of li small letters of English alphabet. You can assume that the total length of all strings will not exceed 2,000,000. Two strings in different line may be the same.

输出

Print out only one integer, the number of palindromes

样例

输入

6 
2 aa 
3 aba 
3 aaa 
6 abaaba 
5 aaaaa 
4 abba

输出

14
时间限制 1 秒
内存限制 128 MB
统计
上一题 下一题