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: EASY

Solutions:
(n, m) = map(int, input().split())
street = []
for i in range(n):
	x = list(map(int, input().split()))
	street.append(x)
(emma_ind, emma) = (-1, -1)
for (j, i) in enumerate(street):
	mn = min(i)
	if mn > emma:
		emma = mn
		emma_ind = j
print(emma)


(n, m) = [int(x) for x in input().split()]
res = -1
for i in range(n):
	res = max(res, min((int(x) for x in input().split())))
print(res)


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


(street, avenue) = map(int, input().split())
cost = list()
min_avenue = 0
max_street = 0
for i in range(street):
	x = list(map(int, input().split()))
	cost.append(x)
	if min(x) > min_avenue:
		max_street = i
		min_avenue = min(x)
print(min_avenue)


(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]))


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
(n, m) = di()
l = [li() for i in range(n)]
mn = 1
for row in l:
	temp = min(row)
	if temp > mn:
		mn = temp
print(mn)


print(max((min(map(int, input().split())) for i in range(int(input().split()[0])))))


(n, m) = map(int, input().split())
l = []
lista = []
for i in range(n):
	lista = list(map(int, input().split()))
	lista.sort()
	l.append(lista[0])
l.sort(reverse=True)
print(l[0])


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
res = 0
for row in a:
	current = float('inf')
	for n in row:
		current = min(current, n)
	res = max(res, current)
print(res)


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	(n, m) = map(int, input().split())
	mx = -1
	for i in range(n):
		l = [int(i) for i in input().split()]
		mx = max(mx, min(l))
	print(mx)
main()


price = 0
maxMin = []
xlist = list(map(int, input().split()))
streets = xlist[0]
avenues = xlist[1]
for j in range(streets):
	costList = list(map(int, input().split()))
	maxMin.append(min(costList))
price = max(maxMin)
print(str(price))


(r, c) = input().split()
r = int(r)
c = int(c)
matrix = [0] * r
for i in range(r):
	matrix[i] = [0] * c
for k in range(r):
	matrix[k] = input().split()
	for p in range(c):
		matrix[k][p] = int(matrix[k][p])
maxi = -1
for d in range(r):
	matrix[d].sort()
	if matrix[d][0] > maxi:
		maxi = matrix[d][0]
print(maxi)


(n, m) = map(int, input().split())
x = 0
for _ in range(n):
	c = list(map(int, input().split()))
	x = max(x, min(c))
print(x)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda val: min(val))
print(min(a[-1]))


(n, m) = map(int, input().split(' '))
mn = 0
mx = 0
for i in range(n):
	a = list(map(int, input().split(' ')))
	for i in range(len(a)):
		if i == 0:
			mn = a[0]
			continue
		if a[i] < mn:
			mn = a[i]
	if mn > mx:
		mx = mn
print(mx)


(n, m) = map(int, input().split())
ul = []
pr = []
for i in range(n):
	pr = [int(i) for i in input().split()]
	ul.append(pr)
	pr = []
mini = []
maxi = []
for i in range(n):
	min1 = ul[i][0]
	for j in range(m):
		if min1 > ul[i][j]:
			min1 = ul[i][j]
	mini.append(min1)
for i in range(n):
	max1 = ul[i][0]
	for j in range(m):
		if max1 < ul[i][j]:
			max1 = ul[i][j]
	maxi.append(max1)
l = 0
while mini[l] != max(mini):
	l += 1
print(mini[l])


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


(n, m) = map(int, input().split())
bm = 0
for i in range(n):
	a = list(map(int, input().split()))
	b = min(a)
	if b > bm:
		bm = b
print(bm)


(n, m) = [int(x) for x in input().split()]
prev = 0
max_arr = []
for i in range(n):
	temp = [int(x) for x in input().split()]
	temp = sorted(temp)
	if temp[0] > prev:
		prev = temp[0]
		max_arr = temp
print(max_arr[0])


print(max((min(map(int, i.split())) for i in [*open(0)][1:])))


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(r, c) = get_ints()
ar = []
dic = {}
for i in range(r):
	tmp = get_list()
	ar.append(tmp)
	mini = min(tmp)
	if mini in dic:
		dic[mini].append(i)
	else:
		dic[mini] = [i]
