This page is still under construction.

Parts of this page are still being built. What you see may change.

Skidor

Time limit7sMemory limit1024 MB

Summary
Find an L by L square with no trees whose height range is minimal, breaking ties by smallest top row then left column.
Level

Hard8 of 10

Topics
Sliding window, Heap, Matrix, Implementation
Solved
No attempts yet

Problem

Johan likes to ski. Not slalom, which Johan is very afraid of. Cross-country skiing, on the other hand, is his thing. When you go cross-country skiing, however, you need large flat surfaces.

Johan has surveyed a large rectangular area out in the forest, whose ground is quite uneven. Here Johan wants to pick out a certain square to ski around on, one large enough to make the skiing interesting. The square must have exactly size L×LL \times L, and have sides parallel to the sides of the area.

Now he asks you to find such a square. For it to suit cross-country skiing well, he has two requirements. First, there must be no trees in the square, and second, the height difference between the highest and lowest point in this square must be as small as possible.

If there are several such possible squares, you should first choose the one that lies farthest north, i.e. has the lowest row number. If there are still several possible, you should second choose the one that lies farthest west, i.e. has the lowest column number.

Input

The first line contains three integers RR, CC, LL such that 1≤R,C≤1000,1≤L≤min(R,C)1\leq R,C \leq 1000, 1 \leq L \leq min(R,C). RR is the number of rows in the large area, CC the number of columns, and LL the size of the square to find.

Then follow RR lines, one for each row in the area. A line contains CC integers, one for each column in the area.

The ccth number on the rrth line describes the height HrcH_{rc} at that point in the area, which is such that −1≤Hrc≤109-1 \leq H_{rc} \leq 10^9. If Hrc=−1H_{rc} = -1, there is instead a tree standing at that spot.

Output

Find rlr_l, clc_l such that Johan's square spans the coordinates rl≤r<rl+Lr_l \leq r < r_l + L, cl≤c<cl+Lc_l \leq c < c_l + L. rlr_l and clc_l must be 0-indexed, for example rl=0r_l = 0 if the first row (the one farthest north) is meant, and cl=0c_l = 0 if the first column (the one farthest west) is meant.

It is guaranteed that a solution exists.

Examples1

  1. Example 1

    Input
    3 3 2
    10 3 5
    2 4 3
    2 8 1
    
    Expected output
    0 1