Codeforces Round 164 (Div. 2)
A
Games
Codeforces
800
原题
←B →
翻译中…

Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.

翻译中…

There are $*n*$ teams taking part in the national championship. The championship consists of $*n*·(*n* - 1)$ games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.

翻译中…

You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($2 ≤ *n* ≤ 30$). Each of the following $*n*$ lines contains a pair of distinct space-separated integers $*h*_{*i*}$, $*a*_{*i*}$ ($1 ≤ *h*_{*i*}, *a*_{*i*} ≤ 100$) — the colors of the $*i*$-th team's home and guest uniforms, respectively.

翻译中…

Output

翻译中…

In a single line print the number of games where the host team is going to play in the guest uniform.

翻译中…

Note

翻译中…

In the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.

翻译中…

In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host team is written first).

翻译中…

样例

Input #1
3
1 2
2 4
3 4
Output #1
1
InputCopy OutputCopy
Input #2
4
100 42
42 100
5 42
100 5
Output #2
5
InputCopy OutputCopy
Input #3
2
1 2
1 2
Output #3
0
InputCopy OutputCopy
题目信息
题号
268A
时间限制
1 s
内存限制
256 MB
标签
暴力

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。