A ladle is carried across a foundry laid out as a grid of R rows and C columns. Each cell holds a non-negative heat cost that is added to the running total when the ladle enters that cell (the starting top-left cell is always entered). The ladle begins at the top-left cell and must reach the bottom-right cell, moving on each step to the cell immediately to the right or immediately below.
Determine the minimum possible total heat over all such routes.
Input format
Line 1: two integers R and C.
Next R lines: each contains C non-negative integers, the heat costs of that row.
Output format
A single integer: the minimum total heat of a right/down route from the top-left cell to the bottom-right cell.
Constraints
- 1 <= R <= 100
- 1 <= C <= 100
- 0 <= each heat cost <= 1000