Under construction

Still being built. Things may change

Sport Climbing Combined

Interview

Time limit1sMemory limit1024 MB

Summary
Given each athlete's ranks in three climbing events, sort them by the product of ranks, then by rank sum, then by bib number, and print the top three bib numbers.
Level

Easy3 of 10

Topics
Sorting, Implementation, Array, Math
Solved
No attempts yet

Problem

Sport climbing is an indoor rock climbing sport that began in 1986. Competitors originally faced off only in lead climbing, then speed climbing was added in 1989, and bouldering was added ten years later in 1999. In the Olympic Games, athletes compete in the three events and are ranked overall to determine the gold, silver, and bronze medals. The overall ranking is decided by the product of the ranks earned in the three events. For example, if an athlete places 1st in lead, 5th in speed, and 2nd in bouldering, the score is 10. The athlete with the lower product ranks higher overall.

Given the bib numbers of nn athletes and the ranks they earned in the three events, write a program that determines the athletes who receive the gold, silver, and bronze medals. Two athletes may have the same product. In that case, the athlete with the lower sum of the three event ranks wins. If both the product and the sum are equal, the athlete with the lower bib number wins.

Input

The input uses standard input. The first line gives a positive integer nn (3≤n≤1003 \le n \le 100), the number of athletes. The following nn lines each give four integers bib_i, pip_i, qiq_i, rir_i, where bib_i is the bib number of the ii-th athlete, and pip_i, qiq_i, rir_i are the ranks that athlete earned in lead, speed, and bouldering, respectively. The bib numbers are distinct positive integers no greater than 999999. Also, an athlete's rank in each event is an integer between 11 and nn. Two athletes may have the same rank in an event.

Output

The output uses standard output. Print the three integers representing the bib numbers of the athletes who receive the gold, silver, and bronze medals, in that order, on one line.

Examples1

  1. Example 1

    Input
    4
    301 4 3 2
    815 2 2 1
    717 1 1 4
    505 3 4 2
    
    Expected output
    815 717 301