#include<iostream>
#include<queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

enum RES{DRAW=-1,WIN,LOSE};

class state{
public:
  bool who;//0 queen 1 army
  short q,a;
};


enum RES win[2][900][900];
char need[2][900][900];
vector<state> edge[2][900][900];

int dx[]={0,0,1,-1,0};
int dy[]={1,-1,0,0,0};
char m[30][30];

bool out(int y,int x,int r,int c){
  return y<0||x<0||y>=r||x>=c;
}

int md(int y,int x,int yy,int xx){
  return max(y,yy)-min(y,yy)+max(x,xx)-min(x,xx);
}

void solve(int q,int a,int r,int c){
  rep(i,2){
    rep(j,r*c){
      rep(k,r*c){
	win[i][j][k]=DRAW;
	edge[i][j][k].clear();
	need[i][j][k]=0;
      }
    }
  }
  
  rep(qi,r){
    rep(qj,c){
      if (m[qi][qj] == '#')continue;
      rep(ai,r){
	rep(aj,c){
	  if (m[ai][aj] == '#')continue;
	  rep(k,5){
	    int nex=qj+dx[k],ney=qi+dy[k];
	    if (out(ney,nex,r,c)||m[ney][nex] == '#')continue;

	    need[0][qi*c+qj][ai*c+aj]++;
	    edge[1][ney*c+nex][ai*c+aj].pb((state){0,qi*c+qj,ai*c+aj});
	  }
	  rep(k,5){
	    int nex=aj+dx[k],ney=ai+dy[k];
	    if (out(ney,nex,r,c)||m[ney][nex] == '#')continue;
	    need[1][qi*c+qj][ai*c+aj]++;
	    edge[0][qi*c+qj][ney*c+nex].pb((state){1,qi*c+qj,ai*c+aj});
	  }
	}
      }
    }
  }

  queue<state> Q;
  //win q
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      rep(ii,r){
	rep(jj,c){
	  if (m[ii][jj] == '#'||(ii==i&&jj==j))continue;
	  if (m[i][j] == 'E'){// && md(i,j,ii,jj)>1){
	    win[0][i*c+j][ii*c+jj]=WIN;
	    Q.push((state){0,i*c+j,ii*c+jj});
	  }
	  if (m[i][j] == 'E' && md(i,j,ii,jj) > 1){
	    win[1][i*c+j][ii*c+jj]=LOSE;
	    Q.push((state){1,i*c+j,ii*c+jj});
	  }
	}
      }
    }
  }
  

  //win a
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      rep(k,4){
	int nex=j+dx[k],ney=i+dy[k];
	if (out(ney,nex,r,c)||m[ney][nex]=='#'){
	  continue;
	}
	if (win[1][i*c+j][ney*c+nex] == DRAW){
	  win[1][i*c+j][ney*c+nex]=WIN;
	  Q.push((state){1,i*c+j,ney*c+nex});
	}
      }
    }
  }
  

  
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      if (win[0][i*c+j][i*c+j] == DRAW){
	win[0][i*c+j][i*c+j]=LOSE;
	Q.push((state){0,i*c+j,i*c+j});
      }
      if (win[1][i*c+j][i*c+j] == DRAW){
	win[1][i*c+j][i*c+j]=WIN;
	Q.push((state){1,i*c+j,i*c+j});
      }
    }
  }
  

  while(!Q.empty()){
    state now = Q.front();Q.pop();
    //cout << now.who <<" " << now.q <<" " << now.a <<" " << win[now.who][now.q][now.a] << endl;
    
    rep(i,edge[now.who][now.q][now.a].size()){
      state next=edge[now.who][now.q][now.a][i];
      need[next.who][next.q][next.a]--;
      //      if (next.who == 0 &&next.q == 0 && next.a == 1)
      //	cout <<now.who <<" " <<  now.q <<" " << now.a << endl;

      if (win[next.who][next.q][next.a] != DRAW)continue;
      if (win[now.who][now.q][now.a] == LOSE){
	win[next.who][next.q][next.a]=WIN;
	Q.push(next);
      }else if (need[next.who][next.q][next.a] == 0 && 
		win[next.who][next.q][next.a]  == DRAW){
	win[next.who][next.q][next.a]=LOSE;
	Q.push(next);
      }
    }
  }

  //  cout << need[0][q][a]<<endl;
  if (win[0][q][a] == LOSE)cout << "Army can catch Queen." << endl;
  else if (win[0][q][a] == WIN)cout << "Queen can escape." << endl;
  else cout << "Queen can not escape and Army can not catch Queen."<<endl;
  return;
}


main(){
  int r,c;
  while(cin>>c>>r && c){
    rep(i,r){
      rep(j,c)cin>>m[i][j];
    }
    int q,a;
    rep(i,r){
      rep(j,c){
	if (m[i][j] == 'Q')q=i*c+j;
	if (m[i][j] == 'A')a=i*c+j;
      }
    }
    solve(q,a,r,c);
  }
}

Measured memory_bytes: 31000