Suki's Lookout Mounds
Suki, a black curly-coated dog with a grey beard and white paws, loves lying on top of the dirt
mounds she has dug in the garden, because from up there she can watch the whole street. The garden
is a grid of R rows and C columns of square patches, and every patch has a height.
A patch makes a good lookout if it is strictly higher than each of its neighbours: the patches directly above, below, to the left and to the right of it that lie inside the garden. Diagonal patches don't count. A patch on the edge of the garden has fewer neighbours, and in a garden of a single patch that patch has none at all, so it is a lookout.
Help Suki find all her lookouts.
Input
The first line contains two integers R and C (1 ≤ R, C ≤ 500).
Each of the next R lines contains C integers h_ij (0 ≤ h_ij ≤ 10^9): the height of the patch
in row i, column j. Rows are numbered from 1 top to bottom and columns from 1 left to right.
Output
On the first line print k, the number of lookouts. Then print k lines, each with two integers:
the row and the column of a lookout. List them in row-major order: by row, and within a row by
column, both increasing. If there are no lookouts, print only 0.
Notes
In the first example the patch of height 9 in row 2, column 2 is higher than its four neighbours 5, 6, 7 and 2. The corner patch of height 8 has only two neighbours, 3 and 7, and is higher than both, and so is the corner patch of height 7 in row 3, column 1 (neighbours 6 and 2). The patch of height 7 in row 2, column 3 is not a lookout, because its neighbour 9 is higher: being higher than its other neighbours isn't enough.
In the second example every patch has the same height. A patch must be strictly higher than its neighbours, so there are no lookouts.