{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\n\tAbesh breaks into Dr. Hank Pym\u0027s house and cracks open its safe, but only finds what he believes to be an old motorcycle suit, which he takes home. After trying the suit on, Abesh accidentally shrinks himself to the size of a very small insect. Incidentally, he found himself standing on top of the screen of his smartphone. At that microscale, the screen looks like a grid of RGB pixels. The screen consists of N\u003cspan\u003e\u0026#215;\u003c/span\u003eN pixels. Each pixel is colored in one of three colors (Red, Green, Blue). The initial state is chosen in one of the pixels of color Red. In each step, Abesh is allowed to move one pixel up, down, left or right remaining inside the field.\u003c/p\u003e\n\u003cp\u003e\n\tFind out the minimal amount of steps Abesh should walk to get to a pixel of color Blue independent of the initial state.\u003c/p\u003e\n\u003cp\u003e\n\tNote that the grid contains at least one pixel of color Red and at least one pixel of color Blue.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\n\tThe input consists of several input blocks. The first line of each block contains integer N, the size of the screen. Then there are N lines with colors of the pixels. Red, Green and Blue are denoted as 1, 2 and 3 respectively.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\n\tFor each input block, the output should consist of one line with the integer, the minimal amount of steps Abesh should walk to get a cell of color Blue (3) independent of the initial state.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e4\n1223\n2123\n2213\n3212\n2\n12\n33\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e3\n1\n\u003c/pre\u003e"}}]}