PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000031. Xếp hạng xác suất (Standings)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Xếp hạng xác suất (Standings)

Standings

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn people. Person ii has AiA_i successes and BiB_i failures. The success rate is Ai/(Ai+Bi)A_i/(A_i+B_i). Sort indices by decreasing rate, breaking ties by smaller index.

Input

The first line contains nn. Each of the next nn lines contains Ai,BiA_i,B_i.

Output

Print the nn indices in the required order.

Constraints

  • 1≤n≤2⋅1051\le n\le 2\cdot10^5.
  • 0≤Ai,Bi≤1090\le A_i,B_i\le 10^9 for 1≤i≤n1\le i\le n.
  • Ai+Bi≥1A_i+B_i\ge 1 for every ii.

Subtasks

  • Subtask 1 (20 points): n≤8n\le 8.
  • Subtask 2 (30 points): n≤30n\le 30.
  • Subtask 3 (50 points): Full constraints.

Examples

Input

3
1 3
3 1
2 2

Output

2 3 1

Explanation

The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.