ans = sorted(dic[sorted(dic)[-1]])[-1]
print(min(ar[ans]))


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


(n, m) = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(n)]
ans = -1
for row in C:
	ans = max(ans, min(row))
print(ans)


try:
	while True:
		(n, m) = map(int, input().split())
		print(max((min(map(int, input().split())) for i in range(n))))
except EOFError:
	pass


(n, m) = 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())
a = [[] for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
b = map(min, a)
ans = max(b)
print(ans)


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


(n, m) = 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) = map(int, input().split())
a = -10 ** 18
for i in range(n):
	x = min(map(int, input().split()))
	a = max(a, x)
print(a)


import logging
import operator
import sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(firstLine, inputLines):
	minList = []
	for line in inputLines:
		minList.append(min(line))
	(max_index, max_value) = max(enumerate(minList), key=operator.itemgetter(1))
	index = max_index
	return max_value

def main():
	firstLine = input().split()
	firstLine = list(map(int, firstLine))
	inputLines = []
	for i in range(firstLine[0]):
		line = input().split()
		line = list(map(int, line))
		inputLines.append(line)
	print(solve(firstLine, inputLines))

def log(*message):
	logging.debug(message)
main()


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


o = input().rstrip().split(' ')
l = []
maxf = -9999
for i in range(0, int(o[0])):
	p = input().rstrip().split(' ')
	p.sort(key=int)
	if int(p[0]) > maxf:
		maxf = int(p[0])
print(maxf)


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


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


l = list(map(int, input().rstrip().split()))
a = []
for i in range(l[0]):
	a.append(list(map(int, input().rstrip().split())))
z = list((min(a[i]) for i in range(l[0])))
print(max(z))


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


def iip():
	return int(input())

def sip():
	return input()

def mip():
	return map(int, input().split())

def lip():
	return list(map(int, input().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst
(n, m) = mip()
arr = matip(n, m)
val = -1
for i in range(n):
	l = min(arr[i])
	if l > val:
		val = l
print(val)


def main():
	(r, c) = [int(x) for x in input().split()]
	ans = 0
	for i in range(r):
		ans = max(ans, min([int(x) for x in input().split()]))
	print(ans)
main()


(n, m) = map(int, input().split(' '))
ls = []
for _ in range(n):
	ls.append(list(map(int, input().split(' '))))
row = []
for i in range(n):
	row.append(min(ls[i]))
m = max(row)
print(min(ls[row.index(m)]))


(N, M) = map(int, input().split())
cur = -1
for n in range(N):
	A = list(map(int, input().split()))
	if cur == -1:
		cur = min(A)
	else:
		cur = max(min(A), cur)
print(cur)


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, m) = mi()
c = []
for i in range(n):
	c.append(li())
posmin = 0
min_ = min(c[0])
for i in range(n):
	if min(c[i]) > min_:
		posmin = i
		min_ = min(c[i])
print(min(c[posmin]))


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


(n, m) = map(int, input().split())
result = 0
for pos in range(n):
	row = list(map(int, input().split()))
	result = max(result, min(row))
print(result)


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	l = list(map(int, input().split()))
	l.sort()
	if l[0] > c:
		c = l[0]
print(c)


def DinnerWithEmma(c):
	minPerRow = []
	for r in c:
		listOfRestaurants = [int(x) for x in r]
		minPerRow.append(min(listOfRestaurants))
	return max(minPerRow)
(n, m) = [int(x) for x in input().split()]
c = []
while n > 0:
	c.append(input().split())
	n -= 1
print(DinnerWithEmma(c))


(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)


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


a = [int(x) for x in str(input()).split()]
N = a[0]
M = a[1]
X = []
maxi = 0
for i in range(0, N):
	X.append([int(x) for x in str(input()).split()])
	maxi = max(maxi, min(X[i]))
print(maxi)


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


(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) = [int(i) for i in input().strip().split()]
grid = [[int(i) for i in input().strip().split()] for j in range(n)]
ans = 0
for i in range(n):
	ans = max(ans, min(grid[i]))
print(ans)


(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 = 10000000000.0
	for j in range(m):
		ml = min(ml, city[i][j])
	ma = max(ma, ml)
print(ma)


(n, m) = [int(j) for j in input().split()]
mat = []
for j in range(n):
	mat.append(min([int(j) for j in input().split()]))
print(max(mat))


(n, m) = map(int, input().split())
A = []
for i in range(n):
	A.append(sorted(map(int, input().split())))
mx = 0
for i in range(n):
	if A[i][0] > mx:
		mx = A[i][0]
print(mx)


(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())
min1 = -1
for i in range(n):
	help = list(map(int, input().split()))
	min1 = max(min1, min(help))
print(min1)


list = [int(x) for x in input().split()]
a = list[0]
b = list[1]
x = []
for t in range(a):
	list = [int(x) for x in input().split()]
	x.append(min(list))
print(max(x))


elso = input().split()
n = int(elso[0])
m = int(elso[1])
lista = []
for _ in range(n):
	sor = input().split()
	sor = list(map(lambda x: int(x), sor))
	lista.append(sor)
lista = list(map(lambda x: min(x), lista))
print(max(lista))


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))


