#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdio.h>
using namespace std;
char maze[10][10];
int t;
bool vis[10][10];
bool flag;
int n,m;
char ch;
int sx,sy,ex,ey;
int dir[4][2] = {1,0,-1,0,0,1,0,-1};
void dfs(int x,int y,int cnt)
{
int nx,ny;
if(x == ex&&y == ey&&cnt==t)
{
flag = 1;
return ;
}
if(cnt>=t)
return;
if(maze[x][y]!='X')
{
for(int i = 0 ; i <4; i++)
{
nx = x+dir[i][0];
ny = y+dir[i][1];
if(maze[nx][ny]!='X'&&nx<=n&&nx>=1&&ny>=1&&ny<=m&&!vis[nx][ny])
{
vis[nx][ny] = 1;
dfs(nx,ny,cnt+1);
vis[nx][ny] = 0;
if(flag)
return ;
}
}
}
}
int main()
{
int cnt;
while(cin>>n>>m>>t)
{
if(n==0&&m==0&&t==0)
break;
for(int i = 1; i<=n; i++)
{
for(int j = 1; j<=m; j++)
{
cin>>maze[i][j];
if(maze[i][j]=='S')
{
sx = i;
sy = j;
}
if(maze[i][j]=='D')
{
ex = i;
ey = j;
}
}
}
if(abs(sx-ex)+abs(sy-ey)>t||(sx+sy+ex+ey+t)%2==1)//剪枝
{
cout<<"NO"<<endl;
continue;
}
memset(vis,0,sizeof(vis));
cnt = 0;
flag = 0;
vis[sx][sy] = 1;
dfs(sx,sy,cnt);
if(flag)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}