#P9194. Cow Friendship Triplets
Cow Friendship Triplets
Cow Friendship Triplets
There are initially pairs of friends among FJ's cows labeled , forming a tree. The cows leave the farm one by one. On day , the th cow leaves the farm, and then all pairs of the th cow's friends still present on the farm become friends.
For each from to , just before the th cow leaves, determine the number of ordered triples of distinct cows such that none of , , are on vacation, is friends with , and is friends with .
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>