文理学院程序设计在线练习


Galgame

Time Limit: 1 Second(s)    Memory Limit: 256 MB

Total Submission(s): 10   Accepted Submission(s): 3
Problem Description

Xiaoxi is playing an interesting Galgame again!
But the Galgame is not the same as it used to be. It's like this:
This Galgame has an straightly and stable storyline. In other words, all the choices will not affect any storyline, but will only affect the favorable degrees(to you) of different girls (which may increase or decrease). There are n selections in total and two girls in this game. In each selection, there are three options player can choose, each option will change the favorable degrees of girls, and the effects on the two girls were Ai Bi.
At the end of the story, if the favorable degrees(to you) of two girls are both more than or equal to 100, then the game will enter in a happyEND.
Every girl’s favorable degrees has an upper limit of 200, when an option makes a girl's favorable degrees higher than the upper limit, the favorable degrees will only reach the upper limit, and not exceed or overflow. Similarly, the lower limit of both girls' favorable degrees is 0, and both girls' favorable degrees is 0 at the beginning.
XiaoXi has now figured out how each option affects the girls, and now she wants to know what to do to get the mininum lexicographic order option for happyEND.

Input

The first line contains an integer T to denote the number of data sets (T<=100).
In the first line of each set of data, an integer n are input, representing the number of game selections.
Subsequently, n subsections, three lines in each subsection, indicated that the choice had three options, and the effects on the two girls were Ai Bi (i.e., the first girl’s favorable degrees would be added Ai (possibly negative), and the second girl’s would be added Bi )
1 <= n <= 1000 -200 <= Ai,Bi<= 200 Σn <= 3000

Output

For each set of data output one line, print the mininum lexicographic order option (each selection), there is no more space at the end.
If it is impossible for a set of data to achieve happyEND, a single line of integer ‘-1' should be output (without quotation marks).

Sample Input
2
2
101 101
50 50
0 0
-1 -1
100 100
100 100
1
0 200
200 0
0 0
Sample Output
1 1
-1
Hint

In example 1, In selection 1,choose the first option and the same in selection 2, which is the smallest dictionary order and can satisfy happyEND.
In Example 2, no matter what is chosen, can not reach the condition that two girls’ favorable degrees are both greater than or equal to 100.

Source

2019绍兴联赛