CodeForces
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city. Let's represent the city as an area of n×nn×n square blocks. Yura needs to move from the block with coordinates (sx,sy)(sx,sy) to the block with coordinates (fx,fy)(fx,fy). In one minute Yura can move to any neighboring by side block; in other words, he can move in four directions. Also, there are mm instant-movement locations in the city. Their coordinates are known to you and Yura. Yura can move to an