#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define double long double
using namespace std;
const int INF = 1e9;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
const int H = 17;
const int W = 65;

int h,w;
vector<string> mp;

int used[W][H][4][W][H][4];

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

char getChar(int x,int y,int dir){return mp[y + dy[dir]][x + dx[dir]];}
void getNx(int &x,int &y,int dir){while(getChar(x, y, dir) != '#') x += dx[dir],y += dy[dir];}
int getDir(int x,int y){for(int i=0;i<4;i++) if(getChar(x, y, i) != '#') return i;}

int bfs(int sx,int sy,int gx,int gy,int flag = 0){
  memset(used,0,sizeof(used));
  int sdir = getDir(sx, sy);
  int gdir = getDir(gx, gy);
  
  struct dat{
    int x, y, dir1, a, b, dir2;
    dat();
    dat(int x,int y,int dir1,int a,int b,int dir2):
      x(x), y(y), dir1(dir1), a(a), b(b), dir2(dir2){}
  };
  
  queue<dat> Q;
  
  auto Push=[&](int nx,int ny,int ndir1,int a,int b,int ndir2){
    
    if(flag) {
      if(used[nx][ny][ndir1][0][0][0]++ == 0) Q.push(dat(nx,ny,ndir1, 0,0,0));
      return;
    }

    if(getChar(a, b, ndir2) != '#') return;
    int na = a, nb = b;
    while(mp[nb][na] != '#'){
      int flag = getChar(na,nb,(ndir2+1)%4) == '#' || getChar(na, nb, (ndir2+3)%4) == '#';
      if(flag && used[nx][ny][ndir1][na][nb][ndir2]++ == 0) Q.push(dat(nx,ny,ndir1, na,nb,ndir2));
      na += dx[(ndir2+2)%4];
      nb += dy[(ndir2+2)%4];
    }
  };
  
  for(int i=0;i<4;i++){
    int nx = sx, ny = sy; getNx(nx, ny, sdir);
    if(getChar(sx, sy, i) == '#') Push(nx,ny,sdir,sx,sy,i);
  }

  int res = 0;
  while(!Q.empty()){
    auto t = Q.front(); Q.pop();
    int x = t.x, y = t.y, dir1 = t.dir1;
    int a = t.a, b = t.b, dir2 = t.dir2;
    if(x == gx && y == gy) res = 1;
    if(x == gx && y == gy && a == gx && b == gy && dir2 == gdir) return 2;
    
    
    {//右に曲がる
      int nx = x, ny = y, ndir1 = (dir1 + 1) % 4; getNx(nx, ny, ndir1);
      int ndir2 = (dir2 + 1) % 4;
      Push(nx, ny, ndir1, a, b, ndir2);
    }

    {//左に曲がる。
      int nx = x, ny = y, ndir1 = (dir1 + 3) % 4; getNx(nx, ny, ndir1);
      int ndir2 = (dir2 + 3) % 4;
      Push(nx, ny, ndir1, a, b, ndir2);
    }
  }
  return res;
}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    cin>>w>>h;
    if(h == 0 && w == 0) return 0;
    
    mp.clear();
    mp.resize(h);
    cin>>mp;
  
    int sx,sy,gx,gy;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
        if(mp[i][j] == 'K') sx = j, sy = i;
        if(mp[i][j] == 'M') gx = j, gy = i;
      }

    int ans = bfs(gx, gy, sx, sy);
    if(ans != 2) ans = bfs(sx, sy, gx, gy, 1);
    if(ans == 0) cout<<"He cannot bring tea to his master."<<endl;
    else if(ans == 1) cout<<"He cannot return to the kitchen."<<endl;
    else cout<<"He can accomplish his mission."<<endl;
  }
  return 0;
}



Measured memory_bytes: 79644