/*
BFS is very watery. BFS won't be used at the beginning. It has been wrong many times with DFS. It should be due to a problem with the algorithm. I think this topic uses DFS.
Yes.
*/
# Include <iostream> // 2389356 2010-04-27 11:23:31 accepted 1240 0 Ms 308 K 1495 B C ++ regret
# Include <queue>
# Include <cstring>
# Include <cmath>
Using namespace STD;
Char map [12] [12] [12];
Bool hash [12] [12] [12];
Bool flag;
Int dir [6] [3] = {0, 0, 1}, {0, 1, 0}, {0, 0,-1}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0 }};
Int A, B, C;
Int D, E, F;
Int T;
Int N;
Struct Node
{
Int X;
Int y;
Int Z;
Int num;
};
Queue <node> q;
Int BFS (INT Si, int SJ, int SK)
{
Node N, P;
N. x = SI;
N. Y = SJ;
N. z = Sk;
N. num = 0;
Int I;
Q. Push (N );
Hash [Si] [SJ] [SK] = false;
While (! Q. Empty ())
{
N = Q. Front ();
If (N. x = F & N. Y = E & N. z = D & N. num = T)
{
Flag = true;
Cout <n <"" <n. Num <Endl;
Break;
}
If (N. Num> T)
{
Break;
}
Q. Pop ();
For (I = 0; I <6; I ++)
{
P. x = n. x + dir [I] [0];
P. Y = n. Y + dir [I] [1];
P. z = n. Z + dir [I] [2];
If (P. x> = 0 & P. x <n & P. y> = 0 & P. Y <n & P. z> = 0 & P. z <n & hash [p. x] [p. y] [p. z] & map [p. x] [p. y] [p. z] = 'O ')
{
P. num = n. Num + 1;
Q. Push (P );
Hash [p. x] [P. Y] [P. Z] = false;
}
}
}
Return 1;
}
Int main ()
{
Char STR [12];
Int I, J, K;
While (CIN> STR> N)
{
For (I = 0; I <n; I ++)
For (j = 0; j <n; j ++)
For (k = 0; k <n; k ++)
Cin> map [I] [J] [k];
Cin> A> B> C;
Cin> D> E> F;
Cin> STR;
T = (INT) (FABS (1.0 * a-d) + FABS (1.0 * B-e) + FABS (1.0 * C-f )); // This ce passed during the provincial Competition
Flag = false;
Memset (hash, true, sizeof (hash); // At the beginning, an error is marked here. It should be specified later. Otherwise, an error occurs when writing data.
BFS (C, B, );
If (! Flag)
Cout <"No route" <Endl;
}
}