For a binary tree, let be the set of all its vertices and
be the key of a vertex
. We say this binary tree is an anti binary search tree if for all
, at least one of the following statement is true:
Given integers
, please construct an anti binary search tree such that the multi-set of the keys of all vertices in the tree equals to the multi-set of these
integers, and that the height of the tree does not exceed
, where
indicates the smallest integer that is not smaller than
.
Recall that the height of the tree is the maximum number of edges between the root of the tree and any vertex on the tree. That is to say, a tree with only one vertex has a height of 0, and a tree with two vertices has a height of 1.
There are multiple test cases. The first line of the input contains an integer
indicating the number of test cases. For each test case:
The first line contains an integer
(
) indicating the number of given integers.
The second line contains
integers
(
) indicating the given integers.
It's guaranteed that the sum of
of all test cases will not exceed
.
For each test case, if such anti binary search tree exists, first output "Yes" (without quotes) in one line, then output
lines indicating the constructed binary tree. For these
lines, the
-th line contains 3 integers
,
and
separated by a space, indicating the key of the
-th vertex, the index of its left child and the index of its right child.
indicates that this vertex does not have a left child, while
indicates that this vertex does not have a right child. Vertex number 1 must be the root. If there are multiple valid answers, you can output any of them.
If no such anti binary search tree exists, just output "No" (without quotes) in one line.