#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;

int W, H;
bool wall[16][64];
P to[16][64][4];

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

bool reached[16][64][16][64][4][4];

struct Node {
	int x1, y1, x2, y2, d1, d2;
};
struct SingleNode {
	int x, y, d;
};

bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
int main() {
	while ( cin >> W >> H, W || H ) {
		fill(wall[0], wall[16], false);
		int sx, sy, gx, gy;
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x) {
				switch (str[x]) {
					case '.': break;
					case '#': wall[y][x] = true; break;
					case 'K': sx = x, sy = y; break;
					case 'M': gx = x, gy = y; break;
				}
			}
		}
		for (int t = 0; t < W+H; ++t) {
			for (int y = 0; y < H; ++y) {
				for (int x = 0; x < W; ++x) {
					for (int d = 0; d < 4; ++d) {
						if (t == 0) {
							int nx = x + dx[d];
							int ny = y + dy[d];
							if ( inRange(nx, ny) && !wall[ny][nx] ) {
								to[y][x][d] = P(nx, ny);
							}
							else {
								to[y][x][d] = P(x, y);
							}
						}
						else {
							P np = to[y][x][d];
							int nx = np.first, ny = np.second;
							to[y][x][d] = to[ny][nx][d];
						}
					}
				}
			}
		}

		fill(&reached[0][0][0][0][0][0], &reached[0][0][0][0][0][0] + 16*64*16*64*4*4, false);

		SingleNode G[16][64][4][2];
		vector<SingleNode> rG[16][64][4][2];
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				for (int d = 0; d < 4; ++d) {
					for (int dd = 0; dd < 2; ++dd) {
						int xx = x+dx[d], yy = y+dy[d];
						if ( wall[y][x] || (inRange(xx, yy) && !wall[yy][xx]) ) {
							G[y][x][d][dd] = (SingleNode){-1, -1, -1};
						}
						else {
							int nd = (d + rot[dd] + 4) % 4;
							P np = to[y][x][nd];
							G[y][x][d][dd] = (SingleNode){np.first, np.second, nd};
							rG[np.second][np.first][nd][dd].push_back( (SingleNode){x, y, d} );
						}
					}
				}
			}
		}

		queue<Node> Q;
		int sx2, sy2, gx2, gy2, sd;
		for (int i = 0; i < 4; ++i) {
			int x = gx + dx[i];
			int y = gy + dy[i];
			if ( inRange(x, y) && !wall[y][x] ) {
				P p = to[gy][gx][i];
				gx2 = p.first;
				gy2 = p.second;
			}
		}
		for (int i = 0; i < 4; ++i) {
			int x = sx + dx[i];
			int y = sy + dy[i];
			if ( inRange(x, y) && !wall[y][x] ) {
				P p = to[sy][sx][i];
				sx2 = p.first;
				sy2 = p.second;
				sd = i;
				for (int j = 0; j < 4; ++j) {
//					cout << sx2 << " " << sy2 << " " << sx << " " << sy << endl;
					reached[sy2][sx2][sy][sx][i][j] = true;
					Q.push( (Node){sx2, sy2, sx, sy, i, j} );
				}
				break;
			}
		}
/*
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				int snx = sx + dx[i];
				int sny = sy + dy[i];
				int gnx = gx + dx[i];
				int gny = gy + dy[i];
				if ( inRange(snx, sny) && !wall[sny][snx] && (!inRange(gnx, gny) || wall[gny][gnx]) ) {
					reached[sy][sx][sy][sx][i][j] = true;
					Q.push( (Node){sx, sy, sx, sy, i, j} );
				}
			}
		}
*/
		int ans = 0;
/*
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				cout << (wall[y][x] ? "#" : ".");
			}
			cout << endl;
		}
*/
		while ( !Q.empty() ) {
			Node node = Q.front(); Q.pop();
			int x1 = node.x1;
			int y1 = node.y1;
			int x2 = node.x2;
			int y2 = node.y2;
			int d1 = node.d1;
			int d2 = node.d2;
			if (x1 == gx && y1 == gy) {
				if (x2 == gx2 && y2 == gy2) {
					ans = max(ans, 2);
				}
				else {
					ans = max(ans, 1);
				}
			}
//			cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << d1 << " " << d2 << endl;
			for (int dd = 0; dd < 2; ++dd) {
				SingleNode& next1 = G[y1][x1][d1][dd];
//				cout << y2 << " " << x2 << " " << d2 << " " << dd << endl;
				assert( !wall[y1][x1] );
				assert( !wall[y2][x2] );
//				assert( rG[y2][x2][d2][!dd].size() > 0 );
				for (int i = 0; i < rG[y2][x2][d2][!dd].size(); ++i) {
					SingleNode& next2 = rG[y2][x2][d2][!dd][i];
					if ( !reached[next1.y][next1.x][next2.y][next2.x][next1.d][next2.d] ) {
						reached[next1.y][next1.x][next2.y][next2.x][next1.d][next2.d] = true;
						Q.push( (Node){next1.x, next1.y, next2.x, next2.y, next1.d, next2.d} );
					}
				}
			}
		}
		if (ans == 0) {
			bool used[16][64][4] = {0};
			queue<SingleNode> Q2; Q2.push({sx2, sy2, sd}); used[sy2][sx2][sd] = true;
			while ( !Q2.empty() ) {
				SingleNode node = Q2.front(); Q2.pop();
				int x = node.x, y = node.y, d = node.d;
				if (x == gx && y == gy) {
					ans = 1;
					break;
				}
				for (int dd = 0; dd < 2; ++dd) {
					SingleNode& next = G[y][x][d][dd];
					if ( !used[next.y][next.x][next.d] ) {
						used[next.y][next.x][next.d] = true;
						Q2.push(next);
					}
				}
			}
		}

		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;
		}
	}
}

Measured memory_bytes: 18104