#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
const int INF = 0x7fffffff;
using namespace std;
const int maxn = 210;
char g[maxn][maxn];
int n, m, res;
int used[maxn][maxn];
struct info {
int x;
int y;
int time;
};
//从天使所在的地方开始搜索,逆向思维.
info start, endx;
queue<info> Q;
void init() {
res = 0;
while(!Q.empty()) Q.pop();
memset(g, '\0', sizeof(g));
for(int i = 0; i < maxn; i++) {
for(int j = 0; j < maxn; j++) {
used[i][j] = INF;
}
}
}
void bfs() {
Q.push(start);
info tmp, in;
while(!Q.empty()) {
tmp = Q.front();
Q.pop();
if(g[tmp.x][tmp.y] == 'r') continue;
if(tmp.x + 1 <= n && g[tmp.x+1][tmp.y] != '#') {// down
in.x = tmp.x + 1;
in.y = tmp.y;
in.time = tmp.time + 1;
if(g[in.x][in.y] == 'x') {
in.time ++;
}
if(used[in.x][in.y] > in.time) {
used[in.x][in.y] = in.time;
Q.push(in);
}
}
if(tmp.x-1 >= 1 && g[tmp.x-1][tmp.y] != '#') {// up
in.x = tmp.x - 1;
in.y = tmp.y;
in.time = tmp.time + 1;
if(g[in.x][in.y] == 'x') {
in.time ++;
}
if(used[in.x][in.y] > in.time) {
used[in.x][in.y] = in.time;
Q.push(in);
}
}
if(tmp.y-1>=1 && g[tmp.x][tmp.y-1] != '#') {// left
in.x = tmp.x;
in.y = tmp.y - 1;
in.time = tmp.time + 1;
if(g[in.x][in.y] == 'x') {
in.time ++;
}
if(used[in.x][in.y] > in.time) {
used[in.x][in.y] = in.time;
Q.push(in);
}
}
if(tmp.y+1 <= m && g[tmp.x][tmp.y+1] != '#') {//right
in.x = tmp.x;
in.y = tmp.y + 1;
in.time = tmp.time + 1;
if(g[in.x][in.y] == 'x') {
in.time ++;
}
if(used[in.x][in.y] > in.time) {
used[in.x][in.y] = in.time;
Q.push(in);
}
}
}
}
int main()
{
int i, j;
while(scanf("%d%d", &n, &m) != EOF) {
init();
for(i = 1; i <= n; i++) {
scanf("%s", g[i] + 1);
}
for(i = 1; i <= n; i++) {
for(j = 1; j <= m; j++) {
if(g[i][j]=='a') {
start.x = i;
start.y = j;
start.time = 0;
used[i][j] = 0;
}
}
}
bfs();
int minv = INF;
for(i = 1; i <= n; i++) {
for(j = 1; j <= m; j++) {
if(g[i][j]=='r') {
minv = min(minv, used[i][j]);
}
}
}
if(minv != INF) {
printf("%d\n", minv);
}else {
printf("Poor ANGEL has to stay in the prison all his life.\n");
}
}
return 0;
}