Stacking Cups

Read each cup's message, recover its radius from either token order, then print colors from smallest to largest cup.

Easy2SortingImplementationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

You are writing a cup stacking module for a robot. The robot carries several sensors that read the radius and the color of a cup exactly. The trouble is a defect in the core routine that processes sensor input: when the color signal arrives after the radius signal, the routine passes on twice the radius, that is, the diameter.

For a red cup of radius 55, the module receives either red 5 or 10 red.

Given the list of messages sent by the core routine, where each message describes a different cup, sort the cups from the smallest to the largest.

Input

The first line contains the number of cups NN. (1N201 \le N \le 20)

Each of the next NN lines contains two tokens, either as color radius or as diameter color. The radius RR of a cup is a positive integer less than 10001000, and the diameter is 2R2R. The color CC is a non-empty string of lowercase English letters of length at most 2020. All cups differ in both size and color.

Output

Print the colors of the cups, one per line, in order of increasing radius.