[m, n] = input().split(' ')
a1 = list(input().split(' '))
a1 = list(map(int, a1))
min1 = min(a1)
for i in range(0, int(m) - 1):
	a2 = list(input().split(' '))
	a2 = list(map(int, a2))
	min2 = min(a2)
	if min1 < min2:
		a1 = a2
		min1 = min2
print(min1)


(n, m) = map(int, input().split())
maxi = 0
for _ in range(n):
	x = list(map(int, input().split()))
	if maxi < min(x):
		maxi = min(x)
print(maxi)


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


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(n, m) = zzz()
lst = []
for i in range(n):
	lst.append(min(zzz()))
print(max(lst))


l = []
x = list(map(int, input().split()))[0]
for i in range(x):
	l.append(list(map(int, input().split())))
m = -1
for i in range(x):
	m = max(min(l[i]), m)
print(m)


kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, k) = kk()
v = 0
for _ in range(n):
	ls = ll()
	mi = min(ls)
	if mi > v:
		v = mi
print(v)


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
(n, m) = il()
ans = -1
for i in range(n):
	ans = max(ans, min(il()))
prinT(ans)


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


(n, m) = map(int, input().split())
minim = -1
for _ in range(n):
	k = list(map(int, input().split()))
	if min(k) > minim:
		minim = min(k)
print(minim)


def solve(_n, _m, matrix):
	answer = float('-inf')
	for row in matrix:
		answer = max(answer, min(row))
	return answer
(n, m) = map(int, input().strip().split(' '))
matrix = [0] * n
for row in range(n):
	matrix[row] = list(map(int, input().strip().split(' ')))
print(solve(n, m, matrix))


(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())
c = [list(map(int, input().split())) for i in range(n)]
m = [min(c[i]) for i in range(n)]
print(max(m))


L = [int(x) for x in input().split()]
Data = []
for i in range(L[0]):
	tmp = [int(x) for x in input().split()]
	Data.append(min(tmp))
print(max(Data))


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


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


def solve(g, i, j):
	ans = 0
	for ii in range(i):
		ans = max(ans, min(g[ii]))
	print(ans)
(i, j) = tuple(map(int, input().split()))
g = []
for _ in range(i):
	g.append(list(map(int, input().split())))
solve(g, i, j)


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = [list(map(int, stdin.readline().strip().split())) for i in range(n)]
ans = -10 ** 40
for i in range(n):
	mn = 10 ** 20
	for j in range(m):
		mn = min(mn, s[i][j])
	if mn > ans:
		ans = mn
print(ans)


(n, m) = [int(i) for i in input().split()]
table = []
for i in range(n):
	l = [int(i) for i in input().split()]
	table.append(min(l))
print(max(table))


r = int(input().split(' ')[0])
for i in range(0, r):
	if i == 0:
		k = min([int(x) for x in input().split(' ')])
	else:
		k = max(k, min([int(x) for x in input().split(' ')]))
print(k)


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) = 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))


(n, m) = [int(x) for x in input().split()]
lst = []
for i in range(0, n):
	lst.append(min([int(x) for x in input().split()]))
print(max(lst))


(n, k) = map(int, input().split())
m = -1
for i in range(n):
	li = list(map(int, input().split()))
	if min(li) > m:
		m = min(li)
