Installing Apps

Choose a largest subset of apps installable within c free space and order them so each install fits, preferring the lexicographically smallest index set.

Medium7Dynamic programmingGreedySortingNo attempts yetTime limit2sMemory limit512 MB

Problem

Sandra recently bought her first smartphone. A friend gave her a long list of applications (apps) that she should install on it. Sandra started installing the apps from the list right away, but after a few installs the phone no longer had enough disk space for any more. Sometimes an installation failed because there was not even enough space to download the installation package. Other apps downloaded fine but then had too little space to store the installed app.

Each app has a download size dd and a storage size ss. To download the app, the phone needs at least dd megabytes of free disk space. Once the app is installed, it occupies ss megabytes of disk space on the phone. The download size can be smaller than the storage size (for example, when the app data is heavily compressed) or larger than the storage size (for example, when the download carries material that may never be used, such as translations into other languages). The installer is very efficient and turns the downloaded package into an installed app without using any extra disk space. So, to install an app, the phone needs at least max(d,s)\max(d, s) megabytes of free disk space.

Sandra soon realised that she may have run out of space only because she installed the apps in the wrong order. She uninstalled every app and now wants to pick an installation order that lets her install as many apps from the list as possible. Sandra installs each app at most once.

Help her decide which apps on the list to install, and in which order.

Input

The input consists of:

  • One line with two integers nn and cc (1n5001 \le n \le 500, 1c100001 \le c \le 10000), the number of available apps and the free disk space of the phone in megabytes.
  • nn lines, each with two integers dd and ss (1d,s100001 \le d, s \le 10000), the download size and the storage size of an app, in megabytes.

Output

On the first line, print the maximum number kk of apps that can be installed. If kk is at least 1, print a second line with the numbers of those kk apps, separated by single spaces, in the order Sandra should install them. If no app can be installed, print only the first line.

The apps are numbered from 1 to nn in input order. Several sets of kk apps may be installable, so the accepted answer is fixed as follows. Among all sets of kk apps that can be installed in some order, choose the set whose app numbers, written in increasing order, form the lexicographically smallest sequence. Of two sequences, the one with the smaller number at the first position where they differ is lexicographically smaller. Print that set sorted by max(d,s)s\max(d, s) - s in decreasing order, and by app number in increasing order among apps with the same value of max(d,s)s\max(d, s) - s. Any set that can be installed in some order can also be installed in this order, so the printed order is always valid.