Summer trip

Summer trip

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 256.0 MB

Description

Due to the Summer Vacation, Mr. Heart decided to take a much-needed break from a stressful life, so he planned to travel at Cox's Bazar for a relaxing beach vacation with his friend. They booked a charming seaside hotel with a special pricing plan: the first D nights cost is A taka per night, while any additional nights were at a lower rate of B per night.

They spent their days soaking in the sun, enjoying the waves, and exploring the vibrant local markets. The mix of luxury and affordability made their trip both enjoyable and budget-friendly.

They spent N nights in this hotel, your task is to calculate the total accomodation fee which they spent on their trip.

Input

First Line T (1 ≤ T ≤ \(10^5\)), the number of test cases.
Second Line N and D(1 ≤ N , D ≤ \(10^5\))
Third line A , B (1 ≤ B < A ≤ \(10^6\))

Output

print the total accomodation fee of their trip

Sample

Input Output
1
5 3
3000 2500
14000

In the test case, First 3 nights cost will be (3 * 3000) = 9000 taka
rest of the 2 nights will be (2 * 2500) = 5000 taka
so the total spend of the trip will be 14000 taka

Brain Booster #5

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
8
Start at
2024-09-05 15:30
End at
2024-09-05 17:45
Duration
2.2 hour(s)
Host
Partic.
88