#P1008. Picking apples

Picking apples

题目描述

Little m has a farm which is located in the north of the city. When Sunday, he always goes back to his farm enjoying picking apples from his apple trees. For more fun, he would like to pick apples from the apple trees in such a way:

  • If every non-empty apple tree has the same number of apples, then just pick one apple from the minimum index apple tree of all non-empty apple trees.

  • Otherwise, just pick one apple from the apple tree which has the second maximum number of apples, if there are more than one trees which have the second maximum number of apples, choose the apple tree with the minimum index.

  • If all apple trees are empty, just do nothing.

Today, little m goes back as usual and he picks kk turns of apples, could you tell him the remaining apples on each apple tree?

picture: apple trees

输入格式

First line of the input contains one integer T(1leTle100)T(1\\le T\\le100) indicates the number of testcases.

For each test case:

The first line contains two positive integers n,k(1len,kle100)n,k(1\\le n,k\\le100) indicate the number of the apple tree and the number of the turns to pick apple.

The second contains nn positive integers a[i](1lea[i]le100)a[i](1\\le a[i]\\le100) indicates the apple on the ithi-th apple tree.

输出格式

For each test case, print one line the remaining apples on each apple tree with the original order.

样例

2 
3 2 
1 2 3 
3 3 
3 2 3 
0 1 3 
2 0 3

提示

For the testcase 1, the operations are below: turn 1: 1 1 3 turn 2: 0 1 3 For the testcase 2, the operations are below: turn 1: 3 1 3 turn 2: 3 0 3 turn 3: 2 0 3