A binary scale is a special device that can measure any value in the open interval (0,1) with a fixed precision. The precision is set with a dial that can be turned to 1,2,3,…,10. When the precision is set to m, the scale measures in units of 1/2m.
A measurement is recorded as a pair (ℓ,m). Such a pair means the precision is set to m and the scale reads ℓ, so the weight of the measured object is ℓ/2m. Here ℓ is a positive integer, and since the scale only reads values in (0,1) we have 0<ℓ<2m.
Write a program that orders the measurements from the smallest value to the largest. Each measurement is given as a pair (ℓ,m). Different pairs that represent the same value (for example (1,2) and (2,3), both equal to 1/4) must be ordered by increasing reading ℓ, the first element of the pair.
The program reads from standard input. The first line contains an integer n (1≤n≤20000), the number of pairs. Each of the next n lines contains one pair ℓi and mi, separated by a single space. For every pair, 1≤mi≤10 and 1≤ℓi<2mi.
The program writes to standard output. Output the n input pairs, reordered so that pairs with smaller measured values come before pairs with larger measured values. Pairs with equal measured values are printed in non-decreasing order of their reading ℓ. Print each pair in the same format as the input, that is, the two integers ℓi and mi separated by a single space.