#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

char dp[31][31][31][31][151];
vector<string> s;
int n,m;
bool ok(int i,int j){
    if(i<0||i>=n)return false;
    if(j<0||j>=m)return false;
    if(s[i][j]=='#')return false;
    return true;
}
int dfs(int qi,int qj,int ai,int aj,int tur){
    if(tur==150){
        return 3;
    }
    if(dp[qi][qj][ai][aj][tur]!=0){
        return dp[qi][qj][ai][aj][tur];
    }
    if(qi==ai&&qj==aj){
        dp[qi][qj][ai][aj][tur]=2;
        return 2;
    }
    if(tur%2==0){
        if(s[qi][qj]=='E'){
            dp[qi][qj][ai][aj][tur] = 1;
            return 1;
        }
        vector<int> a;
        for(int i=-1;i<=1;i++){
            if(ok(qi+i,qj)){
                a.push_back(dfs(qi+i,qj,ai,aj,tur+1));
            }
        }
        for(int j=-1;j<=1;j++){
            if(ok(qi,qj+j)){
                a.push_back(dfs(qi,qj+j,ai,aj,tur+1));
            }
        }
        bool ss = 0;
        for(auto x:a){
            if(x==1){
                dp[qi][qj][ai][aj][tur] = 1;
                return 1;
            }else if(x==3){
                ss = 1;
            }
        }
        if(ss){
            dp[qi][qj][ai][aj][tur] = 3;
            return 3;
        }else{
            dp[qi][qj][ai][aj][tur] = 2;
            return 2;
        }
    }else{
        vector<int> a;
        for(int i=-1;i<=1;i++){
            if(ok(ai+i,aj)){
                a.push_back(dfs(qi,qj,ai+i,aj,tur+1));
            }
        }
        for(int j=-1;j<=1;j++){
            if(ok(ai,aj+j)){
                a.push_back(dfs(qi,qj,ai,aj+j,tur+1));
            }
        }
        bool ss = 0;
        for(auto x:a){
            if(x==2){
                dp[qi][qj][ai][aj][tur] = 2;
                return 2;
            }else if(x==3){
                ss = 1;
            }
        }
        if(ss){
            dp[qi][qj][ai][aj][tur] = 3;
            return 3;
        }else{
            dp[qi][qj][ai][aj][tur] = 1;
            return 1;
        }
    }

}


int main(){
    while(1){
        cin >> m >> n;
        if(n==0)break;
        rep(i,n){
            rep(j,m){
                rep(k,n){
                    rep(l,m){
                        rep(t,151){
                            dp[i][j][k][l][t] = 0;
                        }
                    }
                }
            }
        }
        s.resize(n);
        s.shrink_to_fit();
        rep(i,n){
            cin >> s[i];
        }
        int qi,qj,ai,aj;
        rep(i,n){
            rep(j,m){
                if(s[i][j]=='A'){
                    ai = i;
                    aj = j;
                }else if(s[i][j]=='Q'){
                    qi = i;
                    qj = j;
                } 
            }
        }
        int k = dfs(qi,qj,ai,aj,0);
        if(k==1){
            cout << "Queen can escape.\n";
        }else if(k==2){
            cout << "Army can catch Queen.\n";
        }else{
            cout << "Queen can not escape and Army can not catch Queen.\n";
        }
    }
    return 0;
}


Measured memory_bytes: 105036