Maksim walk cartesian plane initially stand point 0 0 adjacent point leave right for example Maksim currently point 0 0 follow point 1 0 0 1 1 0 0 1 there n distinct key point plane the ith point p_i x_i y_i it guarantee 0 le x_i 0 le y_i key point 0 0let level point point maxx_i y_i 1 second level point point maxx_i y_i 2 Maksim want visit key point but should not visit point level 1 visit point level he start visit point minimum level point give setthe distance point x_1 y_1 x_2 y_2 x_1 x_2 y_1 y_2 v absolute value vMaksim wants visit key point way total distance walk minimum possible your task find distanceif Python programmer consider PyPy instead Python submit code