Golf course Puzzle

0

0 votes
Basic Programming, Easy
Problem

A ABC company wants to invest into building a golf course. They could choose the land which is of rectangular shape of size AxB. The rectangle area is divided into AxB cells. They measured the elevation of each cell and recorded it into an integer number. The company decided that the golf course should be a KxK square (K <= min(A,B)). Thus, there are (A-K+1)(B-K+1) possible KxK squares that can be used to build the golf course. For each such square, the company wants to know the highest elevation of a cell inside the square. They also need to know how many cells that have such highest elevations.

Write a program that help the company do the above task.

Input

The first line contains t, the number of test cases (about 10). Then t test cases follow. Each test case has the following form:

  • The first line contains three integers A, B, K (1 <= A, B <= 10, 1 <= K <= min(A,B) ).
  • There are A lines follow. Each line contains B nonnegative integers not exceeding 50. Each integer represents the elevation of a cell.

There is a blank line after each test case.

Output

For each test case, in the first line print "Case d:" where d is the number of the test case. Then print A-K+1 lines and in each line print B-K+1 entries. Successive entries should be separated by spaces. The entry in the ith line and the jth column has the following form:

  • The first number is the highest elevation of a cell in the KxK square whose top left corner is (i,j).
  • If there is more than one cell in the square that has the highest elevation, print (c), where c is the number of cells inside the square that have the highest elevation.

Print a blank line after each test case.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?