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 <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

char ba[30][30];
int memo[30][30][30][30][2];
int num[30][30][30][30][2];

struct P {
  int qx,qy,ax,ay;
  bool t;
  P(int qy,int qx,int ay,int ax, bool t) : qx(qx),qy(qy),ax(ax),ay(ay),t(t) {}
};
int w,h;

bool check(int y, int x) {
  return y<0||y>=h||x<0||x>=w||ba[y][x]=='#';
}

int main() {
  while(cin>>w>>h,w||h) {
    int qx,qy;
    int ax,ay;
    REP(i,h) REP(j,w) {
      cin >> ba[i][j];
      if (ba[i][j] == 'Q') qy=i,qx=j;
      else if(ba[i][j] == 'A') ay=i,ax=j;
    }
    memset(memo,-1,sizeof(memo));
    memset(num,0,sizeof(num));
    queue<P> Q;
    const int dy[] = {0,-1,0,1,0};
    const int dx[] = {0,0,1,0,-1};
    
    REP(y1,h) REP(x1,w) {
      if (ba[y1][x1]=='#') continue;
      REP(y2,h) REP(x2,w) {
        if (ba[y2][x2]=='#') continue;
        REP(k,2) {
          if (y1==y2&&x1==x2) {
            // queen lose
            memo[y1][x1][y2][x2][k] = k;
            Q.push(P(y1,x1,y2,x2,k));
          } else if (ba[y1][x1]=='E' && k==0) {
            // queen win
            memo[y1][x1][y2][x2][k] = 1;
            Q.push(P(y1,x1,y2,x2,k));
          }
          
          REP(d,5) {
            int yy1=y1+(k?dy[d]:0);
            int xx1=x1+(k?dx[d]:0);
            int yy2=y2+(k?0:dy[d]);
            int xx2=x2+(k?0:dx[d]);
            if (check(yy1,xx1)||check(yy2,xx2)) continue;
            num[yy1][xx1][yy2][xx2][!k]++;
          }
        }
      }
    }
    //cout << num[0][2][0][0][1] << endl;
    while(!Q.empty()) {
      P p = Q.front(); Q.pop();

      int y1=p.qy,x1=p.qx,y2=p.ay,x2=p.ax,k=p.t;
      //printf("(%d,%d),(%d,%d),%d  %d\n",y1,x1,y2,x2,k,memo[y1][x1][y2][x2][k]);
      REP(d,5) {
        int yy1=y1+(k?dy[d]:0);
        int xx1=x1+(k?dx[d]:0);
        int yy2=y2+(k?0:dy[d]);
        int xx2=x2+(k?0:dx[d]);
        if (check(yy1,xx1)||check(yy2,xx2)) continue;        
        if (memo[yy1][xx1][yy2][xx2][!k]!=-1) continue;
        if (memo[y1][x1][y2][x2][k] == 0) {
          memo[yy1][xx1][yy2][xx2][!k] = 1;
          Q.push(P(yy1,xx1,yy2,xx2,!k));
        } else {
          num[yy1][xx1][yy2][xx2][!k]--;
          if (num[yy1][xx1][yy2][xx2][!k] == 0) {
            //printf("  (%d,%d),(%d,%d),%d  \n",yy1,xx1,yy2,xx2,!k);
            memo[yy1][xx1][yy2][xx2][!k] = 0;
            Q.push(P(yy1,xx1,yy2,xx2,!k));
          }
        }
      }
    }
    if (memo[qy][qx][ay][ax][0] == 0) {
      cout << "Army can catch Queen." << endl;
    } else if (memo[qy][qx][ay][ax][0] == 1) {
      cout << "Queen can escape." << endl;
    } else {
      cout << "Queen can not escape and Army can not catch Queen." << endl;
    }
  }
}