#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> pag;
typedef pair<pag,pag> sit;

bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

// »ÝÌÊu©çßéÆ«ÉAæè¤éOÌêðñ
vector<pag> backTable[2][4][16][64];
// »ÝÌÊu©çiÞÆ«ÉAæè¤éÌê
pag goTable[2][4][16][64];
// ·ÅÉÊßµ½ê
bool vis[4][16][64][4][16][64];
// ¡ÌóÔ©çS[Ößêé©
bool isGoal[4][16][64];
bool used[4][101][101];

int H,W;
char field[101][101];
int sx,sy;
int sag;
int gx,gy;
int gag;

const int dy[]={-1,0,1,0};
const int dx[]={0,1,0,-1};

void calcGoAndBackTable(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j]=='#')continue;
            for(int k=0;k<4;k++){
                // ¶©EÉûü]·µÄAOiµ½ ÆÌêðßé
                // ¶
                {
                    int nag=(k-1+4)%4;
                    int ny=i;
                    int nx=j;
                    while(ny>=0&&nx>=0&&ny<H&&nx<W&&field[ny][nx]!='#'){
                        ny+=dy[nag];
                        nx+=dx[nag];
                    }
                    ny-=dy[nag];
                    nx-=dx[nag];
                    goTable[0][k][i][j]=pag(pii(ny,nx),nag);
                }
                // E
                {
                    int nag=(k+1+4)%4;
                    int ny=i;
                    int nx=j;
                    while(ny>=0&&nx>=0&&ny<H&&nx<W&&field[ny][nx]!='#'){
                        ny+=dy[nag];
                        nx+=dx[nag];
                    }
                    ny-=dy[nag];
                    nx-=dx[nag];
                    goTable[1][k][i][j]=pag(pii(ny,nx),nag);
                }
                // »ÝÌü«Ì½ÎÖßÁ½ãûü]··é
                int backAg=(k+2)%4;
                int ny=i;
                int nx=j;
                while(ny>=0&&nx>=0&&ny<H&&nx<W&&field[ny][nx]!='#'){
                    // ±±Å¶ÉûüðÏ¦éêÆEÉûüðÏ¦éêÅêí¯
                    // ¶
                    {
                        int nag=(k-1+4)%4;
                        // ¡ü¢Ä¢éûüÉÇª êÎAXgÉÇÁ
                        if(field[ny+dy[nag]][nx+dx[nag]]=='#')backTable[0][k][i][j].push_back(pag(pii(ny,nx),nag));
                    }
                    // E
                    {
                        int nag=(k+1)%4;
                        // ¡ü¢Ä¢éûüÉÇª êÎAXgÉÇÁ
                        if(field[ny+dy[nag]][nx+dx[nag]]=='#')backTable[1][k][i][j].push_back(pag(pii(ny,nx),nag));
                    }
                    ny+=dy[backAg];
                    nx+=dx[backAg];
                }
            }
        }
    }
}
// X^[gn_©çÔÉvZµÄ¢­
int bfs(int psx,int psy,int pang){
    int res=0;
    // ·ÅÉS[Â\
    if(gy==psy&&gx==psx)return 2;
    for(int cnt=0;cnt<4;cnt++){
        memset(vis,0,sizeof(vis));
        priority_queue<sit> pq;
        // X^[gn_ðpush
        pq.push(sit(pag(pii(psy,psx),pang),pag(pii(sy,sx),(cnt))));
        vis[pang][psy][psx][sag][sy][sx]=true;
        while(pq.size()){
            sit cur=pq.top();pq.pop();
            // »ÝÌóÔðæ¾
            int gpx=cur.first.first.second;
            int gpy=cur.first.first.first;
            int gang=cur.first.second;
            int bpx=cur.second.first.second;
            int bpy=cur.second.first.first;
            int bang=cur.second.second;
            // S[»è
            if(gpy==gy&&gpx==gx){
                res=max(res,1);
                if(isGoal[bang][bpy][bpx]){
                    res=max(res,2);
                }
            }
            // Ì½ßðÇ¤·é©
            for(int i=0;i<2;i++){
                // Ìs«æ
                pag ngpag=goTable[i][gang][gpy][gpx];
                // ßéÓ¾¯vZ
                for(int j=0;j<backTable[i][bang][bpy][bpx].size();j++){
                    pag nbpag=backTable[i][bang][bpy][bpx][j];
                    // ngpagÆnbpagÌîñ©çÉ¢¯éê
                    if(vis[ngpag.second][ngpag.first.first][ngpag.first.second][nbpag.second][nbpag.first.first][nbpag.first.second])
                        continue;
                    vis[ngpag.second][ngpag.first.first][ngpag.first.second][nbpag.second][nbpag.first.first][nbpag.first.second]=true;
                    pq.push(sit(ngpag,nbpag));
                }
            }
        }
    }
    // 3ÂÌÇÌóÔÉÈé©`FbN
    return res;
}

