Turtle#4018

Turtle

2 секунди
128 мегабајти
Многу лесно

In the top-left corner of a rectangular table of size n \times m, there is a turtle. Each cell of the table contains some amount of acid. The turtle can move only right or down; its journey ends in the bottom-right cell of the table.

Влез

The first line contains two natural numbers and (1 \le n, m \le 1000) — the dimensions of the table. Each of the next lines contains integers, separated by spaces — the description of the table, where each number denotes the amount of acid in the corresponding cell (in milliliters).

Излез

Output the minimum possible damage the turtle can receive.

Примери

Пример 1

Loading
Loading

Пример 2

Loading
Loading