|Codeforces Round #241 (Div. 2)|
A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.
Each painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the first painter uses color 1, the second one uses color 2, and so on. Each picture will contain all these n colors. Adding the j-th color to the i-th picture takes the j-th painter t ij units of time.
Order is important everywhere, so the painters' work is ordered by the following rules:
Given that the painters start working at time 0, find for each picture the time when it is ready for sale.
The first line of the input contains integers m, n (1 ≤ m ≤ 50000, 1 ≤ n ≤ 5), where m is the number of pictures and n is the number of painters. Then follow the descriptions of the pictures, one per line. Each line contains n integers t i1, t i2, ..., t in (1 ≤ t ij ≤ 1000), where t ij is the time the j-th painter needs to work on the i-th picture.
Print the sequence of m integers r 1, r 2, ..., r m, where r i is the moment when the n-th painter stopped working on the i-th picture.
1 3 6 10 15
7 8 13 21