6585: Loop

内存限制:512 MB 时间限制:2.500 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

You are given an array a of length n. You must perform exactly k times operations.

For each operation,

 First, you select two integers l,r (1≤l≤r≤n),

 Second, change a to b, satisfy :

    ∘ For each i (1≤i<l) , bi=ai;

    ∘ For each i (l≤i<r) , bi=ai+1;

    ∘ br=al

    ∘ For each i (r<i≤n) , bi=ai;


Find the lexicographically largest possible array after k times operations.

Array x is lexicographically greater than array y if there exists an index i ( 1≤i≤n ) such that xi > yi and for every j(1≤j<i), xj=yj.

输入

The first line of the input contains one integer T (1≤T≤100 ) --- the number of test cases. Then T test cases follow.

The first line of the test case contains two integers n,k (1≤n,k≤300000)

The second line of the test case contains n integers a1,a2,...,an(1≤ai≤300000)

The sum of n over all testcases doesn't exceed 10^6.

The sum of k over all testcases doesn't exceed 10^6.

输出

For each testcase,one line contains n integers ,a1,a2,...,an --- the lexicographically largest possible array after k times operations.
**Don‘t have spaces at the end of the line**

样例输入 复制

2
7 3
1 4 2 1 4 2 4
5 2
4 3 5 4 5

样例输出 复制

4 4 2 4 2 1 1
5 4 5 4 3