Computers#795

Computers

2 seconds
64 megabytes
Very easy

Everybody likes computers, but buying a new one is always a financial challenge. Fortunately, there is always a convenient way to deal with this. You can replace your computer and get a brand new one, thus saving on maintenance costs. Of course, you must pay a fixed amount for each new computer you get.

Suppose you are considering a period of years during which you want to have a computer. Suppose you buy a new computer in year , 1 \leq y \leq n. Then, in year , you must pay a fixed amount , and for each year you own this computer, starting from year through year (z \leq n), you pay a maintenance cost m(y, z). At year , you may eventually plan to buy another computer.

Write a program that computes the minimum cost of having a computer over the -year period.

Input

The program input comes from a text file. Each data set in the file represents a particular set of costs. A data set starts with the fixed cost for acquiring a new computer. Then follows the number of years, and the maintenance costs m(y, z), y=1..n, z=y..n. The program prints the minimum cost of having a computer over the -year period.

White spaces can occur freely in the input. The input data are correct and end with the end of file.

Output

For each data set, the program prints the result to the standard output, starting from the beginning of a line.

Examples

Example 1

Loading
Loading