1571 前缀字串


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

两个字符串s,t,如果s是t的前缀或者t是s的前缀(注意,s是s的前缀的),那么我们称s和t是一个Twisted Pair. 给你N个字符串,让你计算其中有多少个Twisted Pair.

Input

多组数据,第一行是一个整数N(N<=10000),然后是N行,每行一个字符串(只包含26个小写字母,长度<=10)

Output

输出共有几个Twisted Pair

Sample

Input

3
abb
cabbcb
aabb

4
aaaaaaaaaa
aaaaaaa
aaaa
aa

Output

0
6

Source: zjut_DD


Comments

There are no comments at the moment.