#P1917F. Construct Tree
Construct Tree
Description
You are given an array of integers and an integer . Is it possible to construct a tree satisfying the following three conditions?
- The tree contains nodes.
- The length of the -th edge is equal to .
- The (weighted) diameter of the tree is equal to .
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers , ().
The second line of each test case contains integers ().
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output if it is possible to construct a tree that satisfies all the conditions, and otherwise.
You can print the letters in any case (upper or lower).
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers , ().
The second line of each test case contains integers ().
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output if it is possible to construct a tree that satisfies all the conditions, and otherwise.
You can print the letters in any case (upper or lower).
Note
Below, you are given the illustrations of trees for the first and third test cases. One of the diameters is highlighted by coloring its edges in red.