print(m)


(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])


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) = [int(i) for i in input().split()]
min_max = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	b = min(a)
	if b > min_max:
		min_max = b
print(min_max)


(n, m) = map(int, input().split())
s = []
r = []
k = []
l = []
for j in range(1, n + 1):
	listj = list(map(int, input().split()))
	a = max(listj)
	b = min(listj)
	s.append(a)
	r.append(b)
t = min(s)
k.append(t)
w = max(r)
k.append(w)
h = min(k)
if m == 1:
	h = max(k)
print(h)


alph = 'abcdefghijklmnopqrstuvwxyz'
(n, m) = map(int, input().split())
maxmin = -1
p = 0
for i in range(n):
	c = list(map(int, input().split()))
	if maxmin < min(c):
		maxmin = min(c)
		p = min(c)
print(p)


def dinner(n, m, seq):
	cheapest = 0
	for x in range(n):
		smallest = min(seq[x])
		if smallest > cheapest:
			cheapest = smallest
	return cheapest
(n, m) = list(map(int, input().split()))
seq = []
for y in range(n):
	seq.append(list(map(int, input().split())))
print(dinner(n, m, seq))


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


(n, m) = map(int, input().split())
cur_min = min(map(int, input().split()))
for _ in range(n - 1):
	cur_min = max(cur_min, min(map(int, input().split())))
print(cur_min)


from sys import *
from math import *
from string import *
from operator import *
from functools import *
from fractions import *
from collections import *
setrecursionlimit(10 ** 7)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
RI = lambda : list(map(int, input().split()))
RS = lambda : input().rstrip().split()
(n, m) = RI()
maxVal = 0
for i in range(n):
	maxVal = max(maxVal, min(RI()))
print(maxVal)


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


def main():
	print(max((min(map(int, input().split())) for _ in range(int(input().split()[0])))))
main()


import functools
(n, m) = [int(x) for x in input().split()]
c = []
for i in range(n):
	c.append([int(x) for x in input().split()])
print(max(map(lambda cc: min(cc), c)))


stock = [int(s) for s in input().split()]
life = []
for i in range(stock[0]):
	ray = [int(p) for p in input().split()]
	min = ray[0]
	for p in range(stock[1]):
		if min > ray[p]:
			min = ray[p]
	life.append(min)
max = life[0]
for i in range(stock[0]):
	if max < life[i]:
		max = life[i]
print(max)


n = input().split()
a = int(n[0])
b = int(n[1])
z = []
p = []
for i in range(a):
	z.append(input().split())
for k in range(a):
	t = int(z[k][0])
	for i in range(b):
		if t > int(z[k][i]):
			t = int(z[k][i])
	p.append(t)
t = int(p[0])
for i in range(a):
	if t < int(p[i]):
		t = int(p[i])
print(t)


(n, m) = map(int, input().split())
(l, x) = ([], [])
for i in range(n):
	l.append(list(map(int, input().split())))
	x.extend(l[i])
if n == 1:
	print(min(l[0]))
elif m == 1:
	print(*max(l))
else:
	x = list(set(x))
	x.sort()
	c = 0
	for i in range(len(x)):
		for j in range(n):
			if l[j] != -1 and x[i] in l[j]:
				l[j] = -1
				c += 1
		if c == n:
			print(x[i])
			break
		elif c == n - 1:
			for i in range(n):
				if l[i] != -1:
					print(min(l[i]))
			break


(row, col) = map(int, input().split())
array = [[0 for i in range(col)] for j in range(row)]
for i in range(row):
	s = input()
	c = 0
	for j in s.split():
		array[i][c] = int(j)
		c += 1
	largest = min(array[0])
	for i in range(row):
		if min(array[i]) > largest:
			largest = min(array[i])
print(largest)


(n, m) = map(int, input().split())
min_price = set()
for i in range(n):
	prices = [int(item) for item in input().split()]
	min_price.add(min(prices))
print(max(min_price))


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


__author__ = 'abdujabbor'
(n, m) = [int(x) for x in input().split()]
a = [[0] * m] * n
p = [0] * n
for i in range(n):
	a[i] = sorted([int(x) for x in input().split()])
	p[i] = min(a[i])
