#P1996B. Scale

Scale

Description

Tina has a square grid with nn rows and nn columns. Each cell in the grid is either 00 or 11.

Tina wants to reduce the grid by a factor of kk (kk is a divisor of nn). To do this, Tina splits the grid into k×kk \times k nonoverlapping blocks of cells such that every cell belongs to exactly one block.

Tina then replaces each block of cells with a single cell equal to the value of the cells in the block. It is guaranteed that every cell in the same block has the same value.

For example, the following demonstration shows a grid being reduced by factor of 33.

Original grid
000000111111
000000111111
000000111111
111111000000
111111000000
111111000000
Reduced grid
0011
1100

Help Tina reduce the grid by a factor of kk.

The first line contains tt (1t1001 \leq t \leq 100) – the number of test cases.

The first line of each test case contains two integers nn and kk (1n10001 \leq n \leq 1000, 1kn1 \le k \le n, kk is a divisor of nn) — the number of rows and columns of the grid, and the factor that Tina wants to reduce the grid by.

Each of the following nn lines contain nn characters describing the cells of the grid. Each character is either 00 or 11. It is guaranteed every kk by kk block has the same value.

It is guaranteed the sum of nn over all test cases does not exceed 10001000.

For each test case, output the grid reduced by a factor of kk on a new line.

Input

The first line contains tt (1t1001 \leq t \leq 100) – the number of test cases.

The first line of each test case contains two integers nn and kk (1n10001 \leq n \leq 1000, 1kn1 \le k \le n, kk is a divisor of nn) — the number of rows and columns of the grid, and the factor that Tina wants to reduce the grid by.

Each of the following nn lines contain nn characters describing the cells of the grid. Each character is either 00 or 11. It is guaranteed every kk by kk block has the same value.

It is guaranteed the sum of nn over all test cases does not exceed 10001000.

Output

For each test case, output the grid reduced by a factor of kk on a new line.

Sample Input 1

4
4 4
0000
0000
0000
0000
6 3
000111
000111
000111
111000
111000
111000
6 2
001100
001100
111111
111111
110000
110000
8 1
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111

Sample Output 1

0
01
10
010
111
100
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111