{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe game of Chess has several pieces with curious movements. One of them is the \u003ci\u003eQueen\u003c/i\u003e, which can move any number of squares in any direction: in the same line, in the same column or in any of the diagonals, as illustrated by the figure below (black dots represent positions the queen may reach in one move):\u003c/p\u003e\r\n\u003ccenter\u003e\r\n\t\u003cp style\u003d\"text-align: center;\"\u003e\r\n\t\t\u003cimg height\u003d\"145\" src\u003d\"http://uva.onlinejudge.org/external/114/p11494.png\" width\u003d\"202\" /\u003e\u003c/p\u003e\r\n\u003c/center\u003e\r\n\u003c!--\r\nO jogo de xadrez possui várias peças com movimentos curiosos: uma delas\r\né a \\emph{dama}, que pode se mover qualquer quantidade de quadrados na mesma\r\nlinha, na mesma coluna, ou em uma das duas diagonais, conforme\r\nexemplifica a figura abaixo:\r\n\r\n\\begin{center}\r\n\\epsfig{file\u003ddama_alt.eps}\r\n\\end{center}\r\n--\u003e\u003cp\u003e\r\n\tThe great Chess Master \u003cspan data-scayt_word\u003d\"Kary\" data-scaytid\u003d\"21\"\u003eKary\u003c/span\u003e \u003cspan data-scayt_word\u003d\"Gasparov\" data-scaytid\u003d\"22\"\u003eGasparov\u003c/span\u003e invented a new type of chess problem: given the position of a queen in an empty standard chess board (that is, an 8 x 8 board) how many moves are needed so that she reaches another given square in the board?\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u003cspan data-scayt_word\u003d\"Kary\" data-scaytid\u003d\"23\"\u003eKary\u003c/span\u003e found the solution for some of those problems, but is having a difficult time to solve some others, and therefore he has asked that you write a program to solve this type of problem.\u003c!--\r\nO grande mestre de xadrez Kary Gasparov inventou um novo tipo de\r\nproblema de xadrez: dada a posição de uma dama em um tabuleiro de\r\nxadrez vazio, de quantos movimentos, no mínimo, ela precisa para\r\nchegar em outro quadrado do tabuleiro?\r\n\r\nKary achou a solução para alguns desses problemas, mas teve\r\ndificuldade com outros, e por isso pediu que você escrevesse um\r\nprograma que resolve esse tipo de problema.\r\n--\u003e\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe input contains several test cases. The only line of each test case contains four integers \u003ci\u003e\u003cspan data-scayt_word\u003d\"X1\" data-scaytid\u003d\"1\"\u003eX\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan data-scayt_word\u003d\"Y1\" data-scaytid\u003d\"2\"\u003eY\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan data-scayt_word\u003d\"X2\" data-scaytid\u003d\"11\"\u003eX\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e\u003c/i\u003e and \u003ci\u003e\u003cspan data-scayt_word\u003d\"Y2\" data-scaytid\u003d\"13\"\u003eY\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e\u003c/i\u003e (\u003ci\u003e1 \u0026le; \u003cspan data-scayt_word\u003d\"X1\" data-scaytid\u003d\"3\"\u003eX\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e, \u003cspan data-scayt_word\u003d\"Y1\" data-scaytid\u003d\"5\"\u003eY\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e, \u003cspan data-scayt_word\u003d\"X2\" data-scaytid\u003d\"12\"\u003eX\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e, \u003cspan data-scayt_word\u003d\"Y2\" data-scaytid\u003d\"14\"\u003eY\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e \u0026le; 8\u003c/i\u003e). The queen starts in the square with coordinates \u003ci\u003e(\u003cspan data-scayt_word\u003d\"X1\" data-scaytid\u003d\"4\"\u003eX\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e, \u003cspan data-scayt_word\u003d\"Y1\" data-scaytid\u003d\"6\"\u003eY\u003csub\u003e1\u003c/sub\u003e\u003c/span\u003e)\u003c/i\u003e, and must finish at the square with coordinates \u003ci\u003e(\u003cspan data-scayt_word\u003d\"X2\" data-scaytid\u003d\"19\"\u003eX\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e, \u003cspan data-scayt_word\u003d\"Y2\" data-scaytid\u003d\"20\"\u003eY\u003csub\u003e2\u003c/sub\u003e\u003c/span\u003e)\u003c/i\u003e. In the chessboard, columns are numbered from 1 to 8, from left \u003cspan data-scayt_word\u003d\"ro\" data-scaytid\u003d\"28\"\u003ero\u003c/span\u003e right; lines are also numbered from 1 to 8, from top to bottom. The coordinates of a square in line \u003ci\u003eX\u003c/i\u003e and column \u003ci\u003eY\u003c/i\u003e are (\u003ci\u003eX, Y\u003c/i\u003e).\u003c/p\u003e\r\n\u003cp\u003e\r\n\tThe end of input is indicated by a line containing four zeros, separated by spaces.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tFor each test case in the input your program must print a single line, containing an integer, indicating the smallest number of moves needed for the queen to reach the new position.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n4 4 6 2\r\n3 5 3 5\r\n5 5 4 3\r\n0 0 0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n1\r\n0\r\n2\u003c/pre\u003e"}}]}