Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.

Munhattan consists of n streets and m avenues. There is exactly one restaurant on the intersection of each street and avenue. The streets are numbered with integers from 1 to n and the avenues are numbered with integers from 1 to m. The cost of dinner in the restaurant at the intersection of the i-th street and the j-th avenue is c_{ij}.

Jack and Emma decide to choose the restaurant in the following way. Firstly Emma chooses the street to dinner and then Jack chooses the avenue. Emma and Jack makes their choice optimally: Emma wants to maximize the cost of the dinner, Jack wants to minimize it. Emma takes into account that Jack wants to minimize the cost of the dinner. Find the cost of the dinner for the couple in love.


-----Input-----

The first line contains two integers n, m (1 ≤ n, m ≤ 100) — the number of streets and avenues in Munhattan.

Each of the next n lines contains m integers c_{ij} (1 ≤ c_{ij} ≤ 10^9) — the cost of the dinner in the restaurant on the intersection of the i-th street and the j-th avenue.


-----Output-----

Print the only integer a — the cost of the dinner for Jack and Emma.


-----Examples-----
Input
3 4
4 1 3 5
2 2 2 2
5 4 5 1

Output
2

Input
3 3
1 2 3
2 3 1
3 1 2

Output
1



-----Note-----

In the first example if Emma chooses the first or the third streets Jack can choose an avenue with the cost of the dinner 1. So she chooses the second street and Jack chooses any avenue. The cost of the dinner is 2.

In the second example regardless of Emma's choice Jack can choose a restaurant with the cost of the dinner 1.

Difficulty: interview

Starter code:

Solutions:
q=list(map(int,input().split()))
a=[]
s=[]
for i in range(0,q[0]):
    s+=[min(list(map(int,input().split())))]
print(max(s))


read = lambda: list(map(int, input().split()))
n, m = read()
c = [tuple(read()) for i in range(n)]
ans = 0
for i in range(n):
    cur = min(c[i])
    if cur > ans: ans = cur
print(ans)


n, m = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(list(map(int,input().split())))
    b.append(min(a[i]))
print(max(b))


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time



(n, m) = (int(i) for i in input().split())
ans    = 0

for i in range(n):
    b = min([int(j) for j in input().split()])
    if b > ans:
        ans = b

start = time.time()

print(ans)
finish = time.time()
#print(finish - start)


#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

n, m = [int(i) for i in input().split()]

city = []

for i in range(n):
    city.append([int(i) for i in input().split()])

ma = 0

for i in range(n):
    ml = 1e10 # bigger than any

    for j in range(m):
        ml = min(ml, city[i][j])

    ma = max(ma, ml)

print(ma)    


n, m = list(map(int, input().split()))

streets = []

for a in range(0, n):
    street = list(map(int, input().split()))
    streets.append(min(street))

print(max(streets))


n, m = map(int, input().split())

mas = []

for i in range(n):
    cur = list(map(int, input().split()))
    mas.append(min(cur))

print(max(mas))

n, m = list(map(int, input().split()))
streets = [list(map(int, input().split())) for _ in range(n)]
print(max([min(x) for x in streets]))


n, m = map(int, input().split())

mat = []
maxi = 0
for i in range(n):
    a = list(map(int, input().split()))
    mini = min(a)
    maxi = max(maxi, mini)
print(maxi)

n, m = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
print(max([min(i) for i in a]))


n, m = map(int, input().split())
print(max(min(map(int, input().split())) for i in range(n)))

n, m = list(map(int, input().split(' ')[:2]))

c = [list(map(int, input().split(' ')[:m])) for _ in range(n)]

mins = list(map(min, c))

print(max(mins))


n, m = (int(i) for i in input().split())
masha = {}
pasha = {}
max = 0
vybor = 0
for i in range(1, n+1):
    street = [int(i) for i in input().split()]
    mininstreet = min(street)
    pasha.update({i:mininstreet})
    if max <= mininstreet:
        max = mininstreet
        vybor = i
print(pasha[vybor])

import sys
n,m = list(map(int,sys.stdin.readline().split()))
t = -1
for i in range(n):
    a = [1] * m
    a = list(map(int,sys.stdin.readline().split()))
    k = min(a)
    t = max(k,t)
print(t)



n, m = map(int, input().split())
print(max([min(list(map(int, input().split()))) for i in range(n)]))

n, m = [int(_) for _ in input().split()]

ans = []
for i in range(n):
	ary = []
	inp = input().split()
	for q in inp:
		ary.append(int(q))
	ans.append(min(ary))

print(max(ans))


def main():
    n, m = map(int, input().split())
    l = []

    for _ in range(n):
        a = list(map(int, input().split()))
        l.append(min(a))

    print(max(l))

def __starting_point():
    main()
__starting_point()

n,m=list(map(int,input().split()))
mn=0
for i in range(n):
    mas=list(map(int,input().split()))
    if mn<min(mas):
        mn=min(mas)
print(mn)



n, m = map(int, input().split())
ans = 0
for i in range(n):
    ans = max(ans, min((map(int, input().split()))))
print(ans)

s=input().split()
n=int(s[0])
m=int(s[1])
town=[]
town = []
minpricestreet=[]
for i in range(n):
    row = input().split()
    for k in range(len(row)):
        row[k] = int(row[k])
    town.append(row)
    minpricestreet.append(min(row))
 
maxposprice=0
  
for i in (list(range(n))):
    if minpricestreet[i]>maxposprice:
        street_num=i
        maxposprice=minpricestreet[i]

price=min(town[street_num])
    
        
print(price)        


n, m = map(int, input().split())
min1 = -1
for i in range(n):
    help = list(map(int, input().split()))
    min1 = max(min1, min(help))
print(min1)

n, m = [int(x) for x in input().split()]
X = []
for i in range(n):
    X.append([int(x) for x in input().split()])

print(max(min(Xi) for Xi in X))


n,m = map(int,input().split())
print(max([min(list(map(int,input().split()))) for _ in range(n)]))

n , m = tuple(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n)]
mins = [min(l[i]) for i in range(n)]
print(max(mins))

r,c =list(map(int,input().split()))
op=[]
for i in range(r):
    ip=list(map(int,input().split()))
    op.append(min(ip))
print(max(op))