Icebound and Sequence
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld

题目描述

Icebound hates math. But Imp loves math. One day, Imp gave icebound a problem.

The problem is as follows.



For given q,n,p, you need to help icebound to calculate the value of S.

输入描述:

The first line contains an integer T, denoting the number of test cases.
The next T lines, each line contains three integers q,n,p, separated by spaces.
,

输出描述:

For each test case, you need to output a single line with the integer S.
示例1

输入

复制
2
2 3 100
511 4 520

输出

复制
14
184