print(max(p))


(n, m) = [int(x) for x in input().split(' ')]
c = [[int(x) for x in input().split(' ')] for i in range(n)]
ans = max([min(x) for x in c])
print(ans)


from copy import copy
(n, m) = map(int, input().split())
minval = 0
maxval = []
for i in range(n):
	l = list(map(int, input().split()))
	xx = min(l)
	if xx > minval:
		minval = xx
		maxval = copy(l)
print(min(maxval))


(n, m) = input().split()
n = int(n)
m = int(m)
cost = 0
for i in range(0, n):
	streetwiseCost = []
	streetwiseCost.extend((int(i) for i in input().split()))
	min = streetwiseCost[0]
	for j in range(1, m):
		if streetwiseCost[j] < min:
			min = streetwiseCost[j]
	if i == 0 or cost < min:
		cost = min
print(cost)


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


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


(n, m) = map(int, input().split())
max_v = 0
for i in range(n):
	l = list(map(int, input().split()))
	min_st = 10 ** 10
	for j in range(m):
		min_st = min(min_st, l[j])
	max_v = max(max_v, min_st)
print(max_v)


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


(n, m) = map(int, input().split())
c = []
ans = float('-inf')
for x in range(n):
	ans = max(ans, min(map(int, input().split())))
print(ans)


def solve(A, n, m):
	mins = [min(A[i]) for i in range(n)]
	max_v = mins.index(max(mins))
	return min(A[max_v])
(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
A = []
for i in range(n):
	row = input().split(' ')
	row = [int(r) for r in row]
	A.append(row)
assert len(A[0]) == m
print(solve(A, n, m))


R = lambda : map(int, input().split())
(n, m) = R()
mx = 0
for _ in range(n):
	mx = max(mx, min(R()))
print(mx)


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


line = input().split()
N = int(line[0])
M = int(line[1])
res = 0
for i in range(N):
	m = 1000000000
	line = input().split()
	for j in range(M):
		m = min(m, int(line[j]))
	res = max(res, m)
print(res)


c = 0
(n, k) = map(int, input().split())
for _ in range(n):
	k = min(list(map(int, input().split())))
	c = max(k, c)
print(c)


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


(n, m) = map(int, input().split())
mtx = [[int(w) for w in input().split()] for j in range(n)]
g_max = 0
for i in range(n):
	g_max = max(g_max, min(mtx[i]))
print(g_max)


(n, m) = list(map(int, input().split()))
mi = 1
for i in range(n):
	a = list(map(int, input().split()))
	k = min(a)
	if k > mi:
		mi = k
print(mi)


a = input()
a = a.split()
n = int(a[0])
m = int(a[1])
s = []
ma = -1
for i in range(n):
	te = input()
	te = te.split()
	for j in range(m):
		te[j] = int(te[j])
	temp = min(te)
	if temp > ma:
		ma = temp
print(ma)


(r, c) = map(int, input().split())
max_of_min = 0
for i in range(r):
	a = list(map(int, input().split()))
	min_a = min(a)
	max_of_min = max(max_of_min, min_a)
print(max_of_min)


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


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()


(n, m) = [int(x) for x in input().split(' ')]
out = 0
for i in range(0, n):
	street = [int(x) for x in input().split(' ')]
	street.sort()
	out = max(out, street[0])
print(out)


a = input().split(' ')
n = int(a[0])
m = int(a[1])
c = []
for i in range(n):
	a = map(int, input().split(' '))
	c.append(min(a))
print(max(c))


(n, m) = map(int, input().split())
x = []
y = []
p = 1000000001
for _ in range(0, n):
	y = list(map(int, input().split()))
	x.append(y)
y = []
for i in x:
	y.append(min(i))
print(max(y))


(n, m) = map(int, input().split())
myarr = []
for _ in range(n):
	subarr = list(map(int, input().split()))
	myarr.append(subarr)
mini = [0] * n
for i in range(n):
	mini[i] = min(myarr[i])
print(max(mini))


num = input()
ans = num.split(' ')
n = int(ans[0])
emma_arr = []
for i in range(n):
	arr = [int(c) for c in input().split()]
	emma = min(arr)
	emma_arr.append(emma)
print(max(emma_arr))


(n, m) = map(int, input().split())
f1 = 0
for i in range(n):
	t = list(map(int, input().split()))
	mini = min(t)
	if mini > f1:
		f1 = mini
print(f1)


(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))


