P6157 [CF2048B] Kevin and Permutation
入门
题目描述

Kevin is a master of permutation-related problems. You are taking a walk with Kevin in Darkwoods, and during your leisure time, he wants to ask you the following question.

Given two positive integers $ n $ and $ k $, construct a permutation$^{\text{∗}}$ $ p $ of length $ n $ to minimize the sum of the minimum values of all subarrays$^{\text{†}}$ of length $ k $. Formally, you need to minimize

$$ \sum_{i=1}^{n-k+1}\left( \min_{j=i}^{i+k-1} p_j\right). $$

Input

Each test consists of multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^3$).

The only line of each test case contains two integers $ n $ and $ k $ ($1\le k\le n\le 10^5$).

It is guaranteed that the sum of $ n $ over all test cases doesn't exceed $ 10^5 $.

Output

For each test case, output $ n $ integers on a single line — the permutation $ p $ you constructed.

If there are multiple answers, you can print any of them.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 4 2 6 1 8 3
样例输出
3 1 2 4 5 2 1 6 4 3 4 6 2 8 3 1 5 7
提示

In the first test case, with $ k=2 $, consider all subarrays of length $ 2 $: the minimum value of $ p_1,p_2 $ is $ 1 $, the minimum value of $ p_2,p_3 $ is $ 1 $, and the minimum value of $ p_3,p_4 $ is $ 2 $. The sum $ 1+1+2=4 $ is the smallest among all possible permutations.

In the second test case, all subarrays of length $ 1 $ have minimum values of $ 5, 2, 1, 6, 4, 3 $, and the sum $ 5+2+1+6+4+3=21 $ is proven to be the smallest.