#EIUASSEMBLY. Assembly line
Assembly line
The Alternate Control Machine (ACM) Factory has a large assembly line to make a type of product. The assembly has N robots (R1, R2...RN) working sequentially. That means a semi-finished product moves from robot R1, to R2, then to R3... to RN. Each robot adds a component to the product. Each robot can complete its own job in Pi products per one hour.
The company has a budget of M VNĐ to improve productivity for the entire assembly. As a product director, you know that robot Ri needs to invest Mi VNĐ to contribute to the production of one more product per hour. You have to optimize the amount of money to invest to each robot to produce maximum number of products per hour.
Input
The first line of input contains one integer T (1≤T≤10) - the number of test cases.
Then T test cases are given as follows:
- The first line of each test case contains an integer N (1≤n≤105) and an integer M (0≤M≤1012) – the number of robots and the budget
- Line i-th of the next N lines contains two integers Pi (1≤Pi≤109) and Mi (1≤Mi≤109) – information of the robot i-th
Output
For each test case, output in one line the maximum number of products the assembly can make after investing at most M VNĐ.
Example
Input: 1 3 7 1 2 2 3 3 1 Output: 3