(s, a) = list(map(int, input().rstrip().split()))
mat = []
l = []
for i in range(s):
	b = list(map(int, input().rstrip().split()))
	l += [min(b)]
print(max(l))


print(max((min(x) for x in [map(int, s.split()) for s in [*open(0)][1:]])))


(n, m) = map(int, input().split())
maximum = 0
for i in range(n):
	x = list(map(int, input().split()))
	if min(x) > maximum:
		maximum = min(x)
print(maximum)


read = lambda : 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) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
k = []
for j in range(n):
	k.append([min(l[j]), sum(l[j])])
b = [k[i] for i in range(len(k))]
b.sort()
y1 = b[n - 1][0]
y2 = b[n - 1][1]
ind = 0
for j in range(len(k)):
	if k[j][0] == y1:
		if k[j][1] >= y2:
			ind = j
			y2 = k[j][1]
print(min(l[ind]))


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


def supper(lst):
	maximum = 0
	for i in range(len(lst)):
		minimum = 1000000001
		for j in range(len(lst[0])):
			if lst[i][j] < minimum:
				minimum = lst[i][j]
		if minimum > maximum:
			maximum = minimum
	return maximum
(n, m) = [int(i) for i in input().split()]
a = list()
for i in range(n):
	b = [int(j) for j in input().split()]
	a.append(list(b))
print(supper(a))


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
(n, m) = li()
ma_mi = 0
for i in range(n):
	l = li()
	mi = min(l)
	ma_mi = max(ma_mi, mi)
print(ma_mi)


numbers = list(map(int, input().split()))
numOfStreets = numbers[0]
numOfProspects = numbers[1]
street = sorted(list(map(int, input().split())))
numOfStreet = 0
selectedStreed = 1
maxMinNumber = street[0]
price = 0
for i in range(1, numOfStreets):
	street = sorted(list(map(int, input().split())))
	numOfStreet += 1
	if maxMinNumber < street[0]:
		maxMinNumber = street[0]
		selectedStreet = numOfStreet
		price = maxMinNumber
print(maxMinNumber)


(n, m) = list(map(int, input().split()))
Max = -1000000000
for _ in range(n):
	A = min(list(map(int, input().split())))
	if A > Max:
		Max = A
print(Max)


import sys
import math
import bisect

def solve(A):
	n = len(A)
	m = len(A[0])
	B = [0] * n
	for i in range(n):
		B[i] = min(A[i])
	return max(B)

def main():
	(n, m) = map(int, input().split())
	A = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	ans = solve(A)
	print(ans)
main()


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
(n, m) = mi()
x = 0
for _ in range(n):
	x = max(x, min(li()))
print(x)


[n, m] = [int(num) for num in input().split(' ')]
matrix = [[int(num) for num in input().split(' ')] for _ in range(n)]
print(max([min(row) for row in matrix]))


def line_mins(n):
	for i in range(n):
		yield min(map(int, input().split()))

def main():
	(n, m) = map(int, input().split())
	print(max(line_mins(n)))
main()


(n, m) = list(map(int, input().split()))
mini = 0
for i in range(n):
	st = list(map(int, input().split()))
	if min(st) > mini:
		mini = min(st)
print(mini)


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


(n, a) = (int(input().split(' ')[0]), -1)
for i in range(n):
	a = max(a, min([int(j) for j in input().split(' ')]))
print(a)


from sys import stdin
(n, m) = map(int, stdin.readline().split())
print(max([min(list(map(int, stdin.readline().split()))) for i in range(n)]))


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 range(n):
	if minpricestreet[i] > maxposprice:
		street_num = i
		maxposprice = minpricestreet[i]
price = min(town[street_num])
print(price)


import math
(n, m) = map(int, input().split())
ans = -math.inf
for _ in range(n):
	temp = list(map(int, input().split()))
	ans = max(ans, min(temp))
print(ans)


(n, m) = [int(i) for i in input().split()]
min_list = []
for i in range(n):
	row = [int(i) for i in input().split()]
	min_list.append(min(row))
