#include <iostream>
#include <algorithm>
#define MAXN 111
#include <string>
using namespace std;
typedef struct {
string name;
int RMB;
int day;
int vol;
}Point;
bool GY(Point a, Point b) {
if(a.day * b.RMB == a.RMB * b.day) {
if(a.RMB != b.RMB)
return a.RMB < b.RMB;
else
return a.vol > b.vol;
}
return a.day * b.RMB > a.RMB * b.day;
}
Point p[MAXN];
int n;
int main() {
int test, i;
string str;
int r, d, m;
cin >> test;
while(test --) {
scanf("%d", &n);
m = 0;
for(i = 1; i <= n; ++ i) {
cin >> str >> r >> d;
if(d > 199) {
++ m;
p[ m ].name = str;
p[ m ].RMB = r;
p[ m ].vol = d;
if(d >= 1200) d = 1199;
p[ m ].day = d / 200;
}
}
sort(p + 1, p + m + 1, GY);
cout << p[ 1 ].name << endl;
}
return 0;
}