#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;

char ba[16][64];
pii iki[16][64][4];
vector<pii> kaeri[16][64][4];

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

int w, h;
bool visited[16][64][4];

void make_graph(pii now, int d, int nest) {
  int yy = now.first;
  int xx = now.second;
  
  if (visited[yy][xx][d]) return;
  visited[yy][xx][d] = 1;
  
  while (1) {
    yy += dy[d];
    xx += dx[d];
    if (ba[yy][xx] == '#') break;
  }
  yy-=dy[d];
  xx-=dx[d];

  //printf("(%d,%d)%d -> (%d,%d)\n", now.second,now.first,d,xx,yy);
  iki[now.first][now.second][d] = pii(yy,xx);
  kaeri[yy][xx][d].push_back(pii(now.first,now.second));

  // REP(i, 4) {
  //   make_graph(pii(yy,xx), i, nest+1);
  // }

  make_graph(pii(yy,xx), (d+1)%4, nest+1);
  make_graph(pii(yy,xx), (d+3)%4, nest+1);
}

int dd[2];

struct P {
  int sy,sx,d1,ty,tx,d2;
  P(int sy, int sx, int d1, int ty, int tx, int d2) :
    sy(sy),sx(sx),d1(d1),ty(ty),tx(tx),d2(d2) {}
};

bool visited2[16][64][4][16][64][4];

int solve(pii kitchen, pii master) {
  queue<P> Q;
  pii hoge = iki[kitchen.first][kitchen.second][dd[0]];
  REP(i, 4)
    Q.push(P(hoge.first, hoge.second, dd[0], kitchen.first, kitchen.second, i));
  memset(visited2,0,sizeof(visited));
  bool f = 0;
  while(!Q.empty()) {
    P p = Q.front(); Q.pop();
    if (visited2[p.sy][p.sx][p.d1][p.ty][p.tx][p.d2]) continue;
    visited2[p.sy][p.sx][p.d1][p.ty][p.tx][p.d2] = 1;
    
    if (pii(p.sy, p.sx) == master && pii(p.ty, p.tx) == iki[master.first][master.second][dd[1]] && p.d2 == dd[1]) {
      return 2;
    }
    if (pii(p.sy, p.sx) == master) f = 1;

    //printf("(%d,%d)%d, (%d,%d)%d\n", p.sx,p.sy,p.d1,p.tx,p.ty,p.d2);
    
    REP(i, 2) {
      pii pp = iki[p.sy][p.sx][(p.d1+i*2+1)%4];
      int ii = (p.d2+i*2+1)%4;
      
      FOR(it, kaeri[p.ty][p.tx][p.d2]) {
//cout << it->second << "," << it->first << endl;
        Q.push(P(pp.first, pp.second, (p.d1+i*2+1)%4, it->first, it->second, ii));
      }
    }
  }
  return f;
}

int main() {
  while(cin>>w>>h,w||h) {
    pii p[2];
    REP(i,h) {
      REP(j,w) {
        cin >> ba[i][j];
        if (ba[i][j] == 'K') p[0] = pii(i,j);
        else if (ba[i][j] == 'M') p[1] = pii(i,j);
      }
    }
    memset(visited,0,sizeof(visited));
    REP(i, h) REP(j,w) REP(k,4) kaeri[i][j][k].clear();
    // REP(i,h) {
    //   REP(j,w) {
    //     if (ba[i][j] == '#') continue;
    //     int cnt = 1;
    //     // REP(d,4) {
    //     //   int yy = i+dy[d];
    //     //   int xx = j+dx[d];
    //     //   if (ba[yy][xx] != '#') cnt++;
    //     // }
    //     if (cnt == 1) {
    //       //cout << j << "," << i << " ";
    //       REP(d, 4) {
    //         make_graph(pii(i,j), d, 0);
    //       }
    //     }
    //   }
    // }
    bool f = 0;
    REP(i,2) {
      REP(d,4) {
        int yy=p[i].first+dy[d];
        int xx=p[i].second+dx[d];
        if (ba[yy][xx] == '.') dd[i] = d;
        make_graph(p[i], d, 0);
        if (i == 0) {
          REP(j,4) {
            if (visited[p[1].first][p[1].second][j]) f = 1;
          }
        }
      }
    }
    if (!f) {
      cout << "He cannot bring tea to his master." << endl;
    } else {
      memset(visited2,0,sizeof(visited2));
      int res = solve(p[0], p[1]);
      if (res == 2) {
        cout << "He can accomplish his mission." << endl;
      } else {
        cout << "He cannot return to the kitchen." << endl;
      }
    }
  }
}