#P1996B. Scale
Scale
Description
Tina has a square grid with rows and columns. Each cell in the grid is either or .
Tina wants to reduce the grid by a factor of ( is a divisor of ). To do this, Tina splits the grid into 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 .
Help Tina reduce the grid by a factor of .
The first line contains () – the number of test cases.
The first line of each test case contains two integers and (, , is a divisor of ) — the number of rows and columns of the grid, and the factor that Tina wants to reduce the grid by.
Each of the following lines contain characters describing the cells of the grid. Each character is either or . It is guaranteed every by block has the same value.
It is guaranteed the sum of over all test cases does not exceed .
For each test case, output the grid reduced by a factor of on a new line.
Input
The first line contains () – the number of test cases.
The first line of each test case contains two integers and (, , is a divisor of ) — the number of rows and columns of the grid, and the factor that Tina wants to reduce the grid by.
Each of the following lines contain characters describing the cells of the grid. Each character is either or . It is guaranteed every by block has the same value.
It is guaranteed the sum of over all test cases does not exceed .
Output
For each test case, output the grid reduced by a factor of on a new line.