//
// Created by ryo07 on 2018/11/15.
//

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct state{
    int x1,y1,d1,x2,y2,d2;
    state(){}
    state(int xx1,int yy1,int dd1,int xx2,int yy2,int dd2) {
        x1 = xx1;
        y1 = yy1;
        d1 = dd1;
        x2 = xx2;
        y2 = yy2;
        d2 = dd2;
    }
};

int w,h;
int fie[16][64];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool used[16][64][4][16][64][4];
bool uk[16][64][4][16][64][4];
vector<P> G[16][64][4];
P to[16][64][4];
bool used2[16][64][4];
int sx,sy,gx,gy;

void dfs(int cx,int cy,int d,int px,int py){
    if(fie[cy+dy[d]][cx+dx[d]]==-1) {
        to[py][px][d] = P(cy, cx);
        G[cy][cx][d].push_back(P(py,px));
        return;
    }
    dfs(cx+dx[d],cy+dy[d],d,px,py);
}

int solve(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(fie[i][j]==-1)continue;
            for(int k=0;k<4;k++){
                G[i][j][k].clear();
                used2[i][j][k]=false;
            }
            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    if(fie[k][l]==-1)continue;
                    for(int a=0;a<4;a++){
                        for(int b=0;b<4;b++){
                            used[i][j][a][k][l][b]=false;
                            uk[i][j][a][k][l][b]=false;
                        }
                    }
                }
            }
        }
    }
    for(int i=0;i<h;i++) {
        for (int j = 0; j < w; j++) {
            if (fie[i][j] == -1)continue;
            for (int k = 0; k < 4; k++) {
                dfs(j, i, k, j, i);
            }
        }
    }
    queue<state> que;
    for(int i=0;i<4;i++) {
        if (fie[sy + dy[i]][sx + dx[i]] == 0) {
            for (int j = 0; j < 4; j++) {
                que.push(state(sx, sy, i, sx, sy, j));
                used[sy][sx][i][sy][sx][j] = true;
            }
        }
    }
    while(que.size()){
        state s=que.front();
        que.pop();
       // printf("%d %d %d %d %d %d\n",s.x1,s.y1,s.d1,s.x2,s.y2,s.d2);
        for(int i=0;i<G[s.y2][s.x2][s.d2].size();i++){
            int nx2=G[s.y2][s.x2][s.d2][i].second;
            int ny2=G[s.y2][s.x2][s.d2][i].first;
            int nx1=to[s.y1][s.x1][s.d1].second;
            int ny1=to[s.y1][s.x1][s.d1].first;
            uk[ny1][nx1][s.d1][ny2][nx2][s.d2]=true;
            if(!used[ny1][nx1][(s.d1+1)%4][ny2][nx2][(s.d2+1)%4]){
                used[ny1][nx1][(s.d1+1)%4][ny2][nx2][(s.d2+1)%4]=true;
                que.push(state(nx1,ny1,(s.d1+1)%4,nx2,ny2,(s.d2+1)%4));
            }
            if(!used[ny1][nx1][(s.d1+3)%4][ny2][nx2][(s.d2+3)%4]){
                used[ny1][nx1][(s.d1+3)%4][ny2][nx2][(s.d2+3)%4]=true;
                que.push(state(nx1,ny1,(s.d1+3)%4,nx2,ny2,(s.d2+3)%4));
            }
        }
    }
    int gd=-1;
    for(int i=0;i<4;i++){
        if(fie[gy+dy[i]][gx+dx[i]]==0){
            gd=i;
        }
    }
    for(int i=0;i<4;i++){
        if(uk[gy][gx][i][gy][gx][gd])return 1;
    }

    for(int i=0;i<4;i++) {
        if (fie[sy + dy[i]][sx + dx[i]] == 0) {
            que.push(state(sx, sy, i, 0,0,0));
            used2[sy][sx][i] = true;
        }
    }
    while(que.size()){
        state s=que.front();
        que.pop();
        // printf("%d %d %d %d %d %d\n",s.x1,s.y1,s.d1,s.x2,s.y2,s.d2);
        int nx1=to[s.y1][s.x1][s.d1].second;
        int ny1=to[s.y1][s.x1][s.d1].first;
        used2[ny1][nx1][s.d1]=true;
        if(!used2[ny1][nx1][(s.d1+1)%4]){
            used2[ny1][nx1][(s.d1+1)%4]=true;
            que.push(state(nx1,ny1,(s.d1+1)%4,0,0,0));
        }
        if(!used2[ny1][nx1][(s.d1+3)%4]){
            used2[ny1][nx1][(s.d1+3)%4]=true;
            que.push(state(nx1,ny1,(s.d1+3)%4,0,0,0));
        }
    }
    for(int i=0;i<4;i++){
        if(used2[gy][gx][i])return 0;
    }
    return -1;
}

int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w==0 && h==0)break;
        memset(fie,-1,sizeof(fie));
        for(int i=0;i<h;i++){
            string str;
            cin >> str;
            for(int j=0;j<w;j++){
                if(str[j]!='#')fie[i][j]=0;
                if(str[j]=='K'){
                    sx=j;
                    sy=i;
                }
                if(str[j]=='M'){
                    gx=j;
                    gy=i;
                }
            }
        }
        int res=solve();
        if(res==1){
            printf("He can accomplish his mission.");
        }
        if(res==0){
            printf("He cannot return to the kitchen.");
        }
        if(res==-1){
            printf("He cannot bring tea to his master.");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 31692