Limits 1s, 512 MB

Robinson wants to be a mariner. But his father wants him to be a lawyer. But, if Robinson can solve the following problem, his father will grant his wish.

Suppose you are Robinson. You will be given n fractions. You have to arrange them in descending order. Can you solve the problem?

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) that denotes number of fractions. Each of the next n lines contains two integers denoting the numerator and denominator of the fractions.

The numerators and denominators will be in the range $ [1, 10^{17}]$.

Output

Print n fractions in n lines in descending order. If two fractions are same, maintain the input order for printing.

Please refer to sample input/output section for better understanding.

Sample

InputOutput
3
10 2
15 3
24 4
24 4
10 2
15 3

Submit

Login to submit.

Statistics

41% Solution Ratio
Ashraful_jnuEarliest, Aug '20
Ashraful_jnuFastest, 0.0s
Ashraful_jnuLightest, 131 kB
BruteforcekidShortest, 326B
Toph uses cookies. By continuing you agree to our Cookie Policy.