#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[2][33][33][33][33];
Int cnt[2][33][33][33][33];
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int w,h;
  while(cin>>w>>h,w){
    vector<string> s(h);
    for(Int i=0;i<h;i++) cin>>s[i];
    memset(dp,-1,sizeof(dp));
    memset(cnt,0,sizeof(cnt));
    {
      using T = tuple<Int, Int, Int, Int, Int>;
      queue<T> q;
      Int dy[]={0,0,1,-1,0};
      Int dx[]={1,-1,0,0,0};
      auto in=[&](Int y,Int x){
	return 0<=y&&y<h&&0<=x&&x<w;
      };
      
      for(Int qy=0;qy<h;qy++){
	for(Int qx=0;qx<w;qx++){
	  if(s[qy][qx]=='#') continue;
	  for(Int ay=0;ay<h;ay++){
	    for(Int ax=0;ax<w;ax++){
	      if(s[ay][ax]=='#') continue;
	      // t == 0	      
	      {		
		if(s[qy][qx]=='E'&&!(qy==ay&&qx==ax)){
		  dp[0][qy][qx][ay][ax]=1;
		  q.emplace(0,qy,qx,ay,ax);
		}
		for(Int k=0;k<5;k++){
		  Int ny=qy+dy[k],nx=qx+dx[k];
		  if(!in(ny,nx)||s[ny][nx]=='#') continue;
		  cnt[0][qy][qx][ay][ax]++;
		}
	      }
	      // t == 1
	      {
		for(Int k=0;k<5;k++){
		  Int ny=ay+dy[k],nx=ax+dx[k];
		  if(!in(ny,nx)||s[ny][nx]=='#') continue;
		  if(ny==qy&&nx==qx){		    
		    dp[1][qy][qx][ay][ax]=1;
		    q.emplace(1,qy,qx,ay,ax);		  
		  }
		  cnt[1][qy][qx][ay][ax]++;
		}
	      }
	    }
	  }	
	}
      }
      //cout<<cnt[0][0][0][0][1]<<endl;
      const Int DBG = 0;
      
      while(!q.empty()){
	Int t,qy,qx,ay,ax;
	tie(t,qy,qx,ay,ax)=q.front();q.pop();
	Int d=dp[t][qy][qx][ay][ax];
	if(DBG) cout<<t<<":"<<qy<<" "<<qx<<" "<<ay<<" "<<ax<<":"<<d<<endl;
	
	if(t){
	  for(Int k=0;k<5;k++){
	    Int ny=qy+dy[k],nx=qx+dx[k];
	    if(!in(ny,nx)||s[ny][nx]=='#') continue;
	    if(~dp[!t][ny][nx][ay][ax]) continue;
	    cnt[!t][ny][nx][ay][ax]--;
	    if(!d||cnt[!t][ny][nx][ay][ax]==0){
	      if(DBG) cout<<"->"<<!t<<" "<<ny<<" "<<nx<<" "<<ay<<" "<<ax<<":"<<!d<<endl;
	      dp[!t][ny][nx][ay][ax]=!d;
	      q.emplace(!t,ny,nx,ay,ax);
	    }
	  }
	}else{
	  for(Int k=0;k<5;k++){
	    Int ny=ay+dy[k],nx=ax+dx[k];
	    if(!in(ny,nx)||s[ny][nx]=='#') continue;
	    if(~dp[!t][qy][qx][ny][nx]) continue;
	    cnt[!t][qy][qx][ny][nx]--;
	    if(!d||cnt[!t][qy][qx][ny][nx]==0){
	      if(DBG) cout<<"->"<<!t<<" "<<qy<<" "<<qx<<" "<<ny<<" "<<nx<<":"<<!d<<endl;
	      dp[!t][qy][qx][ny][nx]=!d;
	      q.emplace(!t,qy,qx,ny,nx);
	    }
	  }
	}
      }
      
    }
    
    
    {
      Int qx,qy,ax,ay;
      for(Int i=0;i<h;i++){
	for(Int j=0;j<w;j++){
	  if(s[i][j]=='Q') qy=i,qx=j;
	  if(s[i][j]=='A') ay=i,ax=j;
	}
      }
      if(dp[0][qy][qx][ay][ax]==1)
	cout<<"Queen can escape."<<endl;
      if(dp[0][qy][qx][ay][ax]==0)
	cout<<"Army can catch Queen."<<endl;
      if(dp[0][qy][qx][ay][ax]==-1)
	cout<<"Queen can not escape and Army can not catch Queen."<<endl;
    }
  }
  
  return 0;
}

