eolymp
bolt
Try our new interface for solving problems
Problems

MaxSum (jumps to any column)

MaxSum (jumps to any column)

You are given a rectangular table with n rows and m columns. Each cell contains an integer. You can walk along the table from top to bottom, starting from any cell of the upper row, then each time jumping to any cell of the next row (in other words, from the cell with the number (i, j) you can jump to any of the cells (i + 1, 1), (i + 1, 2), ..., (i + 1, m)) and end the route in some cell of the bottom line.

Write a program that finds the maximum possible sum of the values of the traversed cells among all valid paths.

Input

The first line contains the number of rows n and the number of columns m (1n, m200). Each of the next n lines contains exactly m integers (each does not exceed 106 by absolute value) - the values of the table cells.

Output

Print a single number - the maximum sum.

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
4 3
1 15 2
9 7 5
9 2 4
6 9 -1
Output example #1
42
Author Ilya Porublyov
Source 2013 Sevastopol summer school, Wave 1, Day 2