loop do
  n = gets.strip.to_i
  break if n == 0

  mtx = n.times.map{gets.strip.split(' ').map(&:to_i)}

  shortests = (0...n).map{|y| mtx[y].min}
  tallests  = (0...n).map{|x| (0...n).map{|y| mtx[y][x]}.max}

  h = 0

  for y in (0...n)
    sv = shortests[y]
    for x in (0...n)
      if sv == tallests[x] && mtx[y][x] == sv
        h = sv
        break
      end
    end
  end

  puts h
end