P10944 [HackerEarth] chotu and chocolate day
普及
题目描述

On Chocolate day, Chotu wants to give his girlfriend a box of chocolate. Chotu has a N X N square box and N^2 chocolates each having a distinct sweetness value between 1 and N^2.

To make the box look attractive Chotu must fill each row with chocolates arranged in increasing value of sweetness. Chotu also knows that his girlfriend loves the number K so he wants to maximize the total sweetness of the K^th column.
Help Chotu arrange the chocolate in the box in a way that each row has choclates with increasing value of sweetness and the total sweetness of K^th column is maximized.

As there are multiple ways to arrange chocolates, your task is to tell Chotu the maximum possible sweetness he can have for the K^th column.
Input

First line contains integer T denoting number of testcases.
Each testcase has two integers N and K.

Ouptut

For each test case print answer in single line the maximum possible sweetness Chotu can have for the K^th column.

Constraints

1 ≤ T ≤ 20

1 ≤ N ≤ 10^3

1 ≤ K ≤ N

SAMPLE INPUT
1
4 1

SAMPLE OUTPUT
28

Explanation

For the given sample case one possible arrangement of chocolates is

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
The total sweetness of first column is 28.

输入格式

见题面

输出格式

见题面

样例输入
20 619 495 67 12 470 97 544 529 396 340 963 9 154 24 167 32 469 439 507 450 346 76 569 204 518 245 955 107 426 151 883 559 70 37 832 279 176 93 784 778 694 450
样例输出
213191028 173262 62427280 158617888 57618990 449778780 2088933 2749822 99745513 122855226 25153681 124868188 102160996 483424820 52206726 561623320 258580 383954688 4143568 479737048