#!/usr/bin/ruby
while(n=gets.to_i)>0 do
	idx=[]
	m=[]
	n.times{m.push gets.split.map(&:to_i);idx.push [0]*n}
	m.length.times{|i|idx[i][m[i].enum_for(:each_with_index).min[1]]+=1}
	m.length.times{|i|idx[m.transpose[i].enum_for(:each_with_index).max[1]][i]+=2}
	k=0
	n.times{|i|n.times{|j|k=m[i][j] if idx[i][j]==3}}
	p k
end