//bfs或者最短路
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
int move[4][2]={1,0,-1,0,0,1,0,-1};
int r, c, cost, num_p, flag, ans;
char maze[5005][5005];
bool visited[5005][5005];
int step[5005][5005];
struct node{int x, y;}a[5005], st, end;
void init(){
int i, j;
num_p=0;flag=0;
memset(visited, 0 ,sizeof(visited));
for(i=0; i<r; i++)
scanf("%s", maze[i]);
for(i=0; i<r; i++)
for(j=0; j<c; j++){
if(maze[i][j]=='P'){
a[num_p].x=i;
a[num_p++].y=j;
}
else if(maze[i][j]=='Y'){
st.x=i;
st.y=j;
}
else if(maze[i][j]=='C'){
end.x=i;
end.y=j;
}
}
}
bool check(node p){
if(p.x<0||p.y<0||p.x>=r||p.y>=c||visited[p.x][p.y])
return false;
return true;
}
void bfs(){
int i, j, k, flag_p=0;
step[st.x][st.y]=0;
visited[st.x][st.y]=true;
node head, next;
queue<node> q;
q.push(st);
while(!q.empty()){
head=q.front();
q.pop();
for(i=0; i<4; i++){
next.x=head.x+move[i][0];
next.y=head.y+move[i][1];
if(!check(next))continue;
if(maze[next.x][next.y]=='C'){
flag=1;ans=step[head.x][head.y];return;
}
else if(maze[next.x][next.y]=='#'){
visited[next.x][next.y]=1;
continue;
}
else if(maze[next.x][next.y]=='*'){
visited[next.x][next.y]=1;
step[next.x][next.y]=step[head.x][head.y]+1;
q.push(next);
}
else if(!flag_p){
flag_p=1;
for(j=0; j<num_p; j++){
visited[a[j].x][a[j].y]=1;
for(k=0; k<4; k++){
next.x=a[j].x+move[k][0];
next.y=a[j].y+move[k][1];
if(!check(next))continue;
if(maze[next.x][next.y]=='C'){
flag=1;ans=step[head.x][head.y];return;
}
else if(maze[next.x][next.y]=='#'){
visited[next.x][next.y]=1;
continue;
}
else if(maze[next.x][next.y]=='*'){
visited[next.x][next.y]=1;
step[next.x][next.y]=step[head.x][head.y]+1;
q.push(next);
}
}
}
}
}
}
}
int main(){
//freopen("1.txt", "r", stdin);
while(scanf("%d%d%d", &r, &c, &cost)!=EOF){
init();
bfs();
if(flag){
printf("%d\n", ans*cost);
}
else printf("Damn teoy!\n");
}
return 0;
}