To keep his cows intellectually stimulated, Farmer John has placed a large map of the USA on the wall of his barn. Since the cows spend many hours in the barn staring at the map, they begin to notice several curious patterns. For example, the cities of Flint, MI, and Miami, FL, share a very special relationship: the first two letters of "Flint" form the state code ("FL") of Miami, while the first two letters of "Miami" form the state code ("MI") of Flint.
Let us say that two cities form a "special pair" if they satisfy this property and belong to different states. The cows are wondering how many special pairs of cities exist. Please help them solve this amusing geographical puzzle!
The first line contains the number n~(1 \le n \le 2 \cdot 10^5) of cities on the map.
Each of the next lines contains two strings: the name of a city (a string of at least and at most uppercase letters) and its two-letter state code (a string of uppercase letters). Note that the state code may be something like ZQ, which is not an actual U.S. state. Multiple cities with the same name may exist, but they will belong to different states.
Print the number of special pairs of cities.
Example 1