#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

int dp[2][33][33][33][33]; //turn, x_queen, y_queen, x_army, y_army
int h, w;
vs fld;

typedef tuple<int, int, int, int, int> state;

void init()
{
	fld.clear(); fld.resize(h);
	MS(dp, 0);
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	while (cin >> w >> h, h)
	{
		init();
		REP(i, h) cin >> fld[i];
		pii army, queen;
		set<pii> exit;
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == '#') continue;
			if (fld[i][j] == 'Q') queen = pii(i, j);
			if (fld[i][j] == 'A') army = pii(i, j);
			if (fld[i][j] == 'E') exit.emplace(i, j);
			fld[i][j] = '.';
		}
		vector<state> updates;
		for (auto i : exit)REP(ax, h)REP(ay, w)
		{
			int qx = i.first, qy = i.second;
			dp[0][qx][qy][ax][ay] = 1;
			updates.push_back(state(0, qx, qy, ax, ay));
		}
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == '#') continue;
			dp[0][i][j][i][j] = -1;
			updates.push_back(state(0, i, j, i, j));
		}
		REP(i, 2)REP(qx, h)REP(qy, w)REP(ax, h)REP(ay, w) updates.push_back(state(i, qx, qy, ax, ay));
		while (!updates.empty())
		{
			vector<state> nexts;
			for (auto tmp : updates)
			//REP(i, 2)REP(qx, h)REP(qy, w)REP(ax, h)REP(ay, w)
			{
				int i, qx, qy, ax, ay;
				tie(i, qx, qy, ax, ay) = tmp;
				if (!valid(qx, qy, h, w) || !valid(ax, ay, h, w) || dp[i][qx][qy][ax][ay] != 0) continue;
				if (i == 0)
				{
					set<int> st;
					st.insert(dp[1][qx][qy][ax][ay]);
					REP(j, 4)
					{
						int nx = qx + dx[j], ny = qy + dy[j];
						if (!valid(nx, ny, h, w) || fld[nx][ny] == '#') continue;
						st.insert(dp[1][nx][ny][ax][ay]);
					}
					if (st.size() == 1 && *st.begin() == -1)
					{
						dp[i][qx][qy][ax][ay] = -1;
					}
					else if (st.count(1))
					{
						dp[i][qx][qy][ax][ay] = 1;
					}
				}
				else
				{
					set<int> st;
					st.insert(dp[0][qx][qy][ax][ay]);
					REP(j, 4)
					{
						int nx = ax + dx[j], ny = ay + dy[j];
						if (!valid(nx, ny, h, w) || fld[nx][ny] == '#') continue;
						st.insert(dp[0][qx][qy][nx][ny]);
					}
					if (st.size() == 1 && *st.begin() == 1)
					{
						dp[i][qx][qy][ax][ay] = 1;
					}
					else if (st.count(-1))
					{
						dp[i][qx][qy][ax][ay] = -1;
					}
				}
				if (dp[i][qx][qy][ax][ay] != 0)
				{
					if (dp[1 - i][qx][qy][ax][ay] == 0)
					{
						nexts.push_back(state(1 - i, qx, qy, ax, ay));
					}
					REP(i, 2)REP(j, 4)REP(k, 4)
					{
						if (!valid(qx + dx[j], qy + dy[j], h, w) || !valid(ax + dx[k], ay + dy[k], h, w) || dp[i][qx + dx[j]][qy + dy[j]][ax + dx[k]][ay + dy[k]] != 0) continue;
						nexts.push_back(state(i, qx + dx[j], qy + dy[j], ax + dx[k], ay + dy[k]));
					}
				}
			}
			sort(ALL(updates));
			updates.erase(unique(ALL(updates)), updates.end());
			updates = nexts;
		}
		

		int ans = dp[0][queen.first][queen.second][army.first][army.second];
		if (ans == 1) cout << "Queen can escape." << endl;
		else if (ans == 0) cout << "Queen can not escape and Army can not catch Queen." << endl;
		else cout << "Army can catch Queen." << endl;
	}

	return 0;
}

Measured memory_bytes: 52528