Neighborhood Rivalry

No attempts yetTime limit2.5sMemory limit128 MB

Problem

Hektor lives in a single-family house in an estate of similar houses laid out on a regular grid of W×KW \times K houses, split into WW rows and KK columns. Each house occupies one 1×11 \times 1 cell, and its position is a pair of numbers: the row index and the column index of that cell.

A year ago the estate ran a contest for the best-trimmed lawn, and the judges gave every house a score. This year the contest returns. The residents love to compete and hate being outdone by their neighbors at anything, so Hektor expects every house to aim for a score at least as high as the best score anywhere in its neighborhood last year. The neighborhood of the house at (w,k)(w, k) is every house at (a,b)(a, b) with awR|a - w| \le R and bkR|b - k| \le R; it therefore forms a square of side 2R+12R + 1 centered at (w,k)(w, k) (near the borders only the cells that actually exist inside the estate count).

Given the score of every house, compute for each house the highest score in its neighborhood.

Input

The first line contains a natural number ZZ (1Z101 \le Z \le 10): the number of test sets. The test sets follow one after another.

The first line of each test set contains three space-separated natural numbers WW, KK, RR (1W,K,R10001 \le W, K, R \le 1000): the number of rows, the number of columns, and the neighborhood radius.

Each of the next WW lines describes one row of the estate, from the first row to the WW-th. Such a line holds KK space-separated natural numbers gig_i (1gi10000001 \le g_i \le 1000000): the scores of that row's houses, from the first column to the KK-th.

Output

For each test set, print WW lines with KK space-separated numbers each: the highest neighborhood score for every house, in the same order as the input.