{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ch1\u003e\r\n\t\u0026nbsp;\u003c/h1\u003e\r\n\u003cbr clear\u003d\"ALL\" /\u003e\r\n\u003ccenter\u003e\r\n\t\u003ctable bgcolor\u003d\"#0060F0\"\u003e\r\n\t\t\u003ctbody\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd\u003e\r\n\t\t\t\t\t\u003ch1\u003e\r\n\t\t\t\t\t\t\u003cb\u003e\u003cfont color\u003d\"#C0FFFF\" size\u003d\"5\"\u003e\u0026nbsp;\u003ca name\u003d\"SECTION0001000000000000000000\"\u003eThe path in the colored field\u003c/a\u003e\u003c/font\u003e\u0026nbsp;\u003c/b\u003e\u003c/h1\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\u003c/tbody\u003e\r\n\t\u003c/table\u003e\r\n\u003c/center\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001002000000000000000\"\u003eThe Problem\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tThe square field consists of M\u0026times;M cells. Each cell is colored in one of three colors (1,2,3). The initial state is chosen in one of the cells of color 1. In each step one allowed to move one cell up, down, left or right remaining inside the field.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tYou are to define the minimal amount of steps one should make to get a cell of color 3 independent on the initial state.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tNote that the field contains at least one cell of color 1 and at least one cell of color 3.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001003000000000000000\"\u003eThe Input\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tThe input consists of several input blocks. The first line of each block contains integer M \u0026lt;\u003d 100, the size of the field. Then there are M lines with colors of the cells.\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001004000000000000000\"\u003eThe Output\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tFor each input block the output should consist of one line with the integer, the minimal amount of steps one should make to get a cell of color 3 independent on the initial state.\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001005000000000000000\"\u003eSample Input\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e4\r\n1223\r\n2123\r\n2213\r\n3212\r\n2\r\n12\r\n33\r\n\u003c/pre\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001006000000000000000\"\u003eSample Output\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e3\r\n1\r\n\u003c/pre\u003e"}}]}