Construction of a warehouse
On a map of size M×N, a player controls a hero who can build a warehouse in one of the map's cells to store various items scattered across it. In each move, the hero can:
Move to an adjacent cell, either horizontally or vertically.
Pick up an item if there is at least one item in the current cell and the hero's inventory is empty (the items are too heavy for the hero to carry more than one at a time).
Deposit the item from the inventory into the warehouse if the hero is in the cell where the warehouse is located.
Kolya wants to determine the optimal location for the warehouse so that, once built, the total number of moves needed to collect and store all items on the map is minimized.
Input
The first line contains two integers, M and N, representing the dimensions of the map (1 ≤ M, N ≤ 1000). The following M lines each contain N integers, indicating the number of items in each corresponding cell of the map. All these numbers are non-negative and do not exceed 1000.
Output
Output the coordinates (row and column) of the cell where the warehouse should be placed on the first line, followed by the minimum number of moves required to collect and store all the items on the second line. Note that if an item is located in the same cell as the warehouse, it must still be picked up and placed in the warehouse.