#include <iostream>
#include <queue>
using namespace std;
typedef struct
{
int x,y,cout;
}unit;
unit arr[40000];
char map[202][202];
int n,m,step,dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
bool flag;
void bfs(int a,int b)
{
unit cur,next;
int i;
queue<unit> q;
map[a][b] = '#';
cur.x = a;
cur.y = b;
cur.cout = 1;
q.push(cur);
while(!q.empty())
{
cur = q.front();
q.pop();
for(i=0;i<4;i++)
{
next.x = cur.x+dir[i][0];
next.y = cur.y+dir[i][1];
if(next.x>=0 && next.x<n && next.y>=0 && next.y<m)
{
if(map[next.x][next.y]=='.')
{
next.cout = cur.cout+1;
q.push(next);
map[next.x][next.y]='#';
}
else if(map[next.x][next.y]=='x')
{
next.cout = cur.cout+2;
q.push(next);
map[next.x][next.y]='#';
}
else if(map[next.x][next.y]=='a')
{
flag = true;
step = step<cur.cout?step:cur.cout;
}
}
}
}
return;
}
int main()
{
int i,j;
while(cin>>n>>m)
{
flag = false;
step = n*m;
for(i=0;i<n;i++)
cin>>map[i];
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(map[i][j]=='r')
bfs(i,j);
if(flag)
cout<<step<<endl;
else
cout<<"Poor ANGEL has to stay in the prison all his life."<<endl;
}
return 0;
}