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:
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int H,W;
char c[32][32];
int a[2][32][32][32][32];
int rest[2][32][32][32][32];
int dy[] = {0,1,0,-1,0};
int dx[] = {1,0,-1,0,0};

typedef pair<int,pair<pair<int,int>,pair<int,int>>> state;

bool ok(int y,int x){return 0<=y && y<H && 0<=x && x<W
	&& (c[y][x] == '.' || c[y][x] == 'E');}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>W>>H && W){
		rep(i,H)cin>>c[i];
		int sqy,sqx,say,sax;
		rep(i,H)rep(j,W){
			if(c[i][j] == 'Q'){
				sqy=i, sqx=j, c[i][j] = '.';
			}
			if(c[i][j] == 'A'){
				say=i, sax=j, c[i][j] = '.';
			}
		}
		memset(a,0,sizeof(a));
		memset(rest,0,sizeof(rest));
		queue<state> Q;
		rep(qi,H)rep(qj,W)rep(ai,H)rep(aj,W)if(ok(qi,qj) && ok(ai,aj)){
			if(qi == ai && qj == aj){
				a[0][qi][qj][ai][aj] = -1;
				Q.push(mp(0,mp(mp(qi,qj),mp(ai,aj))));
			}
			else if(c[qi][qj] == 'E'){
				a[0][qi][qj][ai][aj] = 1;
				Q.push(mp(0,mp(mp(qi,qj),mp(ai,aj))));
			}
			else{
				rep(dir,5){
					int Qi = qi+dy[dir], Qj = qj+dx[dir];
					rest[0][qi][qj][ai][aj] += ok(Qi,Qj);
				}
			}
			rep(dir,5){
				int Ai = ai+dy[dir], Aj = aj+dx[dir];
				rest[1][qi][qj][ai][aj] += ok(Ai,Aj);
			}
		}
		while(sz(Q)){
			state q = Q.front(); Q.pop();
			int p = q.fir;
			int qy = q.sec.fir.fir, qx = q.sec.fir.sec;
			int ay = q.sec.sec.fir, ax = q.sec.sec.sec;
			int res = a[p][qy][qx][ay][ax];
			//cout<<p<<" "<<qy<<" "<<qx<<" "<<ay<<" "<<ax<<" : "<<res<<endl;
			if(p == 0){
				if(qy == sqy && qx == sqx && ay == say && ax == sax){
					if(res == 1)cout<<"Queen can escape."<<endl;
					else cout<<"Army can catch Queen."<<endl;
					goto end;
				}
				rep(dir,5){
					int Ay = ay+dy[dir], Ax = ax+dx[dir];
					if(!ok(Ay,Ax) || a[1][qy][qx][Ay][Ax] != 0)continue;
					if(res == 1){
						rest[1][qy][qx][Ay][Ax]--;
					}
					if(res == -1 || res == 1 && rest[1][qy][qx][Ay][Ax] == 0){
						a[1][qy][qx][Ay][Ax] = -res;
						Q.push(mp(1,mp(mp(qy,qx),mp(Ay,Ax))));
					}
				}
			}
			else{
				rep(dir,5){
					int Qy = qy+dy[dir], Qx = qx+dx[dir];
					if(!ok(Qy,Qx) || a[0][Qy][Qx][ay][ax] != 0)continue;
					if(res == 1){
						rest[0][Qy][Qx][ay][ax]--;
					}
					if(res == -1 || res == 1 && rest[0][Qy][Qx][ay][ax] == 0){
						a[0][Qy][Qx][ay][ax] = -res;
						Q.push(mp(0,mp(mp(Qy,Qx),mp(ay,ax))));
					}
				}
			}
		}
		cout<<"Queen can not escape and Army can not catch Queen."<<endl;
		end:;
	}
}