Turtle restoring
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
The turtle wants to pass the rectangular table as quickly as possible from top left corner to bottom right corner along the route with the least losses.
Input
The first line contains two positive integers and — the size of the table. Each of the next lines contains integers — the description of the table, each cell contains the amount of acid in it (in milliliters).
The turtle can move only one cell down or right.
Output
Print in the first line the minimal possible turtle's damage. In the next lines print the cells coordinates along which the appropriate path runs. Print the coordinates in the order like they appear on the route.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 3K
Acceptance rate 41%