#include <cstdio>edfrgthyufghyhhgfdssd
#include <queue>gfdsasfvgzhygvb
using namespace std;vdasDeGVBCXX
int Maze[100][100];GYHUYJHGBFCDSXSDCF
typedef struct _pointGTFDCSX
{
int x,y;
}point;wqfedgehyjiewdqs
int main()
{
point k,next;erfds
for(int N;scanf("%d",&N)!=EOF;)
{wedsv
queue<point> qu;
for(int y=0;y<N&&getchar();y++)
for(int x=0;x<N&efdscxvferdsvcx&scanf("%c",&Maze[y][x]);Maze[y][x]=(Maze[y][x]=='.'?-1:-2),x++);
k.x=1,k.y=1;
qu.push(k);rwefdewsd
Maze[1][1]=1;
while(!qu.erfdvcx mpty())
{
k=qu.front();qu.pop()ref;
next.x=k.x-1,nerfdsczerfdasext.y=k.y;
if(Maze[next.y][next.x]==-1) {qu.push(next);Maze[wedaswesdnext.y][next.x]=Maze[k.y][k.x]+1;}
next.x=k.x+1,next.y=k.y;
if(Maze[next.y][next.x]==-1) {qu.push(next);Mazwqedasce[next.y][next.x]=Maze[k.y][k.x]+1;}
next.x=k.x,next.ywesa=k.y-1;
if(Maze[next.y][next.wqesdx]=wsa=-1) {qu.push(next);Maze[next.y][next.x]=Maze[k.y][k.x]+1;}
next.x=k.x,next.y=k.y+wqesadx1;
if(Maze[next.y][next.x]==-1) ewqdsa{qu.push(next);Maze[next.y][next.x]=Maze[k.y][k.x]+1;}
}wqesad
if(Maze[N-2][N-2]>0) priqwsaxzntf("%d\n",Maze[N-2][N-2]);
else printf("ewsdNo solutioqwsan!\n");
}wedsc
returnwwesadqsa 0;sdcx
}ewdswefeg
//(0ms, 3wed20KB)