Under construction

Still being built. Things may change

Ramen Formula

Time limit1sMemory limit1024 MB

Summary
Given N cases of coefficients A, B and pack count X, print W = A(X-1)+B for each case.
Level

Easy1 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

"Curly curly, delicious ramen. Ramen is here, so life is worth living. I could eat ten in a day. Slurp slurp, crunch crunch, delicious ramen."

Yechan loves ramen very much. As the top ramen fan at Sunlin, he often gulps down several packs in one meal.

He has long wanted to know how much water makes the best ramen. After long experiments, he finally came up with the following ramen formula.

W_i=A_i(X_i−1)+B_iW\_i=A\_i(X\_i - 1)+B\_i

Here, W_iW\_i is the amount of water needed, A_iA\_i is the ramen coefficient, B_iB\_i is the base amount of water, and X_iX\_i is the number of ramen packs to cook.

Input

The first line contains NN, the number of times Yechan cooks ramen.

From line 2 to line N+1N+1, line i+1i+1 contains A_iA\_i, B_iB\_i, and X_iX\_i separated by spaces, where A_iA\_i is the ramen coefficient, B_iB\_i is the base amount of water, and X_iX\_i is the number of ramen packs cooked the ii-th time.

All numbers in the input are integers.

Output

Print NN lines. On line ii (1≤i≤N1 \leq i \leq N), print W_iW\_i, the amount of water needed by the ramen formula for the ii-th cooking.

Constraints

  • 1≤N≤1001 \leq N \leq 100
  • 100≤A_i,B_i≤1 000100 \leq A\_i, B\_i \leq 1\,000 (1≤i≤N)(1 \leq i \leq N)
  • 1≤X_i≤1001 \leq X\_i \leq 100 (1≤i≤N)(1 \leq i \leq N)

Examples1

  1. Example 1

    Input
    2
    500 550 4
    450 500 7
    
    Expected output
    2050
    3200