print(max(min_list))


(n, m) = map(int, input().split())
s = [[int(i) for i in input().split()] for j in range(n)]
c = 0
for i in range(n):
	if min(s[i]) > c:
		c = min(s[i])
print(c)


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


(n, m) = list(map(int, input().split()))
maxi = 0
for _ in range(n):
	l = list(map(int, input().split()))
	maxi = max(maxi, min(l))
print(maxi)


street_and_avenue = list(map(int, input().split()))
prices = []
smallest_row = []
smallest_col = []
k = 0
while k < street_and_avenue[0]:
	values = list(map(int, input().split()))
	prices.append(values)
	k += 1
for i in prices:
	smallest_row.append(min(i))
print(max(smallest_row))


(n, m) = map(int, input().split())
maxmin = 0
for i in range(n):
	min = 1000000001
	for c in [int(x) for x in input().split()]:
		if c < min:
			min = c
	if min > maxmin:
		maxmin = min
print(maxmin)


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


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(min(list(map(int, input().split()))))
l.sort()
print(l[-1])


user_input = input().split(' ')
n = int(user_input[0])
m = int(user_input[1])
res = 0
for i in range(0, n):
	row = input().split(' ')
	index = 1000000001
	for a in row:
		index = min(index, int(a))
	res = max(res, index)
print(res)


(streets, avenues) = list(map(int, input().split()))
smallest = []
for street in range(streets):
	smallest.append(min(list(map(int, input().split()))))
print(max(smallest))


arrInfo = input().split()
counterMax = 0
for i in range(int(arrInfo[0])):
	row = input().split()
	counterMin = int(row[0])
	for j in range(len(row)):
		if int(row[int(j)]) < counterMin:
			counterMin = int(row[int(j)])
	if counterMin > counterMax:
		counterMax = counterMin
print(counterMax)


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


l = list(map(int, input().split()))
d = []
(n, m) = (l[0], l[1])
i = 1
while i <= n:
	l = list(map(int, input().split()))
	d += [min(l)]
	i += 1
print(max(d))


(N, M) = map(int, input().split())
max = 0
for i in range(0, N):
	A = list(map(int, input().split()))
	A.sort()
	if max < A[0]:
		max = A[0]
print(max)


(N, M) = map(int, input().split())
res = 0
for _ in range(N):
	res = max(res, min(map(int, input().split())))
print(res)


print(max([min(elm) for elm in [map(int, input().split()) for _ in range(int(input().split()[0]))]]))


def main():
	temp = input().split()
	(n, m) = (int(x) for x in temp)
	matrix = []
	for i in range(n):
		row = input().split()
		row = [int(x) for x in row]
		matrix.append(row)
	print(solver(matrix))

def solver(matrix):
	return max([min(row) for row in matrix])
main()


mn = input().split()
streets = int(mn[0])
avenues = int(mn[1])
inp = []
for i in range(streets):
	street = input().split()
	strt = []
	for j in range(avenues):
		cost = int(street[j])
		strt.append(cost)
	inp.append(strt)
result = max((min(street) for street in inp))
print(result)


X = list(map(int, input().split()))
MaxMin = 0
for i in range(X[0]):
	MaxMin = max(MaxMin, min(list(map(int, input().split()))))
print(MaxMin)


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


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


a = [int(i) for i in input().split()]
ans = 0
for i in range(a[0]):
	c = [int(i) for i in input().split()]
	if ans < min(c):
		ans = min(c)
print(ans)


(n, m) = map(int, input().split())
c = []
for _ in range(n):
	c.append(list(map(int, input().split())))
street = -1
ind = -1
for item in c:
	if min(item) > street:
		street = min(item)
		ind = c.index(item)
print(min(c[ind]))


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


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


import sys
(i, st, av) = (0, 0, 0)
mat = []
for line in sys.stdin:
	numbers = [int(x) for x in line.strip().split()]
	if i == 0:
		(st, av, i) = (numbers[0], numbers[1], 1)
		mat = [[]] * st
		continue
	(mat[i - 1], i) = (numbers, i + 1)
temp = list(map(min, mat))
row = mat[temp.index(max(temp))]
print(row[row.index(min(row))])