#include <iostream>#include <cstdio>#include <queue>#include <string.h>using namespace std;char map[10][10];bool flag[10][10];int way[4][2]={ 0,1,0,-1,1,0,-1,0 };struct point{ int x,y;};point sta,end;int n,m;bool dfs( int s,int x,int y ){ int i,xx,yy; if( map[x][y]=='D' && s==0 ) return true; if( map[x][y]=='D' && s!=0 ) return false; if( s<=0 ) return false; for( i=0;i<4;i++ ) { xx=x+way[i][0] , yy=y+way[i][1]; if( xx>=0 && xx<n && yy>=0 && yy<m && map[xx][yy]!='X' && !flag[xx][yy] ) { flag[xx][yy]=1; if( dfs(s-1,xx,yy) ) return true; flag[xx][yy]=0; } } return false;}int main(){ int t,i,j; queue <point>q; while( cin>>n>>m>>t && ( n||m||t ) ) { memset( flag,0,sizeof(flag) ); for( i=0;i<n;i++ ) { for( j=0;j<m;j++ ) { cin>>map[i][j]; if( map[i][j]=='S' ) sta.x=i , sta.y=j ; } } flag[sta.x][sta.y]=1; if( dfs( t,sta.x,sta.y ) ) printf( "YESn" ); else printf( "NOn" ); } return 0;}