The first line of input will contain two integers, w, and h, denoting the width and height (in numbers of squares) of the map. w and h will be in the range 1 – 50, inclusive.
This is followed by w*h integers distributed across an arbitrary number of subsequent lines. Each of these represents the expected tax collection (in gold pieces per year) for one map square. They occur in the order:
(0, 0)(1, 0), . . . , (w - 1, 0)(0, 1)(1, 1), . . . , (w - 1, h - 1)
Each item will be in the range 0–40, inclusive. A value of 0 denotes water or land that is otherwise uninhabitable--castles cannot be built on those squares.
All maps used as input in this problem will be large enough to guarantee that both castles can be placed on a non-zero square, no matter where the first one is placed (i.e., you cannot crowd your rival entirely off the map).