#P1870C. Colorful Table

    ID: 8746 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 4 Uploaded By: Tags>binary searchdata structuresdpimplementationmathtwo pointers*1300

Colorful Table

No submission language available for this problem.

Description

You are given two integers nn and kk. You are also given an array of integers a1,a2,,ana_1, a_2, \ldots, a_n of size nn. It is known that for all 1in1 \leq i \leq n, 1aik1 \leq a_i \leq k.

Define a two-dimensional array bb of size n×nn \times n as follows: bi,j=min(ai,aj)b_{i, j} = \min(a_i, a_j). Represent array bb as a square, where the upper left cell is b1,1b_{1, 1}, rows are numbered from top to bottom from 11 to nn, and columns are numbered from left to right from 11 to nn. Let the color of a cell be the number written in it (for a cell with coordinates (i,j)(i, j), this is bi,jb_{i, j}).

For each color from 11 to kk, find the smallest rectangle in the array bb containing all cells of this color. Output the sum of width and height of this rectangle.

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. Then follows the description of the test cases.

The first line of each test case contains two integers nn and kk (1n,k1051 \leq n, k \leq 10^5) — the size of array aa and the number of colors.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1aik1 \leq a_i \leq k) — the array aa.

It is guaranteed that the sum of the values of nn and kk over all test cases does not exceed 10510^5.

For each test case, output kk numbers: the sums of width and height of the smallest rectangle containing all cells of a color, for each color from 11 to kk.

Input

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. Then follows the description of the test cases.

The first line of each test case contains two integers nn and kk (1n,k1051 \leq n, k \leq 10^5) — the size of array aa and the number of colors.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1aik1 \leq a_i \leq k) — the array aa.

It is guaranteed that the sum of the values of nn and kk over all test cases does not exceed 10510^5.

Output

For each test case, output kk numbers: the sums of width and height of the smallest rectangle containing all cells of a color, for each color from 11 to kk.

Sample Input 1

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

Sample Output 1

4 
4 2 
0 6 6 2 0 
8 6 
10 6 2

Note

In the first test case, the entire array bb consists of color 11, so the smallest rectangle for color 11 has a size of 2×22 \times 2, and the sum of its sides is 44.

In the second test case, the array bb looks like this:

11
12

One of the corner cells has color 22, and the other three cells have color 11. Therefore, the smallest rectangle for color 11 has a size of 2×22 \times 2, and for color 22 it is 1×11 \times 1.

In the last test case, the array bb looks like this:

11111
12221
12321
12221
11111