Robinson
Robinson has finally downloaded a photo of his island from the Internet and is ready to build a hut on the southern coast. The island is surrounded by the ocean and contains internal water bodies. The photo is represented as a rectangular matrix of size N × M, where each cell is either 0 (water) or 1 (land). Robinson's current dwelling is located at coordinates A, B. Your task is to help Robinson select a cell C, D on the southern coast to construct his new hut, ensuring that the travel time T between the two huts is minimized. If multiple cells meet this criterion, you only need to provide one of them. Robinson can move between adjacent cells that share a side, spending 1 hour on a land cell and 3 hours on a water cell (including the first and last cells of the journey). A cell on the southern coast is defined as the last 1 in each column of the matrix.
Input data:
The first line contains the integers N, M, A, B — natural numbers, each not exceeding 100. The following N lines each contain M numbers, either 0 or 1.
Output data:
The first line should contain T — the minimum travel time between the huts. The second line should contain the coordinates C, D of the new hut on the southern coast.