#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_M, wall_dir_at_K;

void constructTransition() {
	memset(trans, -1, sizeof(trans));
	for_(i,0,1024) for_(j,0,4) for_(k,0,2) trans_rev[i][j][k] = vector< int >();
	wall_dir_at_M = 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;
		if (home_map[y][x] == 'M') pos_id[y][x] = 1023;
		if (home_map[y][x] == '.') pos_id[y][x] = id++;
	}
	
	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] == 'M') wall_dir_at_M.push_back(d);
					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;
				}
			}
		}
	}
	
	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);
		}
	}
}

struct State {
	int id, dir;
	int rev_id, rev_dir;
};

bool vis[1024][4][1024][4];

bool canReachMaster() {
	memset(vis, 0, sizeof(vis));
	
	queue< State > que;
	que.push(State{start_id, start_dir});
	vis[start_id][start_dir][0][0] = true;
	
	while (!que.empty()) {
		State s = que.front(); que.pop();
		for_(c,0,2) {
			int nxt_id = trans[s.id][s.dir][c], nxt_dir = changeDirection(s.dir, c);
			if (!vis[nxt_id][nxt_dir][0][0]) {
				vis[nxt_id][nxt_dir][0][0] = true;
				que.push(State{nxt_id, nxt_dir});
			}
		}
	}
	
	bool flag = false;
	for (int f : wall_dir_at_M) flag |= vis[1023][f][0][0];
	return flag;
}

bool canDo() {
	memset(vis, 0, sizeof(vis));
	
	queue< State > que;
	for (int d : wall_dir_at_K) {
		que.push(State{start_id, start_dir, 0, d});
		vis[start_id][start_dir][0][d] = true;
	}
	
	while (!que.empty()) {
		State s = que.front(); que.pop();
		for_(c,0,2) {
			int nxt_id = trans[s.id][s.dir][c], nxt_dir = changeDirection(s.dir, c), nxt_rev_dir = changeDirection(s.rev_dir, c);
			for (int nxt_rev_id : trans_rev[s.rev_id][s.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(State{nxt_id, nxt_dir, nxt_rev_id, nxt_rev_dir});
				}
			}
		}
	}
	
	bool ans = false;
	for (int f : wall_dir_at_M) ans |= vis[1023][f][goal_id][goal_dir];
	return ans;
}

void solve() {
	constructTransition();	
	if (canDo()) {
		puts("He can accomplish his mission.");
	} else {
		if (canReachMaster()) 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: 19864