Clean Up

No attempts yetTime limit1sMemory limit256 MB

Problem

You work in the IT department of a major league baseball team. Baseball piles up an enormous number of stats, and your job is to write the programs that handle them.

Write a program that decides who bats fourth. The fourth spot is called the clean-up position, and some managers give it to the player with the best batting average.

You are given the current batting order: nine players with their last names, their hits so far, and their at bats so far. You are then given the hits and at bats each player recorded in the next series, in the same roster order. Once the two records are added together and the averages are recomputed, the best average can belong to someone new. There are three cases.

  1. The clean-up batter still has the best average, so the order does not change.
  2. One of the first 3 batters now has the best average, so that batter and the clean-up batter swap positions.
  3. One of the last 5 batters now has the best average, so that batter moves into the fourth spot, the old 4th becomes the 5th, the 5th becomes the 6th, and so on down to the spot that batter came from.

A batting average is (total hits) / (total at bats). When several players share the best average, the order stays unchanged if the clean-up batter is one of them. Otherwise apply the rules above to the tied player who bats earliest.

Input

The first 9 lines give the current roster in batting order: a last name, the hits H so far, and the at bats A so far, separated by spaces. A last name is a string of letters with no spaces and at most 20 characters.

The next 9 lines give, in the same order, the hits h and the at bats a from the next series.

0 ≤ H ≤ A ≤ 1000, 0 ≤ h ≤ a ≤ 1000, and every player has A + a ≥ 1.

Output

Print the new batting order from first to ninth, one last name per line.