Finding Palindromes

Time Limit: 10000MS

Memory Limit: 262144K


A word is called a palindrome if we read from right to left is as same as we read from left to right. For example, "dad", "eye" and "racecar" are all palindromes, but "odd", "see" and "orange" are not palindromes.Given n strings, you can generate n × n pairs of them and concatenate the pairs into single words. The task is to count how many of the so generated words are palindromes.


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.

Sample Input

1 a
2 ab
2 ba

Sample Output



The 5 palindromes are:
aa aba aba abba baab


POJ Monthly--2007.09.09, Zhou Gelin, modified