Problem: A small country called Maltius was governed by a queen. The queen was known as an oppressive ruler. People in the country suffered from heavy taxes and forced labor. So some young people decided to form a revolutionary army and fight against the queen. Now, they besieged the palace and have just rushed into the entrance.

Your task is to write a program to determine whether the queen can escape or will be caught by the army.

Here is detailed description.

* The palace can be considered as grid squares.
* The queen and the army move alternately. The queen moves first.
* At each of their turns, they either move to an adjacent cell or stay at the same cell.
* Each of them must follow the optimal strategy.
* If the queen and the army are at the same cell, the queen will be caught by the army immediately.
* If the queen is at any of exit cells alone after the army’s turn, the queen can escape from the army.
* There may be cases in which the queen cannot escape but won’t be caught by the army forever, under their optimal strategies.

Hint

On the first sample input, the queen can move to exit cells, but either way the queen will be caught at the next army’s turn. So the optimal strategy for the queen is staying at the same cell. Then the army can move to exit cells as well, but again either way the army will miss the queen from the other exit. So the optimal strategy for the army is also staying at the same cell. Thus the queen cannot escape but won’t be caught.



Input

The input consists of multiple datasets. Each dataset describes a map of the palace. The first line of the input contains two integers W (1 ≤ W ≤ 30) and H (1 ≤ H ≤ 30), which indicate the width and height of the palace. The following H lines, each of which contains W characters, denote the map of the palace. "Q" indicates the queen, "A" the army,"E" an exit,"#" a wall and "." a floor.

The map contains exactly one "Q", exactly one "A" and at least one "E". You can assume both the queen and the army can reach all the exits.

The last dataset is followed by a line containing two zeros. This line is not a part of any dataset and should not be processed.

Output

For each dataset, output "Queen can escape.", "Army can catch Queen." or "Queen can not escape and Army can not catch Queen." in a line.

Examples

Input

2 2
QE
EA
3 1
QAE
3 1
AQE
5 5
..E..
.###.
A###Q
.###.
..E..
5 1
A.E.Q
5 5
A....
####.
..E..
.####
....Q
0 0


Output

Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Queen can escape.
Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Army can catch Queen.


Input

2 2
QE
EA
3 1
QAE
3 1
AQE
5 5
..E..
.###.
A###Q
.###.
..E..
5 1
A.E.Q
5 5
A....
.
..E..
.####
....Q
0 0


Output

Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Queen can escape.
Queen can not escape and Army can not catch Queen.
Army can catch Queen.
Army can catch Queen.

Solution (in CPP):

Solution:
#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;
}