题目描述
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has recently got a broadband internet connection. His history of internet data usage is provided as below.
During the first T_{1} minutes, the internet data used was D_{1} MBs per minute, and during the next T_{2} minutes, it was D_{2} MBs per minute, and so on till during last T_{N} minutes it was D_{N} MBs per minute.
The internet provider charges the Chef 1 dollar for every 1 MB data used, except for the first K minutes, when the internet data is free as part of the plan provided to Chef.
Please find out the total amount that Chef has to pay the internet provider (in dollars).
------ Input ------
First line of the input contains a single integer TC the number of test cases. Description of TC test cases follow.
First line of each test case contains two space separated integers N and K.
Next N lines of each test case contains information about the internet data usage. Specifically, in the i-th line, there will be two space separated integers: T_{i} and D_{i}.
------ Output ------
For each test case output a single integer in separate line, the amount that Chef has to pay in dollars.
------ Constraints ------
$1 ≤ TC ≤ 1,000$
$1 ≤ N ≤ 10$
$0 ≤ K ≤ T_{1} + T_{2} + ... + T_{N} $
$1 ≤ T_{i}, D_{i} ≤ 10$
----- Sample Input 1 ------
3
2 2
2 1
2 3
2 2
1 2
2 3
3 0
1 2
2 4
10 10
----- Sample Output 1 ------
6
3
110
----- explanation 1 ------
Example case 1. For the first two minutes, internet data of usage of Chef is free. He has to pay for last 2 minutes only, for which he will be charged at 3 dollars per minute, i.e. total 6 dollars.
Example case 2. For the first two minutes, internet data of usage of Chef is free. He has to pay for last 1 minute only, for which he is being charged at 3 dollars per minute. So, in total he has to pay 3 dollars.
Example case 3. This time, Chef is not provided any free data usage. He has to pay
for entire data usage, which comes out to be 1 * 2 + 2 * 4 + 10 * 10 = 110 dollars.
输入格式
见题面
输出格式
见题面