#include <bits/stdc++.h>
using namespace std;
struct node{
int x,y;
int time;
};
const int N = 2e5;
char arr[N];
bool bj[N];
bool vis[N];
int dirx[] = {0,0,1,-1,1,1,-1,-1};
int diry[] = {1,-1,0,0,1,-1,-1,1};
int xx[]={0,-1,0,0,1};
int yy[]={0,0,-1,1,0};
int n,m;
bool in(int x,int y){
return x>=1&&x<=n&&y>=1&y<=m;
}
void viss(int ex,int ey){
for(int i=0;i<8;i++){
int tx=ex+dirx[i];
int ty=ey+diry[i];
while(in(tx,ty)&&arr[(tx-1)*m+ty]!='X'){
vis[(tx-1)*m+ty]=1;
tx+=dirx[i];
ty+=diry[i];
}
}
}
void bfs(int x,int y){
bj[(x-1)*m+y]=1;
queue<node>q;
q.push({x,y,0});
while(q.size()!=0){
node now=q.front();
q.pop();
if(vis[(now.x-1)*m+now.y]==1){
cout<<now.time<<endl;
return;
}
for(int i=1;i<=4;i++){
int tx=now.x+xx[i];
int ty=now.y+yy[i];
if(in(tx,ty)&&bj[(tx-1)*m+ty]==0&&arr[(tx-1)*m+ty]!='X'){
bj[(tx-1)*m+ty]=1;
q.push({tx,ty,now.time+1});
}
}
}
cout<<"Poor Harry"<<endl;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>arr[(i-1)*m+j];
}
}
int x1,y1,x2,y2;
while(true){
memset(vis,0,sizeof(vis));
memset(bj,0,sizeof(bj));
cin>>x1>>y1>>x2>>y2;
if(x1==0&&y1==0&&x2==0&&y2==0){
break;
}
if(x1==x2&&y1==y2){
cout<<0<<endl;
}
viss(x2,y2);
bfs(x1,y1);
}
return 0;
}