#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int toidx(int a, int b, int n)
{
	return a * n + b;
}

int check(int w,int kitchen, int start, int master, int revstart, vector<pair<int, int> > &g, vector<vector<pair<int, bool> > > &rg)
{
	const int n = g.size();
	vector<bool> visited(n * n, false);

	queue<pair<int, int> > q;

	for(int i = 0; i < 4; ++i)
		q.push(make_pair(start, kitchen + i));

	while(!q.empty()) {

		const int a = q.front().first;
		const int b = q.front().second;
		q.pop();
		const int idx = toidx(a, b, n);

		if(visited[idx])
			continue;
		int ax = (a / 4) / w, ay = (a / 4) % w;
		int bx = (b / 4) / w, by = (b / 4) % w;
		//printf("(%d %d %d), (%d %d)\n", ax, ay, bx, by);
		visited[idx] = true;

		for(int i = 0; i < rg[b].size(); ++i) {
			int nb = rg[b][i].first;
			bool right = rg[b][i].second;
			int na = right ? g[a].first : g[a].second;
			q.push(make_pair(na, nb));
		}
	}

	for(int i = 0; i < 4; ++i) {
		if(visited[toidx(master + i, revstart, n)])
			return 2;
	}

	vector<int> visited2(n);
	queue<int> q2;

	q2.push(start);

	while(!q2.empty()) {

		int v = q2.front();
		q2.pop();

		if(visited2[v])
			continue;
		visited2[v] = true;

		q2.push(g[v].first);
		q2.push(g[v].second);
	}

	for(int i = 0; i < 4; ++i) {
		if(visited2[master + i])
			return 1;
	}

	return 0;
}

void make_graphs(vector<string> &f, int &kitchen, int &start, int &master, int &revstart, vector<pair<int, int> > &g, vector<vector<pair<int, bool> > > &rg)
{
	const int h = f.size(), w = f[0].size();
	const int n = h * w * 4;

	g.resize(n);
	rg.resize(n);

	// up: 0, right: 1, down: 2, left: 3
	const int dx[] = {-1, 0, 1, 0};
	const int dy[] = {0, 1, 0, -1};

	for(int x = 0; x < h; ++x) {
		for(int y = 0; y < w; ++y) {

			if(f[x][y] == '#')
				continue;
			if(f[x][y] == 'K') {
				kitchen = 4 * (x * w + y);
				for(int i = 0; i < 4; ++i) {
					if(f[x+dx[i]][y+dy[i]] != '#')
						start = i;
				}
			}
			if(f[x][y] == 'M') {
				master = 4 * (x * w + y);
				for(int i = 0; i < 4; ++i) {
					if(f[x+dx[i]][y+dy[i]] != '#')
						revstart = i;
				}
			}

			for(int node = 0; node < 4; ++node) {

				int ldir = (node + 3) % 4, rdir = (node + 1) % 4;
				int lx = x, ly = y, rx = x, ry = y;
				int gidx = 4 * (x * w + y) + node;

				while(f[lx+dx[ldir]][ly+dy[ldir]] != '#')
					lx += dx[ldir], ly += dy[ldir];
				while(f[rx+dx[rdir]][ry+dy[rdir]] != '#')
					rx += dx[rdir], ry += dy[rdir];

				int lidx = 4 * (lx * w + ly) + ldir;
				int ridx = 4 * (rx * w + ry) + rdir;

				g[gidx] = make_pair(lidx, ridx);
				rg[lidx].push_back(make_pair(gidx, false));
				rg[ridx].push_back(make_pair(gidx, true));
			}
		}
	}

	revstart = g[master + (revstart + 1) % 4].first;
	start = g[kitchen + (start + 1) % 4].first;
}

int main()
{
	string ansstr[3];

	ansstr[0] = "He cannot bring tea to his master.";
	ansstr[1] = "He cannot return to the kitchen.";
	ansstr[2] = "He can accomplish his mission.";

	while(true) {

		int w, h;
		vector<string> f;

		scanf("%d%d", &w, &h);
		if(w == 0)
			break;
		f.resize(h);
		for(int i = 0; i < h; ++i) {
			char buf[128];
			scanf("%s", buf);
			f[i] = buf;
		}

		vector<pair<int, int> > g;
		vector<vector<pair<int, bool> > > rg;
		int kitchen, start, master, revstart;

		make_graphs(f, kitchen, start, master, revstart, g, rg);
		int ans = check(w,kitchen, start, master, revstart, g, rg);

		printf("%s\n", ansstr[ans].c_str());
	}

	return 0;
}

Measured memory_bytes: 4736