{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"CDN_BASE_URL/e524c640b5fc2b16b91ffae16b1b6816?v\u003d1714612870\" border\u003d\"0\" alt\u003d\"Problem illustration\" align\u003d\"RIGHT\" class\u003d\"problem_raimage\"\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eStriving to develop their intellectual skills, the players of the Psych Up \r\nteam decided to learn how to solving a Rubik\u0027s cube. After a week, they \r\ngave up the attempt in despair. Instead, they decided to solve a simpler \r\n2 × 2 × 2 Rubik\u0027s cube but also failed. Then the team leader \r\nMisha invented a cube that was even simpler. \u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe new cube consists of four layers of size 4 × 4. Each layer is \r\nmade of glass and is absolutely transparent. The upper face of each layer \r\nis divided into 16 equal squares. Four of them are painted red, yellow, \r\nblue, or green. There is a hole at the center of each layer. A solid rod \r\nis put through the holes so that the layers can be turned independently of \r\neach other. \u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe layers look as follows.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_centered_picture\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/ffac44e903eaf3c41ac1a96a418bd84d?v\u003d1714612870\" border\u003d\"0\" alt\u003d\"Problem illustration\"\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe cube is solved if it is in one of the following states (top view).\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_centered_picture\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/20f1e2746f15015a09dd6a864ce884ad?v\u003d1714612870\" border\u003d\"0\" alt\u003d\"Problem illustration\"\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eIt was hard to solve the cube, but the Psych Up team did it. Your task \r\nwill be even harder! You must solve the cube from a given state in a \r\nminimum number of turns. One turn is a turn of one layer by 90 degrees in \r\nany direction. \u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eYou are given four lines, each containing four integers, which describe \r\nthe current state of the cube (top view). The numbers are in the range \r\nfrom\u0026nbsp;1 to\u0026nbsp;4; they correspond to the colors of the cube\u0027s squares. \r\nDifferent numbers denote different colors. \u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput the minimum number of turns needed for solving the cube.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e2 1 2 3\r\n1 1 2 2\r\n4 4 3 3\r\n1 4 3 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}