| TheForces Round #37 (Brute-Forces1) |
|---|
| Закончено |
You are given an integer grid $$$a$$$ containing $$$n$$$ rows and $$$n$$$ columns. Let $$$a_{i,j}$$$ denote the value at the $$$i$$$-th row from the top and $$$j$$$-th column from the left.
Now your task is to construct a tree (undirected acyclic graph) containing $$$n$$$ nodes, such that :
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows.
The first line of each test case contains single integer $$$n$$$ ($$$2 \le n \le 10^3$$$).
The next $$$n$$$ lines of each test case contains $$$n$$$ integers $$$a_{i,1},a_{i,2},\cdots,a_{i,n}$$$ ($$$1 \le a_{i,j} \le n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^3$$$.
For each test case, print $$$-1$$$ if there is no possible tree.
Otherwise, print $$$n-1$$$ lines — the edges of the tree.
If there are multiple answers output any.
541 1 1 11 2 1 11 1 3 31 1 3 451 1 1 1 11 2 1 1 11 1 3 3 31 1 3 4 31 1 3 3 551 1 1 1 23 4 1 1 33 4 1 1 52 3 1 2 31 2 3 4 561 1 1 1 1 11 2 2 1 1 21 2 3 2 3 11 1 2 4 3 21 1 3 3 5 21 2 1 2 2 671 1 1 1 1 1 11 2 1 2 1 1 11 1 3 1 3 3 31 2 1 4 1 1 11 1 3 1 5 5 31 1 3 1 5 6 31 1 3 1 3 3 7
3 4 2 1 1 3 3 5 1 2 4 3 3 1 -1 -1 2 4 3 1 3 6 4 1 7 3 5 6
| Название |
|---|


