john-maria

In the city of Madrid, there are two types of roads - Boulevard and Woonerf. 
As the people of Madrid are fond of eating, there is exactly one pizzeria on the intersection of each Boulevard and Woonerf.

John decides to take Maria to a pizzeria for a lunch. Maria comes from a rich family while John has a modest background.
Therefore, John does not want to go to an expensive pizzeria. But Maria prefers to go to elite places.

The Boulevards are numbered from 1 to x. The Woonerfs are numbered from 1 to y.
The cost of lunch in the pizzeria at the intersection of the m-th Boulevard and the n-th Woonerf is Cmn.

John and Maria could not finalise a pizzeria because Maria wants to go an expensive pizzeria and John could not afford it.
Therefore, they decided that firstly Maria chooses the Boulevard and then John chooses the Woonerf. The pizzeria at this intersection will be finalised.
Maria and John make their choices optimally. Maria wants to maximize the cost of the lunch, John wants to minimize it.
Maria takes into account that John wants to minimize the cost of the lunch.
Find the cost of their lunch.

Input:
The first line contains two space separated integers x and y. The x is the number of Boulevards and y is the number of Woonerfs in the city of Madrid.
Each of the next x lines contains y integers Cmn, which is the cost of the lunch in the pizzeria on the intersection of the m-th Boulevard and the n-th Woonerf.  

Output:
Print the cost of the lunch for John and Maria.

Constraints:  
1 ≤ x,y ≤ 100
1 ≤ Cmn ≤ 10^9

Example:  

Input:
3 4
4 1 3 5
2 2 2 2
5 4 5 1  

Output:
2  

Explanation:
In this case, if Maria chooses the first or the third Boulevards John can choose an Woonerf with the cost of the lunch 1. 
So she chooses the second Boulevard and John chooses any Woonerf. The cost of the lunch is 2.

SAMPLE INPUT
3 3
1 2 3
2 3 1
3 1 2

SAMPLE OUTPUT
1

Explanation

In this case, regardless of Maria's choice John can choose a pizzeria with the cost of the lunch 1.

Source: hackerearth | Difficulty: MEDIUM


Solutions: