#P9194. Cow Friendship Triplets

    ID: 22349 Type: Default 1000ms 256MiB

Cow Friendship Triplets

Cow Friendship Triplets

There are initially N1N-1 pairs of friends among FJ's NN cows labeled 1N1\dots N, forming a tree. The cows leave the farm one by one. On day ii, the iith cow leaves the farm, and then all pairs of the iith cow's friends still present on the farm become friends.

For each ii from 11 to NN, just before the iith cow leaves, determine the number of ordered triples of distinct cows (a,b,c)(a,b,c) such that none of aa, bb, cc are on vacation, aa is friends with bb, and bb is friends with cc.

inputFormat

The first line contains a single integer $N$ -- the number of cows.

The following $N-1$ lines each contain two integers $u$ and $v$ indicating that cow $u$ and cow $v$ are initially friends. It is guaranteed that these pairs form a tree.

outputFormat

Output $N$ lines. The $i$th line should contain the number of ordered triples of distinct cows $(a,b,c)$ satisfying the condition just before the $i$th cow leaves.

sample

3
1 2
2 3
2

0 0

</p>