Boxing, karate, sambo… The audience is sick of classic combat sports.
That is why a popular sports channel launches a new competition format based on the traditional Russian entertainment called line fighting.
There can be from 2 to k teams taking part in a competition, and there are n fighters altogether in all the teams.
Before the competition starts, the fighters are divided into teams: each fighter becomes a member of exactly one team.
Two fighters fight each other if they are members of different teams. The organizers believe that
the more the number of fights between fighters, the higher the popularity of a competition will be.
Help the organizers to distribute fighters between teams so as to maximize the number of fights and output this number.
The first line contains the number of tests T (1 ≤ T ≤ 10). In each of the following T lines you are given a test:
integers n and k separated with a space (2 ≤ k ≤ n ≤ 104).
For each test output the answer (one integer) in a separate line.
Problem Author: Alexey Danilyuk
Problem Source: Ural Regional School Programming Contest 2014