#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
const int N = 31;

int h, w;
vector<string> mp;
int dx[] = {0, 0, 0, 1, -1};
int dy[] = {0, 1, -1, 0, 0};
int in(int x,int y){return 0 <= x && x < w && 0 <= y && y < h;}
int canMove(int x,int y){return in(x, y) && mp[y][x] != '#';}

int dp[2][N][N][N][N];
int used[2][N][N][N][N];
int cnt[2][N][N][N][N];
int bfs(){

  struct dat{
    int turn;
    int y, x;
    int b, a;
    dat();
    dat(int turn,int y,int x,int b,int a):turn(turn), y(y), x(x), b(b), a(a){}
  };
  
  memset(dp,-1,sizeof(dp));
  memset(used,0,sizeof(used));
  memset(cnt,0,sizeof(cnt));

  int Qx, Qy, Ax, Ay;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(mp[i][j] == 'Q') Qx = j, Qy = i;
      if(mp[i][j] == 'A') Ax = j, Ay = i;
    }
  
  queue<dat> Q;
  
  // dp[0]->Q's turn
  // dp[1]->A's turn

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int b=0;b<h;b++)
        for(int a=0;a<w;a++){
          if(mp[i][j] == '#' || mp[b][a] == '#') continue;
	  
          //Qの勝ち確定
          if((i != b || j != a) && mp[i][j] == 'E') {
            Q.push(dat(0, i, j, b, a));
            dp[0][i][j][b][a] = 1;
            used[0][i][j][b][a] = 1;
          }
          
          //Aの勝ち確定
          if(i == b && j == a) {
	    
	    //Qの負け
	    {
	      Q.push(dat(0, i, j, b, a));	    
	      dp[0][i][j][b][a] = 0;
	      used[0][i][j][b][a] = 1;
	    }
	    
	    for(int k=0;k<5;k++){
              int nb = b + dy[k];
              int na = a + dx[k];
              if(!canMove(na, nb) || used[1][i][j][nb][na]) continue;
	      Q.push(dat(1, i, j, nb, na));
	      dp[1][i][j][nb][na] = 1;
	      used[1][i][j][nb][na] = 1;
	    }
	  }
	}

  
  auto getVal=[&](int turn, int y,int x,int b,int a){
    int draw = 0;
    for(int i=0;i<5;i++){
      int nturn = !turn;
      int ny = y + (turn == 0? dy[i]:0);
      int nx = x + (turn == 0? dx[i]:0);
      int nb = b + (turn == 1? dy[i]:0);
      int na = a + (turn == 1? dx[i]:0);
      if(!canMove(nx, ny) || !canMove(na, nb)) continue;
      if(dp[nturn][ny][nx][nb][na] == 0) return 1LL;
      if(dp[nturn][ny][nx][nb][na] == -1) draw = 1;
    }
    return draw? -1LL:0LL;
  };
  
  while(!Q.empty()){
    auto t = Q.front(); Q.pop();
    int turn = t.turn;
    int y = t.y, x = t.x;
    int b = t.b, a = t.a;
    
    for(int i=0;i<5;i++){
      int nturn = !turn;
      int ny = y + (nturn == 0? dy[i]:0);
      int nx = x + (nturn == 0? dx[i]:0);
      int nb = b + (nturn == 1? dy[i]:0);
      int na = a + (nturn == 1? dx[i]:0);
      if(!canMove(nx,ny) || !canMove(na,nb)) continue;
      if(used[nturn][ny][nx][nb][na]) continue; 
      
      int nval = getVal(nturn, ny, nx, nb, na);
      if(nval == -1) continue;
      dp[nturn][ny][nx][nb][na] = nval;
      Q.push(dat(nturn, ny, nx, nb, na));
      used[nturn][ny][nx][nb][na] = 1;
    }
  }

  return dp[0][Qy][Qx][Ay][Ax];
}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    
    cin>>w>>h;
    if(w == 0 && h == 0) return 0;
    mp.clear();
    mp.resize(h);
    cin>>mp;

    int ans = bfs();
    if(ans == -1) cout<<"Queen can not escape and Army can not catch Queen."<<endl;
    if(ans == 0) cout<<"Army can catch Queen."<<endl;
    if(ans == 1) cout<<"Queen can escape."<<endl;
  }
  return 0;
}



Measured memory_bytes: 46408