Pigeon Holes


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

In the staff lounge at GIHS, the pigeon hole cabinet is frequently collapsing because some pigeon holes are too heavy!

The pigeon holes are arranged in an m \times n grid in the teachers' staff room, one for each of the m \times n teachers at GIHS.

Some pigeon holes are too heavy and overflowing for one of two reasons. Either there are too many letters arriving in certain teachers' pigeon holes, or some teachers forget to check their pigeon hole often.

Regardless of why the pigeon holes are overflowing, the maintenance team wants a fast program to tell them the heaviest pigeon hole weight in each column of the pigeon hole grid so they can alert the teachers to clear out their pigeon holes and stop the collapse!

Input

The first line contains two integes m and n (1 \leq m, n \leq 1000), representing the number of rows and columns of pigeon holes respectively.

There are then m lines to represent a row of the pigeon hole grid.

Each row contains n integers, which are the weights w_{i,j} of each pigeon hole in the current row.

w_{i,j} represents the weight of the pigeon hole on row i column j (0 \le w_{i,j} \le 10^9).

Output

Output the heaviest pigeon hole weight in each column of the pigeon hole grid.

This will allow the maintenance staff to tell the teachers with overflowing pigeon holes to clear them out!

Output each of the heaviest weights on a new line.

Example

Input 1
3 3
1 2 1
3 2 0
0 1 0
Output 1
3 
2 
1

Example 1

  • Miss D has the heaviest pigeon hole in column 0 at weight 3.
  • Mrs B and Mr E both have the heaviest weight in column 2 at weight 2.
  • Mr C has the heaviest pigeon hole in column 2 at weight 1.
Input 2
2 3
0 15 4
3 4 8
Output 2
3 
15 
8
Input 3
1 1
5
Output 3
5

Comments

There are no comments at the moment.