This page is still under construction.

Parts of this page are still being built. What you see may change.

Pennant Race

Time limit1sMemory limit128 MB

Summary
Print the team with the highest winning percentage, computed as wins divided by wins plus losses plus ties.
Level

Easy1 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

The Korea Baseball Organization (KBO) is South Korea's professional baseball league. It was founded with six teams in 1982 and now has eight teams. Each team plays 133 games in the regular season, and the season ends with the championship series known as the Korean Series.

The top four teams advance to the post-season, ranked by winning percentage. In the 2009 season the winning percentage of a team is

winning percentage=ww+l+t\text{winning percentage} = \frac{w}{w + l + t}

where ww, ll, and tt are the numbers of games the team won, lost, and tied. In other words, a tie counts as a loss for percentage purposes (from 2002 to 2007 a tie was treated as a "no game", and before that it counted as half a win and half a loss).

The team with the best record advances directly to the Korean Series, while the other three teams compete for the remaining spot in a step-ladder playoff:

  • Semi-playoff: 3rd place vs. 4th place, best of 5 games
  • Playoff: 2nd place vs. the semi-playoff winner, best of 5 games
  • Korean Series: 1st place vs. the playoff winner, best of 7 games

Given the current standings, determine which team advances directly to the 2009 Korean Series. The best record is guaranteed to be unique.

Input

The first line contains the number of test cases TT (1≤T≤201 \le T \le 20).

Each test case begins with a line containing an integer nn (1≤n≤101 \le n \le 10), the number of teams in the pennant race. Each of the next nn lines contains a team name BB (a string shorter than 10 characters) followed by three integers ww, ll, and tt separated by spaces: the number of games that team won, lost, and tied (0≤w≤1330 \le w \le 133, 0≤l≤1330 \le l \le 133, 0≤t≤1330 \le t \le 133).

Output

For each test case, print on its own line the name of the team that advances directly to the 2009 Korean Series.

Examples1

  1. Example 1

    Input
    3
    3
    DOOSAN 84 0 49
    KIA 118 3 12
    SK 93 27 13
    4
    Haitai 101 25 7
    LG 22 39 72
    Hanhwa 17 79 37
    Samsung 28 5 100
    9
    Bears 51 60 22
    Eagles 11 54 68
    Giants 107 19 7
    Twins 96 33 4
    Lions 21 92 20
    Wyverns 60 63 10
    Tigers 109 14 10
    Heroes 26 28 79
    Haitai 106 14 13
    
    Expected output
    KIA
    Haitai
    Tigers