import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

alias Point = int;
Point makePoint(int y, int x, int dir) {
    return (y << 16) + (x << 4) + dir;
}
int y(Point p) { return cast(int)(p >> 16); }
int x(Point p) { return cast(int)((p << 16) >> 16 >> 4L); }
int dir(Point p) { return cast(int)(p % 4); }

void main() {
    int W, H;
    string[] F;

    bool input() {
        readf("%d %d\n", &W, &H);
        if (W == 0 && H == 0) return false;
        F = new string[H];
        foreach (ref L; F) {
            L = readln.chomp;
        }
        return true;
    }

    const int[] dy = [-1, 0, 1, 0];
    const int[] dx = [0, 1, 0, -1];

    char opposite(char dir_char) {
        return dir_char == 'R' ? 'L' : 'R';
    }
    Point dummy = makePoint(100, 100, 7);

    Point K, M;
    void find_KandM() {
        int ky, kx, kdir;
        int my, mx, mdir;
        foreach (int y; 0 .. H) {
            foreach (int x; 0 .. W) {
                if (F[y][x] == 'K') {
                    kx = x;
                    ky = y;
                }
                if (F[y][x] == 'M') {
                    mx = x;
                    my = y;
                }
            }
        }
        int find_empty_dir(int sy, int sx) {
            int sd = -1;
            foreach (int j; 0 .. 4) {
                int ny = sy + dy[j];
                int nx = sx + dx[j];
                if (F[ny][nx] == '.') {
                    sd = j;
                }
            }
            return sd;
        }
        kdir = find_empty_dir(ky, kx);
        mdir = find_empty_dir(my, mx);
        K = makePoint(ky, kx, kdir);
        M = makePoint(my, mx, mdir);
    }
    
    Point forward(in Point p) {
        int k = p.dir;
        int cy = p.y;
        int cx = p.x;
        while (true) {
            int ny = cy + dy[k];
            int nx = cx + dx[k];
            if (F[ny][nx] == '#') break;
            cy = ny;
            cx = nx;
        }
        return makePoint(cy, cx, k);
    }
    
    Point turn(in Point p, char dir_char) {
        int dir;
        if (dir_char == 'R') {
            dir = +1;
        } else if (dir_char == 'L') {
            dir = -1;
        } else {
            assert(false);
        }
        int k = (p.dir + dir + 4) % 4;
        return makePoint(p.y, p.x, k);
    }

    void solve() {
        find_KandM();

        Point[][Tuple!(Point, char)] reachable_to;
        {
            void find_reachable_from(in Point src, char dir_char) {
                reachable_to[tuple(forward(turn(src, dir_char)), dir_char)] ~= src;
            }
            foreach (y; 0 .. H) {
                foreach (x; 0 .. W) {
                    if (F[y][x] == '#') continue;
                    foreach (dir; 0 .. 4) {
                        foreach (char dir_char; "LR") {
                            auto src = makePoint(y, x, dir);
                            find_reachable_from(src, dir_char);
                        }
                    }
                }
            }
            reachable_to[tuple(dummy, 'L')] = [dummy];
            reachable_to[tuple(dummy, 'R')] = [dummy];
        }

        struct State {
            Point forward;
            Point back;
        }
        auto init = forward(K);
        DList!State Q;
        bool[State] checked;
        foreach (last_dir; 0 .. 4) {
            auto last = makePoint(K.y, K.x, last_dir);
            Q.insert(State(init, last));
            checked[State(init, last)] = true;
        }

        bool can_reach_to_M = false;
        while (! Q.empty) {
            auto s = Q.front; Q.removeFront;
            assert(s in checked);
            foreach (char dir_char; "LR") {
                auto turned = turn(s.forward, dir_char);
                //log("forward: ", s.forward, " -> ", forward(turned));
                auto nforward = forward(turned);
                //log("back: ", s.back, " <- ", find_reachable_to(s.back))
                auto backs = reachable_to.get(tuple(s.back, opposite(dir_char)), [dummy]);
                foreach (nback; backs) {
                    auto nstate = State(nforward, nback);
                    if (nstate in checked) continue;
                    if (nforward.y == M.y && nforward.x == M.x) { can_reach_to_M = true; }
                    Q.insert(nstate);
                    checked[nstate] = true;
                }
            }
        }

        //log(checked);
        auto m = forward(M);
        bool can_back_to_K() {
            foreach (fdir; 0 .. 4) {
                if (State(makePoint(M.y, M.x, fdir), m) in checked) {
                    return true;
                }
            }
            return false;
        }
        writeln( can_reach_to_M ? 
                    can_back_to_K() ? "He can accomplish his mission." : "He cannot return to the kitchen."
                  : "He cannot bring tea to his master." );
    }

    while (input()) solve();
}