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 <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef pair<int,int> P;
int h,w,qx,qy,ax,ay;
string s[30];
short int dp[30][30][30][30][2];	//1->Qwin,-1->Awin.0->?
//qx,qy,ax,ay,turn=0->queen
int dx[5]={0,1,0,-1,0},dy[5]={0,0,1,0,-1};
vector<P> exits;
bool is(int x,int y){
	if(x<0||h<=x||y<0||w<=y||s[x][y]=='#') return false;
	return true;
}
void init(){
	exits.clear();
	rep(i,h) rep(j,w) rep(k,h) rep(l,w) rep(turn,2) dp[i][j][k][l][turn]=0;
}
void showdp(int i,int j,int k,int l,int turn,int value){
	printf("dp[%d][%d][%d][%d][%d]=%d\n",i,j,k,l,turn,value);
}
int main(){
	while(true){
		cin>>w>>h;
		if(w==0) break;
		init();
		rep(i,h) cin>>s[i];
		rep(i,h) rep(j,w){
			if(s[i][j]=='Q') qx=i,qy=j;
			if(s[i][j]=='A') ax=i,ay=j;
			if(s[i][j]=='E') exits.pb(P(i,j));
		}
		bool update=true;
		for(P ex : exits){
			int x=ex.fs,y=ex.sc;
			rep(i,h) rep(j,w) dp[x][y][i][j][0]=1;
		}
		rep(i,h) rep(j,w) rep(turn,2) dp[i][j][i][j][turn]=-1;
		while(update){
			update=false;
			//turn=0
			rep(i,h) rep(j,w) rep(k,h) rep(l,w){
				if(dp[i][j][k][l][0]!=0) continue;
				bool allcant=true,canwin=false;
				rep(di,5){
					int nx=i+dx[di],ny=j+dy[di];
					if(!is(nx,ny)) continue;
					if(dp[nx][ny][k][l][1]==1) canwin=true;
					if(dp[nx][ny][k][l][1]!=-1) allcant=false;
				}
				if(canwin){
					dp[i][j][k][l][0]=1;
//					showdp(i,j,k,l,0,1);
					update=true;
					continue;
				}
				if(allcant){
					dp[i][j][k][l][0]=-1;
//					showdp(i,j,k,l,0,-1);
					update=true;
					continue;
				}
			}
			//turn=1
			rep(i,h) rep(j,w) rep(k,h) rep(l,w){
				if(dp[i][j][k][l][1]!=0) continue;
				bool allcant=true,canwin=false;
				rep(di,5){
					int nx=k+dx[di],ny=l+dy[di];
					if(!is(nx,ny)) continue;
					if(dp[i][j][nx][ny][0]==-1) canwin=true;
					if(dp[i][j][nx][ny][0]!=1) allcant=false;
				}
				if(canwin){
					dp[i][j][k][l][1]=-1;
//					showdp(i,j,k,l,1,-1);
					update=true;
					continue;
				}
				if(allcant){
					dp[i][j][k][l][1]=1;
//					showdp(i,j,k,l,1,1);
					update=true;
					continue;
				}
			}
		}
//		rep(i,h) rep(j,w) rep(k,h) rep(l,w) rep(turn,2) showdp(i,j,k,l,turn,dp[i][j][k][l][turn]);
		switch(dp[qx][qy][ax][ay][0]){
			case -1:
				puts("Army can catch Queen.");
				break;
			case 0:
				puts("Queen can not escape and Army can not catch Queen.");
				break;
			case 1:
				puts("Queen can escape.");
				break;
		}
	}
}