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

#GD0000027. Bài toán người thợ giày (Shoemaker's Problem)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Bài toán người thợ giày (Shoemaker's Problem)

Shoemaker's Problem

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn jobs. Job ii takes tit_i days and incurs a penalty of sis_i for each day before completion. Only one job can be processed at a time. Output an order minimizing the total penalty.

Input

The first line contains nn. Each of the next nn lines contains ti,sit_i,s_i. Jobs are numbered from 11.

Output

Print an optimal order of job indices; if multiple orders are optimal, prefer smaller indices first.

Constraints

  • 1≤n≤1051\le n\le 10^5.
  • 1≤ti,si≤1091\le t_i,s_i\le 10^9 for 1≤i≤n1\le i\le n.

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

4
3 4
1 1000
2 2
5 5

Output

2 1 3 4

Explanation

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