#include<bits/stdc++.h>
using namespace std;
int sx,sy,tx,ty;
int n,m;
int fx[8][2]={{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
struct pp{
int x,y,ans;
};
vector<vector<int>> a1;
void bz(int x,int y){
int xx=x,yy=y;
for(int i=0;i<8;i++){
x=xx;
y=yy;
while(1){
a1[x][y]=2;
x+=fx[i][0];
y+=fx[i][1];
if(x<0||x>=n||y<0||y>=m||a1[x][y]==1){
break;
}
}
}
}
int main(){
cin>>n>>m;
vector<vector<int>> a(n,vector<int> (m,0));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
char c;
cin>>c;
if(c=='X'){
a[i][j]=1;
}
}
}
a1=a;
while(1){
a=a1;
cin>>sx>>sy>>tx>>ty;
if(sx==0&&sy==0&&tx==0&&ty==0){
return 0;
}
sx--;
sy--;
tx--;
ty--;
bz(tx,ty);
swap(a,a1);
queue<pp> q;
q.push({sx,sy,0});
bool bo=1;
while(q.size()&&bo){
int x=q.front().x;
int y=q.front().y;
int ans=q.front().ans;
q.pop();
for(int i=0;i<4;i++){
int nx=x+fx[i][0];
int ny=y+fx[i][1];
if(nx>=0&&nx<n&&ny>=0&&ny<m&&a[nx][ny]!=1){
if(a[nx][ny]==2){
cout<<ans+1<<endl;
bo=0;
break;
}
a[nx][ny]=1;
q.push({nx,ny,ans+1});
}
}
}
if(bo){
cout<<"Poor Harry\n";
}
}
}