Every year a contest picks the smartest animal in the universe. The first round runs separately in each animal kingdom and looks for a representative with broad knowledge of mathematics, science, social studies, philosophy, art, music and other fields. Each kingdom decides its own format. The rabbit kingdom holds a first round to find the brilliant rabbits hidden across the kingdom.
To keep grading simple, the rabbit kingdom runs the round as a multiple choice exam. Each examiner writes one exam set, and a candidate picks exactly one set to take. The 50 highest scorers advance to the next round. There are N sets, numbered 1 through N.
One exam set consists of M question types. A type is given by three integers X, Y and Z. The type contains Z questions, every question in it has X choices and is worth Y points, and exactly one of the choices is correct.
You know nothing, so you answer every question by picking one choice uniformly at random. A single question with X choices worth Y points then gives an expected score of Y/X, and the expected score of an exam set is the sum of Z×Y/X over all of its types.
Find the number of the exam set with the highest expected score.
The first line contains the number of test cases T. (1≤T≤20)
The first line of each test case contains the number of exam sets N. (1<N≤100)
The exam sets follow in order from set 1 to set N. Each set starts with a line holding the number of question types M (1≤M≤100), followed by M lines. Each of those lines holds three integers X, Y and Z separated by spaces. (1<X≤1000, 1≤Y≤100, 1≤Z≤100)
For each test case print one integer on its own line, the number of the exam set with the highest expected score.
If several exam sets share the highest expected score, print the number of the one with the fewest questions among them. If those sets also have the same number of questions, print the smallest number. The number of questions in an exam set is the sum of Z over all of its types.
Within one test case every exam set has the same total point value, which is the sum of Y×Z over all of its types.
An expected score is a fraction, so a floating point comparison can make two different values look equal or two equal values look different. Fractions or a common denominator compare exactly.