Flat Organization

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

문제

The company you are currently working for has decided to push the idea of flat organizational structure to its limits: for every pair of employees AA and BB, either AA has been assigned to directly supervise BB's work or BB has been assigned to directly supervise AA's work. Of course, it means that one might now have quite a lot of direct supervisors... which is great, because it makes an employee feel that their work truly is important to so many people rather than just to a single manager, the executives say.

There is always room for improvement, though. As the corporate goal for this year, the hierarchy will be revised to ensure that whenever a person AA is directly supervised by a person BB, then BB is also indirectly supervised by AA at the same time (we say that BB is indirectly supervised by AA if there exists n>2n > 2 and a sequence (c_1,,c_n)(c\_1, \ldots, c\_n) such that c_1=A,c_n=Bc\_1 = A, c\_n = B and for each i<ni < n, c_ic\_i is a direct supervisor of c_i+1c\_{i+1}).

It will ensure that any employee would think twice before deciding to abuse their position of power over anyone else, the executives say.

It should not come off as a surprise, though, that one might get somewhat annoyed if they learn that their supervisee has suddenly been appointed as their supervisor. And some such decisions might cause more resentment than others. Your task is to fulfill the corporate goal by reversing some of the dependencies between employees in such a way that the sum of resentments over these changes is as small as possible.

입력

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

The first line of every test case contains a single integer nn (1n20001 \leq n \leq 2000) -- the number of employees. The employees are numbered from 11 to nn.

Then follow nn lines, containing nn integers d_i,jd\_{i, j} each (0d_i,j21090 \leq d\_{i, j} \leq 2\cdot 10^9). If the employee  ii is  a direct supervisor of employee jj, then d_i,j>0d\_{i, j} > 0 describes the resentment that ii would feel if this dependency got reversed. Otherwise (that is, if jj is a direct supervisor of ii or if i=ji = j), d_i,j=0d\_{i, j} = 0.

The total number of employees in all test cases does not exceed 1000010000.

출력

For each test case, produce a solution which ensures that, for any pair of employees i,ji, j (1i,jn,ij1 \leq i, j \leq n, i \neq j), either ii will be a direct supervisor of jj and jj will be an indirect supervisor of ii, or vice versa. Your solution should minimize the sum of resentments the employees will feel. If more than one such solution exists, you can print any of them.

If no solution exists, you should output a single line containing the word "NO".

Otherwise, in the first line output a single word "YES". In the second line, print two integers kk and rr -- the number of dependencies between employees which you intend to reverse and the achieved sum of resentments, respectively. Note that you do not need to minimize kk.

Then output kk lines, each containing two integers -- the identifiers of employees a,ba, b (1a,bn,ab1 \leq a, b \leq n, a \neq b) such that aa is currently a direct supervisor of bb and their relationship should get reversed. You should never output the same pair of employees more than once.