#P1935C. Messenger in MAC
Messenger in MAC
No submission language available for this problem.
Description
In the new messenger for the students of the Master's Assistance Center, Keftemerum, an update is planned, in which developers want to optimize the set of messages shown to the user. There are a total of messages. Each message is characterized by two integers and . The time spent reading the set of messages with numbers (, all are distinct) is calculated by the formula:
Note that the time to read a set of messages consisting of one message with number is equal to . Also, the time to read an empty set of messages is considered to be .
The user can determine the time that he is willing to spend in the messenger. The messenger must inform the user of the maximum possible size of the set of messages, the reading time of which does not exceed . Note that the maximum size of the set of messages can be equal to .
The developers of the popular messenger failed to implement this function, so they asked you to solve this problem.
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the number of messages and the time the user is willing to spend in the messenger.
The -th of the next lines contains two integers and () — characteristics of the -th message.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output a single integer — the maximum possible size of a set of messages, the reading time of which does not exceed .
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the number of messages and the time the user is willing to spend in the messenger.
The -th of the next lines contains two integers and () — characteristics of the -th message.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output a single integer — the maximum possible size of a set of messages, the reading time of which does not exceed .
Note
In the first test case, you can take a set of three messages with numbers , , and . The time spent reading this set is equal to .
In the second test case, you can take a set of one message with number . The time spent reading this set is equal to .
In the fifth test case, it can be shown that there is no such non-empty set of messages, the reading time of which does not exceed .