#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define U 0
#define R 1
#define D 2
#define L 3
string p = "URDL";
#define MR 0
#define ML 1
const int dr[] = { -1,0,1,0 };
const int dc[] = { 0,1,0,-1 };

int rot(int d, int i,int x) {
	if (x == MR) {
		if (i == 0)return (d + 1) % 4;
		else return (d + 3) % 4;
	}
	else {
		if (i == 0)return (d + 3) % 4;
		else return (d + 1) % 4;
	}
}

int H, W, sr, sc, sd,gr, gc,gd;
string X[16];
int a[1 << 15];
int b[1 << 15];
inline int rr(int x) { return (x>>8)&15; }
inline int cc(int x) { return (x>>2)&63; }
inline int dd(int x) { return x&3; }
inline int pack(int r, int c, int d) {
	return (r << 8) + (c << 2) + d;
}
inline void sweep(int& r, int& c, int d) {
	int nr, nc;
	while (nr = r + dr[d], nc = c + dc[d], X[nr][nc] != '#')
		r = nr, c = nc;
}
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<VVV> VVVV;
typedef vector<VVVV> VVVVV;

VVVV g;
VVVVV r_g;

inline int f(int r1,int c1,int d1,int r2,int c2,int d2) {
	int res = r1;
	res <<= 6; res += c1;
	res <<= 2; res += d1;
	res <<= 4; res += r2;
	res <<= 6; res += c2;
	res <<= 2; res += d2;
	return res;
}
void ff(int res, int &r1, int &c1, int &d1, int &r2, int &c2, int &d2) {
	d2 = res & 3; res >>= 2;
	c2 = res & 63; res >>= 6;
	r2 = res & 15; res >>= 4;
	d1 = res & 3; res >>= 2;
	c1 = res & 63; res >>= 6;
	r1 = res & 15; 
}
bool dp[16][64][4][16][64][4];
int main() {
	while (cin >> W >> H, W + H) {
		REP(i, H)cin >> X[i];
		REP(i, H)REP(j, W) {
			if (X[i][j] == 'K')sr = i, sc = j;
			if (X[i][j] == 'M')gr = i, gc = j;
		}
		REP(i, H)REP(j, W)REP(x, 4)REP(ii, H)REP(jj, W)REP(xx, 4)
			dp[i][j][x][ii][jj][xx] = false;
		g.assign(H, VVV(W, VV(4, V(2, -1))));
		r_g.assign(H, VVVV(W, VVV(4, VV(2, V()))));
		int id = 0;
		a[id++] = pack(0, 0, 0);
		r_g[0][0][0][0].push_back(0);
		r_g[0][0][0][1].push_back(0);
		REP(i, H)REP(j, W)if(X[i][j]!='#')REP(k, 4) {
			int r, c, d;
			r = i, c = j, d = rot(k, 0, MR);
			sweep(r,c,d);
			a[id] = pack(i,j,k);
			b[id] = pack(r, c, d);
			g[i][j][k][MR] = id;
			r_g[r][c][d][ML].push_back(id);
			id++;
			r = i, c = j, d = rot(k, 0, ML);
			sweep(r, c, d);
			a[id] = pack(i, j, k);
			b[id] = pack(r, c, d);
			g[i][j][k][ML] = id;
			r_g[r][c][d][MR].push_back(id);
			id++;
			r_g[i][j][k][0].push_back(0);
			r_g[i][j][k][1].push_back(0);
		}
		int latte, malta;
		stack<int> st;
		{
			int r = sr, c = sc;
			REP(i, 4)if(X[r+dr[i]][c+dc[i]]=='.') {
				sd = i;
				sweep(r, c, sd);
				break;
			}
			REP(i, 4) if(i!=sd){
				dp[r][c][sd][sr][sc][i] = true;
				st.push(f(r, c, sd, sr, sc, i));
			}
		}
		{
			int r = gr, c = gc;
			REP(i, 4)if (X[r + dr[i]][c + dc[i]] == '.') {
				gd = i;
				sweep(r, c, gd);
				break;
			}
			latte = r; malta = c;
		}

		while (st.size()) {
			int r1, c1, d1, r2, c2, d2;
			ff(st.top(), r1, c1, d1, r2, c2, d2); st.pop();

			REP(i, 2) {
				int nxt1 = b[g[r1][c1][d1][i]];
				int nr1 = rr(nxt1);
				int nc1 = cc(nxt1);
				int nd1 = dd(nxt1);
				for (auto &it : r_g[r2][c2][d2][i]) {
					int nxt2 = a[it];
					int nr2 = rr(nxt2);
					int nc2 = cc(nxt2);
					int nd2 = dd(nxt2);
					if (dp[nr1][nc1][nd1][nr2][nc2][nd2] == false) {
						dp[nr1][nc1][nd1][nr2][nc2][nd2] = true;
						st.push(f(nr1,nc1,nd1,nr2,nc2,nd2));
						/*
						cout << r1 << c1 << p[d1] ;
						cout << r2 << c2  << p[d2] << endl;
						cout << "->" << endl;
						cout << nr1 << nc1  << p[nd1] ;
						cout << nr2 << nc2  << p[nd2] << endl;
						cout  << endl;
						*/
					}
				}
			}
		}
		int res = 0;
		REP(i, 4)if (dp[gr][gc][i][latte][malta][gd])res = 1;
		if (res) {
			cout << "He can accomplish his mission." << endl;
			continue;
		}
		REP(i, 4)REP(j, 4)REP(r,H)REP(c,W)if (dp[gr][gc][i][r][c][j])res = 1;
		if (res)cout << "He cannot return to the kitchen." << endl;
		else cout << "He cannot bring tea to his master." << endl;
			
	}
	return 0;
}

Measured memory_bytes: 20524