Under construction

Still being built. Things may change

Does This Make Me Look Fat?

Interview

Time limit1sMemory limit128 MB

Summary
Sort each group of dieters by current weight, computed as starting weight minus days on the diet, heaviest first.
Level

Easy3 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

You host a popular daytime television talk show, and you are working out the details of an upcoming episode about dieting. Your guest is Dr. Voss. His new weight-loss plan, "Do You Want To Diet?", promises to take exactly 1 pound off your body weight every day.

Several dieters who have been following the plan are booked for the episode. To make the episode more dramatic, you want to introduce them in decreasing order of their weight on the day of the show, heaviest guest first. The trouble is that the form they filled out asked for only three things: name, days on the diet, and weight just before the diet started. You have until tonight's taping to work out the order.

Input

The input is a series of 1 to 100 data sets. No blank line separates data sets.

A data set has three parts.

  1. Start line: a single line containing START.
  2. Dieter list: 1 to 10 lines, each holding three fields separated by a single space.
    • Name: the dieter's first name, a string of 1 to 20 alphanumeric characters with no spaces.
    • Days on diet: how many days the dieter has been on the plan as of the day of the show, a positive integer strictly less than 1000.
    • Starting weight: the dieter's weight in pounds just before starting the diet, a positive integer strictly less than 10000.
  3. End line: a single line containing END.

The input guarantees the following.

  • Every dieter lost exactly 1 pound for each day on the diet, as advertised.
  • Nobody stayed on the diet long enough to weigh less than 1 pound on the day of the show.
  • Within one data set, all dieters weigh different amounts on the day of the show.
  • Within one data set, all dieters have different names.

Output

Print one output set per data set, in input order. Separate consecutive output sets with exactly one blank line, and print no blank line after the last output set.

An output set lists the names of that data set's dieters, one per line, in decreasing order of weight on the day of the show. Print every dieter.

Examples1

  1. Example 1

    Input
    START
    Joe 10 110
    END
    START
    James 100 150
    Laura 100 140
    Hershey 100 130
    END
    START
    Hershey0 1 5
    Hershey2 1 3
    Hershey1 1 4
    Hershey3 1 2
    END
    
    Expected output
    Joe
    
    James
    Laura
    Hershey
    
    Hershey0
    Hershey1
    Hershey2
    Hershey3