#include <bits/stdc++.h>
using namespace std;

const int MAXH = 31;
const int MAXW = 31;
const int di[] = {0,1,0,-1,0};
const int dj[] = {1,0,-1,0,0};
int W, H;
char G[MAXH][MAXW];
int mem[MAXH][MAXW][MAXH][MAXW][2];

int main() {
  while(cin >> W >> H && (W|H)) {
    int sqi, sqj, sei, sej;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        if(G[i][j] == 'Q') {
          sqi = i;
          sqj = j;
        }
        if(G[i][j] == 'A') {
          sei = i;
          sej = j;
        }
      }
    }
    
    fill(mem[0][0][0][0], mem[0][0][0][0] + sizeof(mem)/sizeof(int), 1);
    for(int qi = 0; qi < H; ++qi) {
      for(int qj = 0; qj < W; ++qj) {
        for(int ei = 0; ei < H; ++ei) {
          for(int ej = 0; ej < W; ++ej) {
            for(int t = 0; t < 2; ++t) {
              int &now = mem[qi][qj][ei][ej][t];
              if(G[qi][qj] == 'E' && t == 0) now = 2;
              if(qi == ei && qj == ej) now = 0;
            }
          }
        }
      }
    }
    
    for(bool update = true; update;) {
      update = false;
      for(int qi = 0; qi < H; ++qi) {
        for(int qj = 0; qj < W; ++qj) {
          for(int ei = 0; ei < H; ++ei) {
            for(int ej = 0; ej < W; ++ej) {
              for(int t = 0; t < 2; ++t) {
                int &now = mem[qi][qj][ei][ej][t];
                if(now != 1) continue;
                int tmp = t * 2;
                for(int k = 0; k < 5; ++k) {
                  int nqi =  t ? qi : qi + di[k];
                  int nqj =  t ? qj : qj + dj[k];
                  int nei = !t ? ei : ei + di[k];
                  int nej = !t ? ej : ej + dj[k];
                  if(nqi < 0 || nqi >= H) continue;
                  if(nqj < 0 || nqj >= W) continue;
                  if(nei < 0 || nei >= H) continue;
                  if(nej < 0 || nej >= W) continue;
                  if(G[nqi][nqj] == '#') continue;
                  if(G[nei][nej] == '#') continue;
                  if(t) tmp = min(tmp, mem[nqi][nqj][nei][nej][1-t]);
                  else  tmp = max(tmp, mem[nqi][nqj][nei][nej][1-t]);
                }
                if(tmp != 1) {
                  now = tmp;
                  update = true;
                }
              }
            }
          }
        }
      }
    }
    int res = mem[sqi][sqj][sei][sej][0];
    if(res == 0) cout << "Army can catch Queen." << endl;
    else if(res == 1) cout << "Queen can not escape and Army can not catch Queen." << endl;
    else cout << "Queen can escape." << endl;
  }
  return 0;
}