Task
William spends most of his time administering the Italian portal for the IOI training. During his last sleepless night debugging the system, he figured out that several of the usernames used in the website are very similar. This causes a lot of confusion, especially when inspecting users' rankings.
He is then considering to add a new rule to the website: you are not allowed to select a username whose set of letters is a subset of the set of letters of another username. For example, you cannot register the username bob00 if n0ob is already present. In order to evaluate the impact of such a design choice, he now wants to measure how much this rule is violated by the current list of usernames.
More precisely, given a list of usernames consisting of characters a - z
and 0 - 9
, he wants to count the number of username pairs such that .
Input data
The first line contains the only integer . The subsequent lines contain the usernames .
Output data
You need to write a single line with an integer: the number of pairs violating the rule.
Constraints and clarifications
- .
- Each username is a string of length at most consisting of characters
a - z
and0 - 9
.
# | Points | Constraints |
---|---|---|
1 | 5 | Examples. |
2 | 35 | and there are no two usernames with the same set of letters. |
3 | 25 | . |
4 | 25 | Usernames consists only of characters a - b . |
5 | 10 | No additional limitations. |
Example 1
stdin
3
carole
rollercar
4ndr31
stdout
2
Explanation
In the first sample case, carole
and rollercar
share the same set of letters, while 4ndr31
is unrelated. Thus the invalid pairs are and .
Example 2
stdin
4
robin
tyrionboss
bornin2000
toy
stdout
3
Explanation
In the second sample case the invalid pairs are , , .