Time limit
2s
Memory limit
128 MB
King Dongho loved wrestling. In his kingdom, each wrestler has a positive integer strength, and each also wears a magic ring with a positive integer power during a match. The ring gives its wearer extra power proportional to the opponent's strength.
When wrestler A fights wrestler B, A's performance value is A's strength + B's strength * the power of A's magic ring. The wrestler with the larger performance value wins.
Suppose wrestler A has strength 10 and ring power 3, while wrestler B has strength 18 and ring power 4. Then A's performance is 10 + 3 * 18 = 64, and B's performance is 18 + 4 * 10 = 58, so A wins. If A fights wrestler C, whose strength is 15 and ring power is 5, then A's performance is 10 + 3 * 15 = 55, while C's performance is 15 + 5 * 10 = 65, so C wins. C also wins against B.
Every year, Dongho holds a wrestling festival. During the festival, every pair of wrestlers fights exactly once. After the festival, Dongho invites all wrestlers and awards them gold coins.
Heehyun must decide the order in which the wrestlers line up to meet Dongho. The number of gold coins a wrestler receives is the number of matches the wrestler won + the number of defeated wrestlers who stand earlier in the line.
For A, B, and C above, if they meet Dongho in the order A, B, C, then A receives 1 coin, B receives 0 coins, and C receives 4 coins. C won two matches, and both A and B, whom C defeated, stand before C, so C receives two additional coins. If the order is C, A, B instead, then C receives 2 coins, A receives 1 coin, and B receives 0 coins.
Heehyun wants to minimize the total number of gold coins paid by the kingdom. Given every wrestler's strength and magic ring power, find an order in which the wrestlers should meet Dongho so that the total number of awarded coins is minimized. You may assume that no match ends with equal performance values.
The first line contains the number of wrestlers N. The wrestlers are numbered from 1 to N.
Each of the next N lines describes one wrestler. The k-th of these lines contains the strength and magic ring power of wrestler k. N is at most 10,000, and every strength and ring power is an integer between 1 and 1,000, inclusive.
Print the wrestler numbers, one per line, in the order in which they should meet Dongho.