#include<iostream>
using namespace std;
int data_read(int n,int **maze)//讀取測資
{
char tem;
for(int i=0; i<n; i++)
{
maze[i]=new int[n];
for(int j=0; j<n; j++)
{
cin>>tem;
if(tem=='#')
{
maze[i][j]=1;
}
else if(tem=='.')
{
maze[i][j]=0;
}
}
}
}
typedef struct
{
int x;
int y;
} point;
point point_read(int x,int y)
{
point p= {x,y};
return p;
}
void visit(int **maze,point start,point end,int current_path,int *final_path)
{
if(maze[start.y][start.x]!=1)
{
maze[start.y][start.x]=1;
current_path++;
if(start.x==end.x&&start.y==end.y)
{
if(current_path<*final_path)
{
*final_path=current_path;
}
}
else
{
visit(maze,point_read(start.x+1,start.y),end,current_path,final_path);
visit(maze,point_read(start.x,start.y+1),end,current_path,final_path);
visit(maze,point_read(start.x-1,start.y),end,current_path,final_path);
visit(maze,point_read(start.x,start.y-1),end,current_path,final_path);
}
maze[start.y][start.x]=0;
current_path--;
}
}
int main()
{
for(int n; cin>>n;)
{
int **maze=new int*[n],current_path=0,final_path=n*n;
data_read(n,maze);
visit(maze,point_read(1,1),point_read(n-2,n-2),current_path,&final_path);
if(final_path!=n*n)
{
cout<<final_path<<endl;
}
else
{
cout<<"No solution!"<<endl;
}
}
return 0;
}