#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;

// L,U,R,D --- right:+1, left:-1
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};
const int dc[2] = {-1,1};

int changeDirection(int f, int c) { return (f + dc[c] + 4) % 4; }

int W, H, pos_id[16][64];
string home_map[16];

int nextPos(int cx, int cy, int d) {
	while (home_map[cy + dy[d]][cx + dx[d]] != '#') {
		cx += dx[d];
		cy += dy[d];
	}
	return pos_id[cy][cx];
}

/***************** solver ********************/

int trans[1024][4][2];
vector< int > trans_rev[1024][4][2];
int start_id, start_dir, goal_id, goal_dir;
vector< int > wall_dir_at_K;

void constructTransition() {
	for_(i,0,1024) for_(j,0,4) for_(k,0,2) trans_rev[i][j][k] = vector< int >();
	wall_dir_at_K = vector< int >();
	
	int id = 1;
	for_(y,0,H) for_(x,0,W) {
		if (home_map[y][x] == 'K') pos_id[y][x] = 0;
		else if (home_map[y][x] == 'M') pos_id[y][x] = 1023;
		else if (home_map[y][x] == '.') pos_id[y][x] = id++;
	}
	
	int cnt = 0;
	for_(y,0,H) {
		for_(x,0,W) {
			if (home_map[y][x] == 'M' || home_map[y][x] == 'K') {
				for_(d,0,4) {
					int nx = x + dx[d], ny = y + dy[d];
					if (home_map[ny][nx] == '#') {
						if (home_map[y][x] == 'K') wall_dir_at_K.push_back(d);
						continue;
					}
				
					if (home_map[y][x] == 'M') {
						goal_id = nextPos(nx, ny, d);
						goal_dir = d;
					} else {
						start_id = nextPos(nx, ny, d);
						start_dir = d;
					}
				}
				++cnt;
			}
			if (cnt == 2) break;
		}
		if (cnt == 2) break;
	}
	
	for_(y,0,H) for_(x,0,W) {
		if (home_map[y][x] == '#') continue;
		id = pos_id[y][x];
		for_(f,0,4) for_(c,0,2) {
			int nxt_dir = changeDirection(f, c);
			int nxt_id = nextPos(x, y, nxt_dir);
			trans[id][f][c] = nxt_id;
			trans_rev[nxt_id][nxt_dir][c].push_back(id);
		}
	}
}

int SHIFT = 16, MASK = (1 << 16) - 1;
bool visM[1024][4];
bool vis[1024][4][1024][4];

inline int makeState(int id, int dir) { return (id | (dir << SHIFT)); }
inline int getID(int state) { return (state & MASK); }
inline int getDIR(int state) { return (state >> SHIFT); }

bool canReachMaster() {
	memset(visM, 0, sizeof(visM));
	
	queue< int > que;
	que.push(makeState(start_id, start_dir));
	visM[start_id][start_dir] = true;
	
	while (!que.empty()) {
		int s = que.front(); que.pop();
		int id = getID(s), dir = getDIR(s);
		if (id == 1023) return true;
		for_(c,0,2) {
			int nxt_id = trans[id][dir][c], nxt_dir = changeDirection(dir, c);
			if (!visM[nxt_id][nxt_dir]) {
				visM[nxt_id][nxt_dir] = true;
				que.push(makeState(nxt_id, nxt_dir));
			}
		}
	}
	
	return false;
}

bool canDo() {
	memset(vis, 0, sizeof(vis));
	
	queue< pii > que;
	for (int d : wall_dir_at_K) {
		que.push(pii(makeState(start_id, start_dir), makeState(0, d)));
		vis[start_id][start_dir][0][d] = true;
	}
	
	while (!que.empty()) {
		pii p = que.front(); que.pop();
		int id = getID(p.first), dir = getDIR(p.first);
		int rev_id = getID(p.second), rev_dir = getDIR(p.second);
		if (id == 1023 && rev_id == goal_id && rev_dir == goal_dir) return true;
		for_(c,0,2) {
			int nxt_id = trans[id][dir][c], nxt_dir = changeDirection(dir, c), nxt_rev_dir = changeDirection(rev_dir, c);
			for (int nxt_rev_id : trans_rev[rev_id][rev_dir][1 - c]) {
				if (!vis[nxt_id][nxt_dir][nxt_rev_id][nxt_rev_dir]) {
					vis[nxt_id][nxt_dir][nxt_rev_id][nxt_rev_dir] = true;
					que.push(pii(makeState(nxt_id, nxt_dir), makeState(nxt_rev_id, nxt_rev_dir)));
				}
			}
		}
	}
	
	return false;
}

void solve() {
	constructTransition();	
	if (canReachMaster()) {
		if (canDo()) puts("He can accomplish his mission.");
		else puts("He cannot return to the kitchen.");
	} else {
		puts("He cannot bring tea to his master.");
	}
}

int main() {
	while (1) {
		cin >> W >> H;
		if (H == 0) break;
		for_(y,0,H) cin >> home_map[y];
		solve();
	}
}

Measured memory_bytes: 19792