An inversion in an array is a pair of positions where the earlier element is the bigger one - formally, positions with .
You are given an array of positive integers. Pick two positions and with , cut out everything strictly between them, and you are left with
Note that cuts out nothing at all, so is then the whole array.
Count the pairs for which the array has at most inversions.
Input
First line of input will be a single integer - the number of testcases.
The first line of each testcase contains two integers and - the length of the array and the largest number of inversions allowed.
The second line contains integers .
Output
For every testcase print a single line with the number of pairs that leave at most inversions.
Example
4 3 1 1 3 2 3 0 1 3 2 5 2 1 5 4 1 100 5 4 1 5 4 1 100
3 1 6 10
The first two testcases use the same array , which has three possible pairs. The pair leaves with no inversions; the pairs and both cut out nothing and leave the whole array, which has one inversion. So one pair works when and all three work when . In the last testcase every one of the pairs stays within inversions.
Constraints
The sum of over all testcases does not exceed
This problem was adapted, with permission, from Inverzije nakon izbacivanja segmenata, authored by Društvo matematičara Srbije and Fondacija Petlja.