#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
int n,m,ex,ey,sx,sy;
int dx[10]= {0,1,0,-1,0,1,-1,1,-1};
int dy[10]= {0,0,1,0,-1,-1,1,1,-1};
struct da {
int x,y,t;
};
int main() {
cin>>n>>m;
char ch[n+1][m+1],map[n+1][m+1];
memset(ch,0,sizeof(ch));
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cin>>ch[i][j];
map[i][j]=ch[i][j];
}
}
while(cin>>ex>>ey>>sx>>sy) {
bool r=false;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
ch[i][j]=map[i][j];
}
}
while(ex!=0&&ey!=0&&sx!=0&&sy!=0) {
queue<da> q;
da temp;
temp.t=0,temp.x=sx,temp.y=sy;
q.push(temp);
if(sx==ex&&ey==sy) {
cout<<0;
r=true;
break;
}
while(!q.empty()) {
da k=q.front();
q.pop();
r=false;
for(int i=1; i<=8; i++) {
int cnt=1;
while(1) {
int newxx=k.x+dx[i]*cnt,newyy=k.y+dy[i]*cnt;
if(newxx==ex&&newyy==ey) {
cout<<k.t<<endl;
r=true;
break;
}
cnt++;
if(!(newxx>0&&newxx<=n&&newyy>0&&newyy<=m&&ch[newxx][newyy]=='O'))break;
}
if(r)break;
}
if(r)break;
for(int i=1; i<=4; i++) {
int newx=dx[i]+k.x,newy=dy[i]+k.y;
if(newx>0&&newx<=n&&newy>0&&newy<=m&&ch[newx][newy]=='O') {
temp.t=k.t+1,temp.x=newx,temp.y=newy;
ch[newx][newy]='X';
q.push(temp);
}
}
}
if(!r)cout<<"Poor Harry\n";
break;
}
}
return 0;
}