405541: GYM101991 A Awesome Shawarma

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Awesome Shawarmatime limit per test14.0 smemory limit per test1024 megabytesinputawesome.inoutputstandard output

Fouad has a raw awesome shawarma, and he is in a city which is represented as an undirected tree. He heard that there is a magical oven that will cook the Shawarma, to make it so delicious. However, In order to acquire the magical oven, there need to be two conditions that should be satisfied in this city:

  • One extra edge that must be added to join two different nodes in the tree (It is allowed to join two nodes, which were previously connected by a direct edge).
  • The number of bridges after adding the new edge should be between $$$[L, R]$$$ inclusively.

Please help Fouad to acquire the magical oven, to cook the awesome shawarma by counting in how many ways he can add an edge that satisfies the conditions above.

Input

The first line of the input file contains a single integer $$$T$$$, the number of test cases.

Each test case begins with a line containing three integers $$$N$$$, $$$L$$$, and $$$R$$$ ($$$2 \le N \le 10^5$$$, $$$0 \le L \le R \le N - 1$$$), in which $$$N$$$ is the number of nodes, and $$$L$$$ and $$$R$$$ are the minimum and maximum numbers of allowed bridges, respectively.

Then $$$N - 1$$$ lines follow, each line contains two integers $$$X_i$$$ and $$$Y_i$$$ ($$$1 \le X_i, Y_i \le N$$$), giving an edge between nodes $$$X_i$$$ and $$$Y_i$$$.

Output

For each test case, print a single line containing the number of ways to add one new edge such that the number of bridges in the new graph is within the range $$$[L, R]$$$ inclusively.

ExampleInput
2
5 1 2
1 2
2 3
4 5
2 4
5 1 3
1 2
2 3
4 5
2 4
Output
6
10
Note

A bridge in a graph is an edge, such that if it is removed, the graph will become disconnected.

In the second sample, the result is acquired by connecting an edge between any two different nodes.

加入题单

上一题 下一题 算法标签: