{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eThe Avengers become divided, both over how to approach Loki and the revelation that S.H.I.E.L.D. plans to harness the Tesseract to develop weapons as a deterrent against hostile extraterrestrials. The argument is raised between Captain America, Iron man and Thor each having his own point to keep. Agent Natasha Romanoff comes up with a non-violent solution to this argument by suggesting a variant of the game of chess for three players. This time chessboard contains only a knight, a rook and a bishop. In this game, first Captain America takes his turn, next Iron Man and then Thor. After Thor\u0027s turn, this sequence repeats.\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eCaptain America can only move knight, Iron Man rook, and Thor bishop and each player can move their respective piece to an empty position. \u003c/li\u003e\r\n\u003cli\u003eThe rook can move any number of squares horizontally or vertically, but may not leap over other pieces. \u003c/li\u003e\r\n\u003cli\u003eThe bishop can move any number of squares diagonally, but may not leap over other pieces.\u003c/li\u003e\r\n\u003cli\u003eThe knight\u0027 move forms an \"L\"-shape: two squares vertically and one square horizontally, or two squares horizontally and one square vertically. The knight is the only piece that can leap over other pieces.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003e\u003cbr\u003e The objective of game is to place rook at the initial position of knight, bishop at initial position of rook and knight at initial position of bishop. That is, if the initial position of knight, rook and bishop is \u003cstrong\u003e(x1, y1), (x2, y2)\u003c/strong\u003e and \u003cstrong\u003e(x3, y3)\u003c/strong\u003e, respectively, then the final position of them should be \u003cstrong\u003e(x3, y3), (x1, y1), (x2, y2)\u003c/strong\u003e respectively.\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of the input contains an integer T denoting the number of test cases.\u003cbr\u003e Each test case consists of exactly one line containing 6 space separated integers \u003cstrong\u003ex1 y1 x2 y2 x3 y3\u003c/strong\u003e.\u003cbr\u003e \u003cstrong\u003ex1 y1\u003c/strong\u003e represents the initial position of Knight.\u003cbr\u003e \u003cstrong\u003e x2 y2\u003c/strong\u003e represents the initial position of Rook.\u003cbr\u003e \u003cstrong\u003e x3 y3\u003c/strong\u003e represents the initial position of Bishop.\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cstrong\u003eT\u003c/strong\u003e\u003d\u003cstrong\u003e5\u003c/strong\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cstrong\u003e0\u003c/strong\u003e ≤ \u003cstrong\u003ex1, y1\u003c/strong\u003e ≤ \u003cstrong\u003e7\u003c/strong\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cstrong\u003e0\u003c/strong\u003e ≤ \u003cstrong\u003ex2, y2\u003c/strong\u003e ≤ \u003cstrong\u003e7\u003c/strong\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cstrong\u003e0\u003c/strong\u003e ≤ \u003cstrong\u003ex3, y3\u003c/strong\u003e ≤ \u003cstrong\u003e7\u003c/strong\u003e\u003c/li\u003e\r\n\u003cli\u003eNo pair of initial positions are equal, i.e., (\u003cstrong\u003ex1\u003c/strong\u003e, \u003cstrong\u003ey1\u003c/strong\u003e) !\u003d (\u003cstrong\u003ex2\u003c/strong\u003e,\u003cstrong\u003e y2\u003c/strong\u003e) \u0026amp;\u0026amp; (\u003cstrong\u003ex1\u003c/strong\u003e, \u003cstrong\u003ey1\u003c/strong\u003e) !\u003d (\u003cstrong\u003ex3\u003c/strong\u003e, \u003cstrong\u003ey3\u003c/strong\u003e) \u0026amp;\u0026amp; (\u003cstrong\u003ex2\u003c/strong\u003e, \u003cstrong\u003ey2\u003c/strong\u003e) !\u003d (\u003cstrong\u003ex3\u003c/strong\u003e, \u003cstrong\u003ey3\u003c/strong\u003e)\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each test case, print the minimum number of turns required to achieve this objective.\u003c/p\u003e\r\n\u003cp\u003eIf the desired configuration is not reachable print -1.\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n0 0 5 1 3 3 \r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003ch3\u003eExplanation\u003c/h3\u003e\r\n\u003cp\u003eStarting Points of Knight[0,0], Rook[5,1] and Bishop[3,3] can be changed to Knight[3,3], Rook[0,0], Bishop[5,1] in the following five steps:\u003cbr\u003e Knight - [0,0] to [1,2]\u003cbr\u003e Rook - [5,1] to [5,0]\u003cbr\u003e Bishop - [3,3] to [5,1]\u003cbr\u003e Knight - [1,2] to [3,3]\u003cbr\u003e Rook - [5,0] to [0,0]\u003c/p\u003e\r\n\u003cp\u003eThere is no way to get the required final configuration in less than 5 steps.\u003c/p\u003e\n\u003c/div\u003e"}}]}