Under construction

Still being built. Things may change

Optimization is Freaky Fun

Time limit2sMemory limit256 MB

Summary
For each query with N, S, and E up to 10^12, print the value that Kyojun's program outputs.
Level

Medium4 of 10

Topics
Math, Number theory
Solved
No attempts yet

Problem

The following is the source code written by Kyojun.

<Figure 1> Source code written by Kyojun

The input of the program written by Kyojun is as follows:

Q
N1 S1 E1
N2 S2 E2
...
NQ SQ EQ

Write a program that prints the output of the program written by Kyojun.

Input

The first line contains a natural number QQ.

The (i+1)(i+1)-th line contains three natural numbers NiN_i, SiS_i, and EiE_i, separated by spaces (1≤i≤Q1 \le i \le Q).

Output

From the first line to the QQ-th line, print the output of the program written by Kyojun.

Constraints

All input data satisfy the following conditions.

  • 3≤Q≤1053 \le Q \le 10^5
  • 1≤Ni≤10121 \le N_i \le 10^{12} (1≤i≤Q1 \le i \le Q)
  • 1≤Si≤10121 \le S_i \le 10^{12} (1≤i≤Q1 \le i \le Q)
  • 1≤Ei≤10121 \le E_i \le 10^{12} (1≤i≤Q1 \le i \le Q)

Examples1

  1. Example 1

    Input
    3
    4 1 3
    5 2 3
    6 1 6
    
    Expected output
    7
    3
    14