output_description: Print N lines. The i-th line is for scenario of replacing the rook at (X_i,
  Y_i) with your king. This line should contain one integer: the minimum number
  of moves to beat M_i rooks where M_i denotes the maximum possible number of
  beaten rooks in this scenario (in infinite time).
  
  * * *
input_description: Input is given from Standard Input in the following format.
  
      
      
      N
      X_1 Y_1
      X_2 Y_2
      \vdots
      X_N Y_N
attempt: print("わかりましぇん")
  
problem_description: Statement
  
  You are given positions (X_i, Y_i) of N enemy rooks on an infinite chessboard.
  No two rooks attack each other (at most one rook per row or column).
  
  You're going to replace one rook with a king and then move the king repeatedly
  to beat as many rooks as possible.
  
  You can't enter a cell that is being attacked by a rook. Additionally, you
  **can't move diagonally to an empty cell** (but you can beat a rook
  diagonally).
  
  (So this king moves like a superpawn that beats diagonally in 4 directions and
  moves horizontally/vertically in 4 directions.)
  
  For each rook, consider replacing it with a king, and find the minimum
  possible number of moves needed to beat the maximum possible number of rooks.
samples: [{"input": "6\n    1 8\n    6 10\n    2 7\n    4 4\n    9 3\n    5 1", "output": "5\n    0\n    7\n    5\n    0\n    0\n    \n\nSee the drawing below. If we replace rook 3 with a king, we can beat at most\ntwo other rooks. The red path is one of optimal sequences of moves: beat rook\n1, then keep going down and right until you can beat rook 4. There are 7 steps\nand that's the third number in the output.\n\n![path](https://img.atcoder.jp/agc047/rooks_path_small3.png)\n\n_x-coordinate increases from left to right, while y increases bottom to top._\n\nStarting from rook 2, 5 or 6, we can't beat any other rook. The optimal number\nof moves is 0.\n\n* * *"}, {"input": "5\n    5 5\n    100 100\n    70 20\n    81 70\n    800 1", "output": "985\n    985\n    1065\n    1034\n    0\n    \n\n* * *"}, {"input": "10\n    2 5\n    4 4\n    13 12\n    12 13\n    14 17\n    17 19\n    22 22\n    16 18\n    19 27\n    25 26", "output": "2\n    2\n    9\n    9\n    3\n    3\n    24\n    5\n    0\n    25"}]