bool bfs2(int psx,int psy,int pang){
    int res=0;
    // ·ÅÉS[Â\
    if(gy==psy&&gx==psx)return true;
    memset(used,0,sizeof(used));
    priority_queue<pag> pq;
    // X^[gn_ðpush
    pq.push(pag(pii(psy,psx),pang));
    used[pang][psy][psx]=true;
    while(pq.size()){
        pag cur=pq.top();pq.pop();
        // »ÝÌóÔðæ¾
        int gpx=cur.first.second;
        int gpy=cur.first.first;
        int gang=cur.second;
        // S[»è
        if(gpy==gy&&gpx==gx){
            return true;
        }
        // Ì½ßðÇ¤·é©
        for(int i=0;i<2;i++){
            // Ìs«æ
            pag ngpag=goTable[i][gang][gpy][gpx];
            if(used[ngpag.second][ngpag.first.first][ngpag.first.second])
                continue;
            used[ngpag.second][ngpag.first.first][ngpag.first.second]=true;
            pq.push(ngpag);
        }
    }
    return false;
}

void input(){
    // startÆgoalÌÊuðè
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            cin>>field[i][j];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j]=='K'){
                field[i][j]='.';
                sy=i;sx=j;
                for(int k=0;k<4;k++){
                    int ny=i+dy[k];
                    int nx=j+dx[k];
                    if(field[ny][nx]=='.')sag=k;
                }
            }
            else if(field[i][j]=='M'){
                field[i][j]='.';
                gy=i;gx=j;
                for(int k=0;k<4;k++){
                    int ny=i+dy[k];
                    int nx=j+dx[k];
                    if(field[ny][nx]=='.')gag=k;
                }
            }
        }
    }
}
void init(){
    memset(isGoal,0,sizeof(isGoal));
    for(int i=0;i<2;i++)for(int j=0;j<4;j++)
        for(int k=0;k<16;k++)for(int l=0;l<64;l++)
            backTable[i][j][k][l].clear();
}
int main(){
    while(cin>>W>>H&&(W|H)){
        // ú»
        init();
        input();
        calcGoAndBackTable();
        // S[ÖßêéêðvZ
        {
            int cy=gy;
            int cx=gx;
            int cag=gag;
            isGoal[cag][cy][cx]=true;
            while(field[cy][cx]!='#'){
                //isGoal[cag][cy][cx]=true;
                cy+=dy[gag];
                cx+=dx[gag];
            }
            cy-=dy[gag];
            cx-=dx[gag];
            isGoal[cag][cy][cx]=true;
        }
        // startn_©ç··ßÄ¨­
        int psy=sy;
        int psx=sx;
        int pang=sag;
        while(psy>=0&&psx>=0&&psy<H&&psx<W&&field[psy][psx]!='#'){
            psy+=dy[sag];
            psx+=dx[sag];
        }
        // ß·
        psy-=dy[sag];
        psx-=dx[sag];
        int res=bfs(psx,psy,pang);
        res=max(res,(int)bfs2(psx,psy,pang));
        if(res==0)
            cout<<"He cannot bring tea to his master."<<endl;
        else if(res==1)
            cout<<"He cannot return to the kitchen."<<endl;
        else if(res==2)
            cout<<"He can accomplish his mission."<<endl;
    }

    return 0;
}

Measured memory_bytes: 17000