#P4025. [PA 2014] Bohater

[PA 2014] Bohater

Description

In a computer game, you need to defeat nn monsters (numbered from 11 to nn).

To defeat monster ii, you need to spend did_i health points, but after the monster dies, it drops a healing potion that restores aia_i health points.

At any time, your health must not drop to 00 (or below).

Determine whether there exists an order of fighting such that you can defeat all nn monsters without dying.

Input Format

The first line contains two integers n,zn, z, representing the number of monsters and your initial health.

The next nn lines each contain two integers di,aid_i, a_i.

Output Format

The first line is TAK (yes) or NIE (no), indicating whether such an order exists.

If the first line is TAK, then the second line contains a permutation of 1n1\sim n separated by spaces, representing a valid order.

If there are multiple answers, you may output any one of them. (This problem uses SPJ.)

3 5
3 1
4 8
8 3
TAK
2 3 1 

Hint

For 100%100\% of the testdata, 1n,z1051 \le n, z \le 10^5, 0di,ai1050 \le d_i, a_i \le 10^5.

Translated by ChatGPT 5