Triples

아직 제출이 없습니다시간 제한7초메모리 제한512 MB

문제

You are given a tree, i.e. a connected undirected graph with no cycles. For every two vertices x,yx, y let d(x,y)d(x, y) denote the length (i.e. the number of edges) of the unique simple path between xx and yy. Count all the (unordered) triples x,y,z\\{x,y,z\\} such that d(x,y)=d(y,z)=d(z,x)>0d(x,y) = d(y,z) = d(z,x) > 0.

입력

The first line of input contains the number of test cases zz (1z201 \leq z \leq 20). The descriptions of the test cases follow.

The first line of every test case contains the number of vertices nn (3n100,0003 \leq n \leq 100\\,000). Each of the next n1n - 1 lines contains two integers a,ba, b (1a,bn1 \leq a, b \leq n), denoting that there is an edge between vertices aa and bb.

출력

For each test case output one integer: the number of triples in question.