/* Server Guard Issues */# include <iostream> # include <string> // # include <fstream> # include <queue> using namespace std; # define MAX 12 typedef struct _ point {int x; int y; int dep;} point; int map [MAX] [MAX]; int p [] [2] = {-1,-2}, {-2,-1}, {-2}, {-1}, {-1, 2 }, {2, 1}, {2,-1}, {1,-2 }}; point start, end; // fstream fin; int bfs (); int main () {// fin. open ("2585.txt", ios: in); int times = 0; int B; while (cin> B) {if (B =-1) break; for (int I = 0; I <12; I ++) for (int j = 0; j <12; j ++) map [I] [j] = 1; // perimeter fence for (int I = 2; I <10; I ++) for (int j = 2; j <10; j ++) map [I] [j] = 0; string a; for (int I = 0; I <B; I ++) {cin>; map [a [0]-'A' + 2] [(a [1]-'1') + 2] = 1;} cin> a; start. x = a [0]-'A' + 2; start. y = a [1]-'1' + 2; start. dep = 0; cin> a; end. x = a [0]-'A' + 2; end. y = a [1]-'1' + 2; int dep = bfs (); if (dep) cout <"Board" <++ times <": "<dep <" moves "<endl; else cout <" Board "<++ times <": n Ot reachable "<endl;} system (" pause "); return 0;} int bfs () {int dep = 0; queue <point> Q; Q. push (start); while (! Q. empty () {// The current dep for (int I = 0; I <8; I ++) {point cur = Q. front (); if (map [cur. x + p [I] [0] [cur. y + p [I] [1] = 0) {if (end. x = cur. x + p [I] [0] & cur. y + p [I] [1] = end. y) {end. dep = cur. dep + 1; return end. dep;} map [cur. x + p [I] [0] [cur. y + p [I] [1] = 1; point temp; temp. x = cur. x + p [I] [0]; temp. y = cur. y + p [I] [1]; temp. dep = cur. dep + 1; Q. push (temp) ;}} Q. pop () ;}return 0 ;}