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

#define rep(i, n) for (int i = 0; i < (n); i ++)

static const int dy[] = { -1, 0, 1, 0 }, dx[] = { 0, -1, 0, 1 };
int h, w, sy, sx, gy, gx, sd, gd;
vector<string> M;
bool used2[16][64][4][16][64][4];
bool used[16][64];

struct point {
        int y, x;
        point (int yy = -1, int xx = -1) : y(yy), x(xx) {}
};

bool cango() {
        memset(used, 0, sizeof(used));
        queue<point> q;
        q.push((point){sy, sx});
        used[sy][sx] = true;
        while (!q.empty()) {
                point p = q.front(); q.pop();
                if (p.y == gy && p.x == gx) { 
                        return true;
                }
                for (int d = 0; d < 4; d ++) {
                        int xx = p.x, yy = p.y;
                        while (M[yy + dy[d]][xx + dx[d]] != '#') yy += dy[d], xx += dx[d];
                        if (!used[yy][xx]) {
                                used[yy][xx] = true;
                                q.push({yy, xx});
                        }
                }
        }
        return false;
}

bool canreturn() {
        memset(used2, 0, sizeof(used2));
        queue<pair<pair<point, int>, pair<point, int>>> q;
        for (int d = 0; d < 4; d ++) {
                point s(sy, sx);
                used2[sy][sx][sd][sy][sx][d] = true;
                q.push(make_pair(make_pair(s, sd), make_pair(s, d)));
        }
        while (!q.empty()) {
		int y1, x1, d1, y2, x2, d2;
		y1 = q.front().first.first.y, x1 = q.front().first.first.x;
		y2 = q.front().second.first.y, x2 = q.front().second.first.x;
		d1 = q.front().first.second, d2 = q.front().second.second;
		q.pop();
		while (M[y1 + dy[d1]][x1 + dx[d1]] != '#') y1 += dy[d1], x1 += dx[d1];
                while (1) {
                        for (int i = 1; i < 4; i += 2) {
                                int nd1 = (d1 + i) % 4, nd2 = (d2 + i) % 4;
                                if (M[y2 + dy[nd2]][x2 + dx[nd2]] == '#') {
                                        if (!used2[y1][x1][nd1][y2][x2][nd2]) {
                                                used2[y1][x1][nd1][y2][x2][nd2] = true;
                                                q.push(make_pair(make_pair((point){y1, x1}, nd1), make_pair((point){y2, x2}, nd2)));
                                        }
                                }
                        }
                        if (M[y2 - dy[d2]][x2 - dx[d2]] == '#') break;
                        y2 -= dy[d2], x2 -= dx[d2];
                }
                if (M[y1][x1] == 'M' && M[y2][x2] == 'M' && d2 == gd) return true;
        }
        return false;
}

int main() {
        while (cin >> w >> h && h) {
                M.resize(h);
                for (int i = 0; i < h; i ++) cin >> M[i];
                for (int i = 0; i < h; i ++) {
                        for (int j = 0; j < w; j ++) {
                                if (M[i][j] == 'K') {
                                        sy = i, sx = j;
                                        for (int d = 0; d < 4; d ++) {
                                                int ny = i + dy[d], nx = j + dx[d];
                                                if (M[ny][nx] != '#') sd = d;
                                        }
                                }
                                if (M[i][j] == 'M') {
                                        gy = i, gx = j;
                                        for (int d = 0; d < 4; d ++) {
                                                int ny = i + dy[d], nx = j + dx[d];
                                                if (M[ny][nx] != '#') gd = d;
                                        }
                                }
                        }
                }             
                if (cango() && canreturn()) cout << "He can accomplish his mission." << endl;
                else if (cango()) cout << "He cannot return to the kitchen." << endl;
                else cout << "He cannot bring tea to his master." << endl;
        }
        return 0;
}

Measured memory_bytes: 19596