A tree (undirected connected acyclic graph) is given with nodes and edges, each labeled with a lowercase letter. We will define the path as the sequence of edges that lead from node to node . Additionally, we will consider paths and to be identical. A path can be palindromic if there exists a way to permute all the letters traversed on that path such that they form a palindromic path.
Task
Determine how many paths can be palindromic.
Input data
The first line contains the number , representing the number of nodes.
The next lines each contain a triplet , representing an edge connecting node to node , labeled with the character .
Output data
Print on one line the number of paths that can be palindromic.
Constraints and clarifications
Example
stdin
8
1 2 a
1 3 a
2 7 b
2 8 b
3 4 b
4 5 a
4 6 a
stdout
21
Explanation
The paths that can be palindromic are: , , , , , , , , , , , , , , , , , , , , .