Turtle restoring#4019

Turtle restoring

2 seconds
128 megabytes
Medium

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 m~(n, m \le 1000) — 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

In the first line, print the turtle's minimum possible damage. In the next lines print the cell coordinates through which the appropriate path passes. Print the coordinates in the order like they appear on the route.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading