#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

const int WIN = -1;
const int LOSE = -2;

class Data
{
public:
    int y1, x1, y2, x2, turn;
    Data(int y01, int x01, int y02, int x02, int turn0)
    {
        y1 = y01;
        x1 = x01;
        y2 = y02;
        x2 = x02;
        turn = turn0;
    }
    int toInt()
    {
        return (((y1 * 32 + x1) * 32 + y2) * 32 + x2) * 2 + turn;
    }
};

int main()
{
    for(;;){
        int h, w;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h+2, string(w+2, '#'));
        int qy, qx, ay, ax;
        for(int y=1; y<=h; ++y){
            for(int x=1; x<=w; ++x){
                cin >> s[y][x];
                if(s[y][x] == 'Q'){
                    qy = y;
                    qx = x;
                }else if(s[y][x] == 'A'){
                    ay = y;
                    ax = x;
                }
            }
        }
        
        vector<vector<int> > adjacent(h+2, vector<int>(w+2));
        for(int y=1; y<=h; ++y){
            for(int x=1; x<=w; ++x){
                for(int i=0; i<5; ++i){
                    if(s[y+dy[i]][x+dx[i]] != '#')
                        ++ adjacent[y][x];
                }
            }
        }

        vector<int> memo(32*32*32*32*2, 0);
        queue<Data> q;
        for(int y1=1; y1<=h; ++y1){
            for(int x1=1; x1<=w; ++x1){
                if(s[y1][x1] == '#')
                    continue;
                Data d(y1, x1, y1, x1, 0);
                memo[d.toInt()] = LOSE;
                q.push(d);

                if(s[y1][x1] != 'E')
                    continue;
                for(int y2=1; y2<=h; ++y2){
                    for(int x2=1; x2<=w; ++x2){
                        if(s[y2][x2] == '#' || (y1 == y2 && x1 == x2))
                            continue;
                        Data d(y1, x1, y2, x2, 0);
                        memo[d.toInt()] = WIN;
                        q.push(d);
                    }
                }
            }
        }

        while(!q.empty()){
            Data d = q.front();
            int k = d.toInt();
            q.pop();

            for(int i=0; i<5; ++i){
                Data d2 = d;
                swap(d2.y1, d2.y2);
                swap(d2.x1, d2.x2);
                d2.y1 += dy[i];
                d2.x1 += dx[i];
                d2.turn ^= 1;
                if(s[d2.y1][d2.x1] == '#')
                    continue;

                int k2 = d2.toInt();

                if(memo[k2] == WIN || memo[k2] == LOSE)
                    continue;

                if(memo[k] == WIN){
                    ++ memo[k2];
                    if(memo[k2] == adjacent[d2.y1][d2.x1]){
                        memo[k2] = LOSE;
                        q.push(d2);
                    }
                }else{
                    memo[k2] = WIN;
                    q.push(d2);
                }
            }
        }

        Data d(qy, qx, ay, ax, 0);
        int k = d.toInt();
        if(memo[k] == WIN)
            cout << "Queen can escape." << endl;
        else if(memo[k] == LOSE)
            cout << "Army can catch Queen." << endl;
        else
            cout << "Queen can not escape and Army can not catch Queen." << endl;
    }
}

Measured memory_bytes: 9456