Problem: You are given a tree, consisting of vertices. Each edge has an integer value written on it.
Let be the number of values that appear exactly once on the edges of a simple path between vertices and .
Calculate the sum of over all pairs of vertices and such that .
Input Format: The first line contains a single integer () — the number of vertices in the tree.
Each of the next lines contains three integers and () — the description of an edge: the vertices it connects and the value written on it.
The given edges form a tree.
Output Format: Print a single integer — the sum of over all pairs of vertices and such that .