Under construction

Still being built. Things may change

Divar's Salaries

Time limit1sMemory limit2048 MB

Summary
Computes each employee's monthly pay from wage x, total hours k, and holiday hours h, using 1.5x for hours past 140 and 2x for holiday hours.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Amin works in the financial department of Divar company. As part of his job, he prepares the salary payment list for the company's employees. Each employee's salary is calculated from a base hourly rate of xx Rials. However, the actual pay rate depends on the type of working hours.

  • Normal working hours: Paid at the standard rate of xx Rials per hour.
  • Overtime hours: Hours worked beyond the standard 140 hours per month are paid at 1.5 times the base rate.
  • Holiday hours: Hours worked on recognized holidays are paid at twice the base rate, whether they fall within or beyond the standard 140 hours.

Holiday hours take precedence. Those hours are paid at the doubled rate regardless of the standard working hour limits.

Amin must calculate the total monthly salary for each employee, counting normal hours, overtime hours, and holiday hours.

Input

The first line contains a single integer nn (1≤n≤1 0001 \le n \le 1\,000), the number of employees. Each of the following nn lines contains three integers xx, kk, and hh describing one employee.

  • xx (100≤x≤106100 \le x \le 10^6): The hourly wage in Rials. It is always a multiple of 10.
  • kk (0≤k≤4800 \le k \le 480): The total number of hours worked this month.
  • hh (0≤h≤k0 \le h \le k): The number of holiday hours worked.

Output

For each employee, print the total monthly payment on a separate line. Separate every three digits with commas, starting from the right.

Examples1

  1. Example 1

    Input
    3
    500 10 0
    200 190 15
    10000 150 20
    
    Expected output
    5,000
    44,500
    1,700,000