#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

struct seica {
    int ky, kx, kd, my, mx, md;
    seica(int _ky, int _kx, int _kd, int _my, int _mx, int _md){
        ky = _ky;
        kx = _kx;
        kd = _kd;
        my = _my;
        mx = _mx;
        md = _md;
    }
};


int dp[16][64][4][16][64][4];
P straight[16][64][4];
int visited[16][64][4];
int reach[16][64][4];
int h, w, ky, kx, kd, my, mx, md, cou;
char mp[16][64];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<pair<P, ll>> pre[16][64][4][4];
pair<P, ll> nxt[16][64][4][4];
queue<seica> q;

int getStartDir(int y, int x){
    REP(i, 4)if(mp[y + dy[i]][x + dx[i]] != '#')return i;
    return -1;
}

P goStraight(int y, int x, int d){
    P ret = MP(y, x);
    while(mp[ret.FI + dy[d]][ret.SE + dx[d]] != '#'){
        ret.FI += dy[d];
        ret.SE += dx[d];
    }
    return ret;
}

void calNxt(){
	REP(i, h){
		REP(j, w){
			if(mp[i][j] == '#')continue;
			REP(k, 4) {
				straight[i][j][k] = goStraight(i, j, k);
			}
		}
	}

	REP(i, h){
		REP(j, w){
			if(mp[i][j] == '#')continue;
			REP(k, 4){
				nxt[i][j][k][1] = MP(straight[i][j][(k+1)%4], (k+1)%4);
				nxt[i][j][k][3] = MP(straight[i][j][(k+3)%4], (k+3)%4);
			}
		}
	}
}

void calPre(){
	REP(i, 16)REP(j,64)REP(k, 4)REP(l, 4)pre[i][j][k][l].clear();

	queue<pair<P, ll>> que;
	auto nm = straight[my][mx][md];
	visited[nm.FI][nm.SE][md] = cou;
	que.push(MP(MP(nm.FI, nm.SE), md));

	while(!que.empty()){
		auto y = que.front().FI.FI;
		auto x = que.front().FI.SE;
		auto d = que.front().SE;
		que.pop();

		nm = straight[y][x][(d+1)%4];
		pre[nm.FI][nm.SE][(d+1)%4][1].EB(MP(y, x), d);
		if(visited[nm.FI][nm.SE][(d+1)%4] != cou){
			visited[nm.FI][nm.SE][(d+1)%4] = cou;
			que.push(MP(MP(nm.FI, nm.SE), (d+1)%4));
		}
		nm = straight[y][x][(d+3)%4];
		pre[nm.FI][nm.SE][(d+3)%4][3].EB(MP(y, x), d);
		if(visited[nm.FI][nm.SE][(d+3)%4] != cou){
			visited[nm.FI][nm.SE][(d+3)%4] = cou;
			que.push(MP(MP(nm.FI, nm.SE), (d+3)%4));
		}
	}
}

void move(seica now, int turn){
	auto nk = nxt[now.ky][now.kx][now.kd][turn];
	auto pm = pre[now.my][now.mx][now.md][4 - turn];

	REP(i, pm.size()){
		if(dp[nk.FI.FI][nk.FI.SE][nk.SE][pm[i].FI.FI][pm[i].FI.SE][pm[i].SE] == cou)continue;
		dp[nk.FI.FI][nk.FI.SE][nk.SE][pm[i].FI.FI][pm[i].FI.SE][pm[i].SE] = cou;
		q.push(seica(nk.FI.FI, nk.FI.SE, nk.SE, pm[i].FI.FI, pm[i].FI.SE, pm[i].SE));
	}
}

bool canHeBringTea(){
	queue<pair<P, ll>> que;
	auto nk = straight[ky][kx][kd];
	reach[nk.FI][nk.SE][kd] = cou;
	que.push(MP(MP(nk.FI, nk.SE), kd));

	while(!que.empty()){
		auto y = que.front().FI.FI;
		auto x = que.front().FI.SE;
		auto d = que.front().SE;
		que.pop();

		if(y == my && x == mx)return true;

		nk = straight[y][x][(d+1)%4];
		if(reach[nk.FI][nk.SE][(d+1)%4] != cou){
			reach[nk.FI][nk.SE][(d+1)%4] = cou;
			que.push(MP(MP(nk.FI, nk.SE), (d+1)%4));
		}
		nk = straight[y][x][(d+3)%4];
		if(reach[nk.FI][nk.SE][(d+3)%4] != cou){
			reach[nk.FI][nk.SE][(d+3)%4] = cou;
			que.push(MP(MP(nk.FI, nk.SE), (d+3)%4));
		}
	}

	return false;
}

void solve() {
	auto nm = straight[my][mx][md];
	auto nk = straight[ky][kx][kd];
	bool ok = false;
	//cout << "doal " << ky << " " << kx << " " << kd << " " << my << " " << mx << " " << md << endl;
	//cout << "start " << nm.FI << " " << nm.SE << endl;

	REP(i, 4){
		if(i == kd)continue;
		q.push(seica(nk.FI, nk.SE, kd, ky, kx, i));
		dp[nk.FI][nk.SE][kd][ky][kx][i] = cou;
	}

	while(!q.empty()){
		auto now = q.front();q.pop();

		//cout << now.ky << " " << now.kx << " " << now.kd << " " << now.my << " " << now.mx << " " << now.md << endl;

		if(now.ky == my && now.kx == mx && now.my == nm.FI && now.mx == nm.SE && now.md == md){
			ok = true;
			while(!q.empty())q.pop();
			break;
		}

		move(now, 1);
		move(now, 3);
	}

	if(ok){
		cout << "He can accomplish his mission." << endl;
	}
	else if(canHeBringTea()){
		cout << "He cannot return to the kitchen." << endl;
	}
	else {
		cout << "He cannot bring tea to his master." << endl;
	}
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

	while(cin >> w >> h, w | h){
		cou++;

		REP(i, h)REP(j, w){
			cin >> mp[i][j];
			if(mp[i][j] == 'K'){ky = i;kx = j;}
			if(mp[i][j] == 'M'){my = i;mx = j;}
		}

		kd = getStartDir(ky, kx);
		md = getStartDir(my, mx);

		calNxt();
		calPre();
		solve();
	}

	return 0;
}



Measured memory_bytes: 45516