#include<iostream> #include<queue> #include<cstring> using namespace std; struct node{ int x,y,z; int step; }; int move1[6][3]={-1,0,0,1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1}; int cheak[12][12][12]; char s[]={"START "}; char f[]={"END"}; char space[12][12][12]; int n,x,y,z,g; int bfs(int a,int b,int c) { queue<node>q; node now; now.x=c; now.y=a; now.z=b; now.step=0; q.push(now); while(!q.empty()) { now=q.front(); q.pop(); if(now.x==z+1&&now.y==x+1&&now.z==y+1) { g=1; return now.step; } for(int i=0;i<6;i++) { int dx=now.x+move1[i][0]; int dy=now.y+move1[i][1]; int dz=now.z+move1[i][2]; if(dx>=1&&dx<=n&&dy>=1&&dy<=n&&dz>=1&&dz<=n&&cheak[dx][dy][dz]==0&&space[dx][dy][dz]=='O') { node next; next.x=dx; next.y=dy; next.z=dz; cheak[dx][dy][dz]=1; next.step=now.step+1; q.push(next); } } } } int main() { int a1,b1,c1,w; while(cin>>s>>n) { g=0; memset(space,0,sizeof(space)); memset(cheak,0,sizeof(cheak)); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { cin>>(space[i][j]+1); } cin>>a1>>b1>>c1; cin>>x>>y>>z; cin>>f; w=bfs(a1+1,b1+1,c1+1); if(g==1) { cout<<n<<" "<<w<<endl; } else { cout<<"NO ROUTE"<<endl; } } }