Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Robinson Crusoe

By Rajan_sust · 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

    Discussion

    Statistics


    39% Solution Ratio

    Ashraful_jnuEarliest, 3M ago

    Ashraful_jnuFastest, 0.0s

    Ashraful_jnuLightest, 131 kB

    BruteforcekidShortest, 326B

    Submit

    Login to submit