#include <stdio.h>
#include <stdlib.h>
/* Written by Nishant Mittal aka nishantwrp */
int main()
{
   int n,m,i,j,a,b;
   scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
   int min=-1;
   int checka,checkb;
   checka= abs(n-i);
   checkb = abs(m-j);

   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(m-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(n-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }

   if (min == -1) {
    printf("Poor Inna and pony!");
   } else if (min == 0) {
   printf("0");
   } else if  ((abs(n-i) >=a || i-1 >= a ) &&  (abs(m-j) >=b || j-1 >=b)) {
   printf("%d",min);
   } else {
   printf("Poor Inna and pony!");
   }
    return 0;
}

#include <stdio.h>

#define INF (1<<29)

int n, m, i, j, a, b;

int min(int a, int b) { return a < b ? a : b; }

int solve(int i, int j){
	int ret = 0;
	if (i % a || j % b) return INF;
	ret = min(i/a, j/b);
	i -= ret * a;
	j -= ret * b;
	if (i && j) return INF;
	if (j/b % 2 != 0 || i/a % 2 != 0) return INF;
	if (i == 0 && j != 0 && a >= n) return INF;
	if (j == 0 && i != 0 && b >= m) return INF;
	return ret + j/b + i/a;
}

int main(void){
	scanf("%d %d %d %d %d %d", &n, &m, &i, &j, &a, &b);
	int x = min(min(solve(i-1,j-1),solve(n-i,j-1)),min(solve(i-1,m-j),solve(n-i,m-j)));
	if (x < INF)
		printf("%d\n", x);
	else
		printf("Poor Inna and pony!\n");
	return 0;
}

#include<stdio.h>
long max(long x , long y){ return x>y?x:y; }
int main()
{
    long i,j,n,m,a,b,ans[4],min,f=0;
    long cint,dint;
    float c,d;
    scanf("%ld%ld%ld%ld%ld%ld",&n,&m,&i,&j,&a,&b);

    if((i==1 || i==n) && (j==1 || j==m))
    {
             printf("0");
             return 0;
    }

    if(a>=n || b>=m)
    {
            printf("Poor Inna and pony!");
            return 0;
    }

    c=(i-1)*1.0/a;
    d=(j-1)*1.0/b;
    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(n-i)*1.0/a;
    d=(j-1)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if((abs(cint-dint))%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(i-1)*1.0/a;
    d=(m-j)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(n-i)*1.0/a;
    d=(m-j)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    if(f==0)
    {
            printf("Poor Inna and pony!");
            return 0;
    }
    min=ans[0];
    for(i=1;i<f;i++)
    if(min>ans[i])
    min=ans[i];

    printf("%ld",min);
    return 0;
}

#include <stdio.h>
#include <math.h>
int n,m;
in_bounce(int x,int y)
{
  if(x<=n&&x>=1&&y<=m&&y>=1) return 1;
  return 0;
}
main()
{
   int i,j,a,b,k,dir[4][2],nowdx,nowdy,min;
   while(~scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b))
   {
	   min=9999999;
       dir[0][0]=1;dir[0][1]=1;
	   dir[1][0]=1;dir[1][1]=m;
	   dir[2][0]=n;dir[2][1]=m;
	   dir[3][0]=n;dir[3][1]=1;
	   for(k=0;k<4;k++)
	   {
	     nowdx=abs(i-dir[k][0]);
		 nowdy=abs(j-dir[k][1]);
		 if(nowdx%a!=0||nowdy%b!=0) continue;
		 else
		  if(nowdx/a==nowdy/b&&min>nowdx/a) min=nowdx/a;
		  else if(nowdx/a>nowdy/b)
		  {if((nowdx/a-nowdy/b)%2==0&&(min>nowdy/b+(nowdx/a-nowdy/b))&&(in_bounce(i,j-b)||in_bounce(i,j+b))) min=nowdy/b+(nowdx/a-nowdy/b);}
		  else  if((nowdy/b-nowdx/a)%2==0&&(min>nowdx/a+(nowdy/b-nowdx/a))&&(in_bounce(i-a,j)||in_bounce(i+a,j))) min=nowdx/a+(nowdy/b-nowdx/a);
	   }
	   if(min==9999999) printf("Poor Inna and pony!\n");
	   else printf("%d\n",min);
   }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int calc_moves(int, int, int, int, int, int);
int min(int, int);

int main(){

    int i, j, x, y, n, m, a, b;
    scanf("%d %d %d %d %d %d", &n, &m, &x, &y, &a, &b);

    int sol1 = calc_moves(x, y, 1, 1, a, b);
    int sol2 = calc_moves(x, y, 1, m, a, b);
    int sol3 = calc_moves(x, y, n, 1, a, b);
    int sol4 = calc_moves(x, y, n, m, a, b);

    if (sol1 == -1 && sol2 == -1 && sol3 == -1 && sol4 == -1) {
        printf("Poor Inna and pony!\n");
    }
    else {
        int sol = min(sol1, min(sol2, min(sol3, sol4)));
        if (sol > 0 && ((x - a < 1 && x + a > n) || (y - b < 1 && y + b > m))) {
            printf("Poor Inna and pony!\n");
        }
        else {
            printf("%d\n", sol);
        }
    }

#ifdef _AT_HOME_
    system("pause");
#endif

    return 0;
}

int calc_moves(int start_x, int start_y, int finish_x, int finish_y, int step_x, int step_y) {

    int dx = abs(start_x - finish_x);
    int dy = abs(start_y - finish_y);

    if (dx % step_x != 0 || dy % step_y != 0) {
        return -1;
    }

    int sx = dx / step_x;
    int sy = dy / step_y;

    if (abs(sx - sy) & 1) {
        return -1;
    }
    else {
        return (sx > sy)?sx:sy;
    }

}

int min(int a, int b) {
    if (a == -1 || b == -1) {
        return -a*b;
    }
    else{
        return (a > b)?b:a;
    }
}

#include<stdio.h>
long long int n,m,i,j,a,b;
int ab(int a)
{
	if(a<0)
	return -a;
	return a;
}
int max(int a,int b)
{
	if(a<b)
	return b;
	return a;
}
int min(int a,int b)
{
	if(a>b)
	return b;
	return a;
}
int func(int u,int v)
{
		if(i==u&&j==v)
		return 0;
		if(i+a>n&&i-a<=0)
		return -1;
		if(j+b>m&&j-b<=0)
		return -1;
		int x=ab(u-i),y=ab(v-j);
		if(x%a!=0||y%b!=0)
		return -1;
		x=x/a;y=y/b;
		if(x%2!=y%2)
		return -1;
		int t=max(x,y);
		return t;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&i,&j,&a,&b);
	int ans=100000000;
	int a=func(1,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(1,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	if(ans<100000000)
	printf("%d",ans);
	else
	printf("Poor Inna and pony!");
	return 0;
}

#include<stdio.h>
#define INF 1000000009
int max(int x,int y){
    if(x>y){
        return x;
    }
    return y;
}
int min(int x, int y){
    if(x>y){
        return y;
    }
    return x;
}
int main(){
    int n,m,i,j,a,b,cnt1=INF,cnt2=INF,cnt3=INF,cnt4=INF;
    int ans1=INF,ans2=INF,ans3=INF,ans4=INF,s,t,ret;
    int flg1=0,flg2=0,flg3=0,flg4=0;
    scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
    if((i-1)%a!=0){
        if((n-i)%a!=0){
            if((j-1)%b!=0){
                if((m-j)%b!=0){
                    printf("Poor Inna and pony!\n");
                    return 0;
                }
            }
        }
    }
    if((i-1)%a==0){
        cnt1=(i-1)/a;
    }
    if((n-i)%a==0){
        cnt2=(n-i)/a;
    }
    if((j-1)%b==0){
        cnt3=(j-1)/b;
    }
    if((m-j)%b==0){
        cnt4=(m-j)/b;
    }
    if(i+a>n && cnt1==0){
        flg1++;
    }
    if(i-a<1 && cnt2==0){
        flg2++;
    }
    if(j+b>m && cnt3==0){
        flg3++;
    }
    if(j-b<1 && cnt4==0){
        flg4++;
    }
    if((cnt1-cnt3)%2==0 && cnt1!=INF && cnt3!=INF){
        if(cnt1>cnt3 && flg3==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        if(cnt1<cnt3 && flg1==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        ans1=max(cnt1,cnt3);
    }
    if((cnt1-cnt4)%2==0 && cnt1!=INF && cnt4!=INF){
        if(cnt1>cnt4 && flg4==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        if(cnt1<cnt4 && flg1==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        ans2=max(cnt1,cnt4);
    }
    if((cnt2-cnt3)%2==0 && cnt2!=INF && cnt3!=INF){
        if(cnt2>cnt3 && flg3==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        if(cnt2<cnt3 && flg2==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        ans3=max(cnt2,cnt3);
    }
    if((cnt2-cnt4)%2==0 && cnt2!=INF && cnt4!=INF){
        if(cnt2>cnt4 && flg4==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        if(cnt2<cnt4 && flg2==1){
            printf("Poor Inna and pony!\n");
            return 0;
        }
        ans4=max(cnt2,cnt4);
    }
    if(ans1==INF && ans2==INF && ans3==INF && ans4==INF){
        printf("Poor Inna and pony!\n");
        return 0;
    }
    s=min(ans1,ans2);
    t=min(ans3,ans4);
    ret=min(s,t);
    printf("%d\n",ret);
    return 0;
}

#include<stdio.h>

int max(int a,int b)
{
    return a>b?a:b;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int n,m,i,j,a,b,ans=-1,x,y,an,flag=0;
    scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
    x=i-1;y=j-1;
    if(((i-1)>=a || (n-i)>=a) && ((j-1)>=b || (m-j)>=b))
        flag=1;

    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=i-1;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=j-1;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    if(ans==-1 || (ans!=0 && flag==0)) printf("Poor Inna and pony!");
    else printf("%d",ans);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int min(int x1,int x2){if(x1<x2)return x1;else return x2;}
int max(int x1,int x2){if(x1>x2)return x1;else return x2;}

int  n,m,i,j,a,b,dx,dy;
int count=999999;

void check(int x1, int x2)
{
    if (x1 == i && x2 == j)
    {
        count = 0;
        return;
    }
    if (i + a > n && i - a <= 0) return;
    if (j + b > m && j - b <= 0) return;
    x1 = abs(x1 - i); x2 = abs(x2 - j);
    if (x1 % a || x2 % b) return;
    x1 =x1/ a;
    x2 =x2/ b;
    if (x1 % 2 != x2 % 2) return;
    count = min(count, max(x1, x2));
}

int main()
{

    scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);

    check(1, 1);
    check(1, m);
    check(n, 1);
    check(n, m);

    if(count==999999)
        printf("Poor Inna and pony!");
    else
        printf("%d",count);

    return 0;

}

#include <stdio.h>
#include <string.h>
int mn(int a,int b){
	if(a==-1)return b;
	if(b==-1)return a;
	return a<b?a:b;
}
int ch(int a,int b){
	if(a==-1)return 0;
	if(b==-1)return 0;
	int c=a-b;
	if(c<0)c*=-1;
	return ((c%2)==0);
}
int mx(int a,int b){
	return a>b?a:b;
}
int main(){
	int n,m,i,j,a,b,p1,q1,p2,q2;
	int w,x,y,z;
	scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
	if((i==1||i==n)&&(j==1||j==m)){
		printf("0");return 0;
	}
	if((i+a>n)&&(i-a<1)||(j+b>m)&&(j-b<1)){
		printf("Poor Inna and pony!");
		return 0;
	}
	p1=q1=-1;
	if((n-i)%a==0)p1=(n-i)/a;
	if((i-1)%a==0)q1=(i-1)/a;
	p2=q2=-1;
	if((m-j)%b==0)p2=(m-j)/b;
	if((j-1)%b==0)q2=(j-1)/b;
	w=x=y=z=-1;
	if(ch(p1,p2))w=mx(p1,p2);
	if(ch(p1,q2))x=mx(p1,q2);
	if(ch(q1,p2))y=mx(q1,p2);
	if(ch(q1,q2))z=mx(q1,q2);
	n=mn(mn(w,x),mn(y,z));
	if(n==-1)
		printf("Poor Inna and pony!");
	else
		printf("%d",n);
}

#include <stdio.h>
int abs(int x)
{
if(x<0)
return -x;
else
return x;
}
int main()
{
int n,m,x,y,a,b,diff1,diff2,mov1,mov2,f=0,diff3,min=10000000,g;
scanf("%d %d %d %d %d %d",&n,&m,&x,&y,&a,&b);
//CORNER1
diff1=abs(x-1);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>=(a+1))
g=1;
else if(mov2>mov1 && (m-b)>=1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER2
diff1=abs(x-n);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && (n-a)>=1)
g=1;
else if(mov2>mov1 &&  m>=(1+b))
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER3
diff1=abs(x-n);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && (n-a)>=1)
g=1;
else if(mov2>mov1 && (m-b)>=1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER4
diff1=abs(x-1);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>=(1+a))
g=1;
else if(mov2>mov1 && m>=(1+b))
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
if(f==1)
printf("%d\n",min);
else
printf("Poor Inna and pony!\n");
return 0;
}

#include<stdio.h>
//Written By GHATAK...
int main()
{
	int n,m,i,j,a,b;
	scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
	int top,bottom,left,right,mintop,minbottom,minright,minleft;
	top=i-1;
	bottom=n-i;
	left=j-1;
	right=m-j;
	minright=right/b;
	minleft=left/b;
	mintop=top/a;
	minbottom=bottom/a;
	int t=0,min;
	if(i==1)
    {
        if(j==1)
        {
            printf("0");
            return 0;
        }
        if(j==m)
        {
            printf("0");
            return 0;
        }
    }
    if(i==n)
    {
        if(j==1)
        {
            printf("0");
            return 0;
        }
        if(j==m)
        {
            printf("0");
            return 0;
        }
    }
    if(((n==1)&&(a!=0))||((m==1)&&(b!=0)))
    {
        printf("Poor Inna and pony!");
        return 0;
    }
	if(b!=0)
	{
		if(a!=0)
		{
			if(((left%b==0)&&(left>=b))||((right%b==0)&&(right>=b)))
			{
				if(((top%a==0)&&(top>=a))||((bottom%a==0)&&(bottom>=a)))
				{
					if(right%b==0)
					{
						//bottom
						if(bottom%a==0)
						{

						if(minbottom==minright)
						{
							if(t==0)
							{
								min=minbottom;
								t++;
							}
							else
							{
								if(min>minbottom)
								{
									min=minbottom;
								}
							}
						}
						else
						{
							int k;
							k=abs(minbottom-minright);
							if(k%2==0)
							{
								if(t==0)
								{
									if(minbottom>minright)
									{
										min=minbottom;
									}
									else
									{
										min=minright;
									}
									t++;
								}
								else
								{
									if(minbottom>minright)
									{
										if(min>minbottom)
										{
											min=minbottom;
										}
									}
									else
									{
										if(min>minright)
										{
											min=minright;
										}
									}
								}
							}
						}
						}
						//top
						if(top%a==0)
						{
							if(mintop==minright)
						{
							if(t==0)
							{
								min=mintop;
								t++;
							}
							else
							{
								if(min>mintop)
								{
									min=mintop;
								}
							}
						}
						else
						{
							int k;
							k=abs(mintop-minright);
							if(k%2==0)
							{
								if(t==0)
								{
									if(mintop>minright)
									{
										min=mintop;
									}
									else
									{
										min=minright;
									}
									t++;
								}
								else
								{
									if(mintop>minright)
									{
										if(min>mintop)
										{
											min=mintop;
										}
									}
									else
									{
										if(min>minright)
										{
											min=minright;
										}
									}
								}
							}
						}

						}

					}

					if(left%b==0)
					{
						//bottom
						if(bottom%a==0)
						{

						if(minbottom==minleft)
						{
							if(t==0)
							{
								min=minbottom;
								t++;
							}
							else
							{
								if(min>minbottom)
								{
									min=minbottom;
								}
							}
						}
						else
						{
							int k;
							k=abs(minbottom-minleft);
							if(k%2==0)
							{
								if(t==0)
								{
									if(minbottom>minleft)
									{
										min=minbottom;
									}
									else
									{
										min=minleft;
									}
									t++;
								}
								else
								{
									if(minbottom>minleft)
									{
										if(min>minbottom)
										{
											min=minbottom;
										}
									}
									else
									{
										if(min>minleft)
										{
											min=minleft;
										}
									}
								}
							}
						}
						}
						//top
						if(top%a==0)
						{
							if(mintop==minleft)
						{
							if(t==0)
							{
								min=mintop;
								t++;
							}
							else
							{
								if(min>mintop)
								{
									min=mintop;
								}
							}
						}
						else
						{
							int k;
							k=abs(mintop-minleft);
							if(k%2==0)
							{
								if(t==0)
								{
									if(mintop>minleft)
									{
										min=mintop;
									}
									else
									{
										min=minleft;
									}
									t++;
								}
								else
								{
									if(mintop>minleft)
									{
										if(min>mintop)
										{
											min=mintop;
										}
									}
									else
									{
										if(min>minleft)
										{
											min=minleft;
										}
									}
								}
							}
						}

						}

					}

				}
			}
		}

		else
		{
			if((i==1)||(i==n))
			{
				if((left%b==0)&&(left>=b))
				{
					if(t==0)
					{
						min=minleft;
						t++;
					}
				}
				if((right%b==0)&&(right>=b))
				{
					if(t==0)
					{
						min=minright;
						t++;
					}
					else
					{
						if(min>minright)
						{
							min=minright;
						}
					}
				}
			}
		}
	}

	else
	{
		if(a!=0)
		{
			if((j==1)||(j==m))
			{
				if((top%a==0)&&(top>=a))
				{
					if(t==0)
					{
						min=mintop;
						t++;
					}
				}
				if((bottom%a==0)&&(bottom>=a))
				{
					if(t==0)
					{
						min=minbottom;
						t++;
					}
					else
					{
						if(min>minbottom)
						{
							min=minbottom;
						}
					}
				}
			}
		}
		else
		{
			if(((i==1)||(i==n))&&((j==1)||(j==m)))
			{
				min=0;
				t++;
			}
		}
	}
	if(t==0)
	{
		printf("Poor Inna and pony!");
	}
	else
	{
		printf("%d",min);
	}
	return 0;

}

#include <stdio.h>

#define INF 1000000
#define MAX 1010

int abs(int a)
{
    if (a < 0) return -a;
    return a;
}

int max (int a, int b)
{
    if (a<b) return b;
    return a;
}

int main()
{
    int n, m, i, j, a, b;

    scanf("%d %d %d %d %d %d", &n, &m, &i, &j, &a, &b);

    if (a > (n-i) || a > (i-1) || b > (m-j) || b > (j-1))
    {
        printf("Poor Inna and pony!\n");
        return 0;
    }

    int resp = -1;
    if ((n-i)%a == 0 && (m-j)%b == 0)
    {
        if ( abs((n-i)/a - (m-j)/b) % 2 == 0)
        {
            int aux = max((n-i)/a, (m-j)/b);
            resp = max(resp, aux);
            //printf("(+,+) %d\n", aux);
        }
    }

    if ((i-1)%a == 0 && (m-j)%b == 0)
    {
        if ( abs((i-1)/a - (m-j)/b) % 2 == 0)
        {
            int aux = max((i-1)/a, (m-j)/b);
            resp = max(resp, aux);
            //printf("(-,+) %d\n", aux);
        }
    }

    if ((n-i)%a == 0 && (j-1)%b == 0)
    {
        if ( abs((n-i)/a - (j-1)/b) % 2 == 0)
        {
            int aux = max((n-i)/a, (j-1)/b);
            resp = max(resp, aux);
            //printf("(+,-) %d\n", aux);
        }
    }

    if ((i-1)%a == 0 && (j-1)%b == 0)
    {
        if ( abs((i-1)/a - (j-1)/b) % 2 == 0)
        {
            int aux = max((i-1)/a, (j-1)/b);
            resp = max(resp, aux);
            //printf("(-,-) %d\n", aux);
        }
    }

    if (resp == -1) printf("Poor Inna and pony!\n");
    else printf("%d\n",resp);
    return 0;

}

#include <stdio.h>
#include <math.h>
int n,m;
in_bounce(int x,int y)
{
  if(x<=n&&x>=1&&y<=m&&y>=1) return 1;
  return 0;
}
main()
{
   int i,j,a,b,k,dir[4][2],nowdx,nowdy,min;
   while(~scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b))
   {
	   min=9999999;
       dir[0][0]=1;dir[0][1]=1;
	   dir[1][0]=1;dir[1][1]=m;
	   dir[2][0]=n;dir[2][1]=m;
	   dir[3][0]=n;dir[3][1]=1;
	   for(k=0;k<4;k++)
	   {
	     nowdx=abs(i-dir[k][0]);
		 nowdy=abs(j-dir[k][1]);
		 if(nowdx%a!=0||nowdy%b!=0) continue;
		 else
		  if(nowdx/a==nowdy/b&&min>nowdx/a) min=nowdx/a;
		  else if(nowdx/a>nowdy/b)
		  {if((nowdx/a-nowdy/b)%(2*a)==0&&(min>nowdy/b+(nowdx/a-nowdy/b)%a)&&(in_bounce(i-2*a,j)||in_bounce(i+2*a,j))) min=nowdy/b+(nowdx/a-nowdy/b)%a;}
		  else  if((nowdx/b-nowdy/a)%(2*b)==0&&(min>nowdx/a+(nowdx/b-nowdy/a)%b)&&(in_bounce(i,j-b*2)||in_bounce(i,j+b*2))) min=nowdx/a+(nowdx/b-nowdy/a)%b;
	   }
	   if(min==9999999) printf("Poor Inna and pony!\n");
	   else printf("%d\n",min);
   }
}

#include <stdio.h>
#include <stdlib.h>
/* Written by Nishant Mittal aka nishantwrp */
int main()
{
   int n,m,i,j,a,b;
   scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
   int min=-1;
   int checka,checkb;
   checka= abs(n-i);
   checkb = abs(m-j);
   if ((checka >=a && checkb >=b) || (i-1 >= a && j-1 >=b)) {
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(m-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(n-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
}
   if (min == -1) {
    printf("Poor Inna and pony!");
   } else {
   printf("%d",min);
   }
    return 0;
}

#include <stdio.h>

max (long int *pp,long int *pq){
	long int t;
	if ((*pp)<(*pq)){
		t=*pp;
		*pp=*pq;
		*pq=t;

	}

}
int main (){
	long int n,m,i,j,a,b,p,q;
	scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
	if (((n-i)%a==0) && ( (m-j)%b==0) )
{
	p=(n-i)/a;
	q=(m-j)/b;
	max(&p,&q);
	printf("p=%ld\n",p);
	printf("q=%ld\n",q);
	if ((p-q)%2==0){
		printf("%ld",p);
		return 0;
		}
		else {
			printf("Poor Inna and pony!\n");
			return 0;
		}
	}
else if (((n-i)%a==0) && ( (j-1)%b==0 ))
{
	p=(n-i)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (j-1)%b==0 ))
{
	p=(i-1)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (m-j)%b==0 ))
{
	p=(i-1)/a;
	q=(m-j)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

	else
	{
	printf("Poor Inna and pony!\n");

}
return 0;
}

#include<stdio.h>
long max(long x , long y){ return x>y?x:y; }
int main()
{
    long i,j,n,m,a,b,ans[4],min,f=0;
    long cint,dint;
    float c,d;
    scanf("%ld%ld%ld%ld%ld%ld",&n,&m,&i,&j,&a,&b);
    if(a>=n || b>=m)
    {
            printf("Poor Inna and pony!");
            return 0;
    }
    c=(i-1)*1.0/a;
    d=(j-1)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(n-i)*1.0/a;
    d=(j-1)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if((abs(cint-dint))%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(i-1)*1.0/a;
    d=(m-j)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    c=(n-i)*1.0/a;
    d=(m-j)*1.0/b;

    if(c==(long int)c && d==(long int)d)
    {
        cint=(long int)c;
        dint=(long int)d;
        if(abs(cint-dint)%2==0)
        ans[f++]=max(cint,dint);
    }

    if(f==0)
    {
            printf("Poor Inna and pony!");
            return 0;
    }
    min=1000000;
    for(i=0;i<f;i++)
    if(min>ans[i])
    min=ans[i];

    printf("%ld",min);
    return 0;
}

#include<stdio.h>
int main()
{
    long int i,j,k,l,a,b,n,m,k1,k2,k3,k4;
    scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
    k=1-i;l=1-j;
    k1=n-i;k2=1-j;
    k3=1-i;k4=m-j;
    n-=i;m-=j;

    if(n%a==0&&m%b==0&&n/a==m/b)
    {
        if(n/a<0)
        printf("%ld",-n/a);
        else
        printf("%ld",n/a);
    }
    else if(k%a==0&&l%b==0&&k/a==l/b)
    {
        if(k/a<0)
        printf("%ld",-k/a);
        else
        printf("%ld",k/a);
    }
    else if(k1%a==0&&k2%b==0&&k1/a==k2/b)
    {
        if(k1/a<0)
        printf("%ld",-k1/a);
        else
        printf("%ld",k1/a);
    }
    else if(k3%a==0&&k4%b==0&&k3/a==k4/b)
    {
        if(k3/a<0)
        printf("%ld",-k3/a);
        else
        printf("%ld",k3/a);
    }
    else
    printf("Poor Inna and pony!");
    return 0;

}

#include<stdio.h>
int main()
{
    long int i,j,k,l,a,b,n,m;
    scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
    k=i-1;l=j-1;
    n-=i;m-=j;
    if(n%a==0&&m%b==0&&n/a==m/b)
    {
        printf("%ld",n/a);
    }
    else if(k%a==0&&l%b==0&&k/a==l/b)
    {
        printf("%ld",k/a);
    }
    else
    printf("Poor Inna and pony!");
    return 0;

}

#include <stdio.h>
#include <stdlib.h>
/* Written by Nishant Mittal aka nishantwrp */
int main()
{
   int n,m,i,j,a,b;
   scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
   int min=-1;
   int checka,checkb;
   checka= abs(n-i);
   checkb = abs(m-j);

   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(1-i);
   checkb = abs(m-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }
   checka= abs(n-i);
   checkb = abs(1-j);
   if (checka%a==0 &&checkb%b == 0) {
    int x,y;
    x = checka/a;
    y = checkb/b;
    if (x%2 == y%2) {
        if (x>y) {
        if (min == -1 || min > x) {
            min = x;
        }
        } else {
        if (min == -1 || min > y) {
            min = y;
        }
        }
    }
   }

   if (min == -1) {
    printf("Poor Inna and pony!");
   } else if (min == 0) {
   printf("0");
   } else if  ((abs(n-i) >=a && abs(m-j) >=b) || (i-1 >= a && j-1 >=b)) {
   printf("%d",min);
   } else {
   printf("Poor Inna and pony!");
   }
    return 0;
}

#include <stdio.h>

#define INF 1000000
#define MAX 1010

int abs(int a)
{
    if (a < 0) return -a;
    return a;
}

int max (int a, int b)
{
    if (a<b) return b;
    return a;
}

int main()
{
    int n, m, i, j, a, b;

    scanf("%d %d %d %d %d %d", &n, &m, &i, &j, &a, &b);

    if ((a > (n-i) && a > (i-1)) || (b > (m-j) && b > (j-1)))
    {
        printf("Poor Inna and pony!\n");
        return 0;
    }

    int resp = -1;
    if ((n-i)%a == 0 && (m-j)%b == 0)
    {
        if ( abs((n-i)/a - (m-j)/b) % 2 == 0)
        {
            int aux = max((n-i)/a, (m-j)/b);
            resp = max(resp, aux);
            //printf("(+,+) %d\n", aux);
        }
    }

    if ((i-1)%a == 0 && (m-j)%b == 0)
    {
        if ( abs((i-1)/a - (m-j)/b) % 2 == 0)
        {
            int aux = max((i-1)/a, (m-j)/b);
            resp = max(resp, aux);
            //printf("(-,+) %d\n", aux);
        }
    }

    if ((n-i)%a == 0 && (j-1)%b == 0)
    {
        if ( abs((n-i)/a - (j-1)/b) % 2 == 0)
        {
            int aux = max((n-i)/a, (j-1)/b);
            resp = max(resp, aux);
            //printf("(+,-) %d\n", aux);
        }
    }

    if ((i-1)%a == 0 && (j-1)%b == 0)
    {
        if ( abs((i-1)/a - (j-1)/b) % 2 == 0)
        {
            int aux = max((i-1)/a, (j-1)/b);
            resp = max(resp, aux);
            //printf("(-,-) %d\n", aux);
        }
    }

    if (resp == -1) printf("Poor Inna and pony!\n");
    else printf("%d\n",resp);
    return 0;

}

#include<stdio.h>
int main()
{
    long int i,j,k,l,a,b,n,m;
    scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
    k=i-1;l=j-1;
    n-=i;m-=j;
    if(n%a==0&&m%b==0&&n/a==m/b)
    {
        if(n/a<0)
        printf("%ld",-n/a);
        else
        printf("%ld",n/a);
    }
    else if(k%a==0&&l%b==0&&k/a==l/b)
    {
        if(k/a<0)
        printf("%ld",-k/a);
        else
        printf("%ld",k/a);
    }
    else
    printf("Poor Inna and pony!");
    return 0;

}

#include<stdio.h>
long long int n,m,i,j,a,b;
int ab(int a)
{
	if(a<0)
	return -a;
	return a;
}
int max(int a,int b)
{
	if(a<b)
	return b;
	return a;
}
int min(int a,int b)
{
	if(a>b)
	return b;
	return a;
}
int func(int u,int v)
{
		if(i==u&&j==v)
		return 0;
		if(i+a>n&&i-a<=0)
		return -1;
		if(i+b>m&&i-b<=0)
		return -1;
		int x=ab(u-i),y=ab(v-j);
		if(x%a!=0||y%b!=0)
		return -1;
		x=x/a;y=y/b;
		if(x%2!=y%2)
		return -1;
		int t=max(x,y);
		return t;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&i,&j,&a,&b);
	int ans=100000000;
	int a=func(1,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(1,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	if(ans<100000000)
	printf("%d",ans);
	else
	printf("Poor Inna and pony!");
	return 0;
}

#include <stdio.h>
int abs(int x)
{
if(x<0)
return -x;
else
return x;
}
int main()
{
int n,m,x,y,a,b,diff1,diff2,mov1,mov2,f=0,diff3,min=10000000;
scanf("%d %d %d %d %d %d",&n,&m,&x,&y,&a,&b);
//CORNER1
diff1=abs(x-1);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3%2==0)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER2
diff1=abs(x-n);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3%2==0)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER3
diff1=abs(x-n);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3%2==0)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER4
diff1=abs(x-1);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3%2==0)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
if(f==1)
printf("%d\n",min);
else
printf("Poor Inna and pony!\n");
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int calc_moves(int, int, int, int, int, int);
int min(int, int);

int main(){

    int i, j, x, y, n, m, a, b;
    scanf("%d %d %d %d %d %d", &n, &m, &x, &y, &a, &b);

    int sol1 = calc_moves(x, y, 1, 1, a, b);
    int sol2 = calc_moves(x, y, 1, m, a, b);
    int sol3 = calc_moves(x, y, n, 1, a, b);
    int sol4 = calc_moves(x, y, n, m, a, b);

    printf("%d %d %d %d\n", sol1, sol2, sol3, sol4);

    if (sol1 == -1 && sol2 == -1 && sol3 == -1 && sol4 == -1) {
        printf("Poor Inna and pony!\n");
    }
    else {
        printf("%d\n", min(sol1, min(sol2, min(sol3, sol4))));
    }

#ifdef _AT_HOME_
    system("pause");
#endif

    return 0;
}

int calc_moves(int start_x, int start_y, int finish_x, int finish_y, int step_x, int step_y) {

    int dx = abs(start_x - finish_x);
    int dy = abs(start_y - finish_y);

    if (dx % step_x != 0 || dy % step_y != 0) {
        return -1;
    }

    int sx = dx / step_x;
    int sy = dy / step_y;

    if (abs(sx - sy) & 1) {
        return -1;
    }
    else {
        return (sx > sy)?sx:sy;
    }

}

int min(int a, int b) {
    return (a > b || a == -1)?b:a;
}

#include <stdio.h>

max (long int *pp,long int *pb){
	long int t;
	if ((*pp)<(*pb)){
		t=*pp;
		*pp=*pb;
		*pb=t;

	}

}
int main (){
	long int n,m,i,j,a,b,p,q;
	scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
	if (((n-i)%a==0) && ( (m-j)%b==0) )
{
	p=(n-i)/a;
	q=(m-j)/b;
	max(&p,&b);

	if ((p-q)%2==0){
		printf("%ld",p);
		}
		else {
			printf("Poor Inna and pony!\n");
		}
	}
else if (((n-i)%a==0) && ( (j-1)%b==0 ))
{
	p=(n-i)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (j-1)%b==0 ))
{
	p=(i-1)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (m-j)%b==0 ))
{
	p=(i-1)/a;
	q=(m-j)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

	else
	{
	printf("Poor Inna and pony!\n");

}
return 0;
}

#include<stdio.h>
#include<math.h>
int max(int a, int b)
{
	if(a>b)
	return a;
	return b;
}
int check1(int x, int y,int i, int j,int a,int b)
{
	if((abs(x-i)%a)==0 && (abs(y-j)%b)==0)
	return 1;
	return 0;
}
int check2(int x, int y, int i, int j,int a, int b)
{
	if((abs(x-i)/a)%2==0 && (abs(y-j)/b)%2==0)
	return 1;
	if((abs(x-i)/a)%2==1 && (abs(y-j)/b)%2==1)
	return 1;
	return 0;
}
int dist(int x,int y,int i, int j,int a, int b)
{
	return (max(abs(x-i)/a, abs(y-j)/b));
}
int main()
{
	int n,m,i,j,a,b;
	scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
	int A[4]={0};
	if(check1(1,1,i,j,a,b)==0 && (check1(1,m,i,j,a,b)==0) && check1(n,1,i,j,a,b)==0 && check1(n,m,i,j,a,b)==0)
	{
		printf("Poor Inna and pony!");
		return 0;
	}
	if(check2(1,1,i,j,a,b)==0 && (check2(1,m,i,j,a,b)==0) && check2(n,1,i,j,a,b)==0 && check2(n,m,i,j,a,b)==0)
	{
		printf("Poor Inna and pony!");
		return 0;
	}
	A[0]=dist(1,1,i,j,a,b);
	A[1]=dist(1,m,i,j,a,b);
	A[2]=dist(n,1,i,j,a,b);
	A[3]=dist(n,m,i,j,a,b);
	int min=A[0];
	for(i=1;i<=3;i++)
	{
		if(A[i]<min)
		min=A[i];
	}
	printf("%d",min);
	return 0;
}

#include <stdio.h>
#include <math.h>
int n,m;
in_bounce(int x,int y)
{
  if(x<=n&&x>=1&&y<=m&&y>=1) return 1;
  return 0;
}
main()
{
   int i,j,a,b,k,dir[4][2],nowdx,nowdy,min;
   while(~scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b))
   {
	   min=9999999;
       dir[0][0]=1;dir[0][1]=1;
	   dir[1][0]=1;dir[1][1]=m;
	   dir[2][0]=n;dir[2][1]=m;
	   dir[3][0]=n;dir[3][1]=1;
	   for(k=0;k<4;k++)
	   {
	     nowdx=abs(i-dir[k][0]);
		 nowdy=abs(j-dir[k][1]);
		 if(nowdx%a!=0||nowdy%b!=0) continue;
		 else
		  if(nowdx/a==nowdy/b&&min>nowdx/a) min=nowdx/a;
		  else if(nowdx/a>nowdy/b)
		  {if((nowdx/a-nowdy/b)%(2*a)==0&&(min>nowdy/b+(nowdx/a-nowdy/b)/a)&&(in_bounce(i-2*a,j)||in_bounce(i+2*a,j))) min=nowdy/b+(nowdx/a-nowdy/b)/a;}
		  else  if((nowdy/b-nowdx/a)%(2*b)==0&&(min>nowdx/a+(nowdy/b-nowdx/a)/b)&&(in_bounce(i,j-b*2)||in_bounce(i,j+b*2))) min=nowdx/a+(nowdy/b-nowdx/a)/b;
	   }
	   if(min==9999999) printf("Poor Inna and pony!\n");
	   else printf("%d\n",min);
   }
}

#include <stdio.h>
#include <string.h>
int mn(int a,int b){
	if(a==-1)return b;
	if(b==-1)return a;
	return a<b?a:b;
}
int ch(int a,int b){
	if(a==-1)return 0;
	if(b==-1)return 0;
	int c=a-b;
	if(c<0)c*=-1;
	return ((c%2)==0);
}
int mx(int a,int b){
	return a>b?a:b;
}
int main(){
	int n,m,i,j,a,b,p1,q1,p2,q2;
	int w,x,y,z;
	scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
	p1=q1=-1;
	if((n-i)%a==0)p1=(n-i)/a;
	if((i-1)%a==0)q1=(i-1)/a;
	p2=q2=-1;
	if((m-j)%b==0)p2=(m-j)/b;
	if((j-1)%b==0)q2=(j-1)/b;
	w=x=y=z=-1;
	if(ch(p1,p2))w=mx(p1,p2);
	if(ch(p1,q2))x=mx(p1,q2);
	if(ch(q1,p2))y=mx(q1,p2);
	if(ch(q1,q2))z=mx(q1,q2);
	n=mn(mn(w,x),mn(y,z));
	if(n==-1)
		printf("Poor Inna and pony!");
	else
		printf("%d",n);
}

#include<stdio.h>
#include<math.h>
int max(int a, int b)
{
	if(a>b)
	return a;
	return b;
}
int check1(int x, int y,int i, int j,int a,int b)
{
	if((abs(x-i)%a)==0 && (abs(y-j)%b)==0)
	return 1;
	return 0;
}
int check2(int x, int y, int i, int j,int a, int b)
{
	if((abs(x-i)/a)%2==0 && (abs(y-j)/b)%2==0)
	return 1;
	if((abs(x-i)/a)%2==1 && (abs(y-j)/b)%2==1)
	return 1;
	return 0;
}
int dist(int x,int y,int i, int j,int a, int b)
{
	return (max(abs(x-i)/a, abs(y-j)/b));
}
int main()
{
	int n,m,i,j,a,b;
	scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
	int A[4]={0};
	if(check1(1,1,i,j,a,b)==0 && (check1(1,m,i,j,a,b)==0) && check1(n,1,i,j,a,b)==0 && check1(n,m,i,j,a,b)==0)
	{
		printf("Poor Inna and pony!");
		return 0;
	}
	if(check2(1,1,i,j,a,b)==0 && (check2(1,m,i,j,a,b)==0) && check2(n,1,i,j,a,b)==0 && check2(n,m,i,j,a,b)==0)
	{
		printf("Poor Inna and pony!");
		return 0;
	}
	A[0]=dist(1,1,i,j,a,b);
	A[1]=dist(1,m,i,j,a,b);
	A[2]=dist(n,1,i,j,a,b);
	A[3]=dist(n,m,i,j,a,b);
	int max=A[0];
	for(i=1;i<=3;i++)
	{
		if(A[i]>max)
		max=A[i];
	}
	printf("%d",max);
	return 0;
}

#include <stdio.h>
int abs(int x)
{
if(x<0)
return -x;
else
return x;
}
int main()
{
int n,m,x,y,a,b,diff1,diff2,mov1,mov2,f=0,diff3,min=10000000,g;
scanf("%d %d %d %d %d %d",&n,&m,&x,&y,&a,&b);
//CORNER1
diff1=abs(x-1);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>1)
g=1;
else if(mov2>mov1 && m>1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER2
diff1=abs(x-n);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>1)
g=1;
else if(mov2>mov1 && m>1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER3
diff1=abs(x-n);
diff2=abs(y-m);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>1)
g=1;
else if(mov2>mov1 && m>1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
//CORNER4
diff1=abs(x-1);
diff2=abs(y-1);
if(diff1%a==0 && diff2%b==0)
{
g=0;
mov1=diff2/b;
mov2=diff1/a;
diff3=abs(mov1-mov2);
if(diff3==0)
g=1;
else if(mov1>mov2 && n>1)
g=1;
else if(mov2>mov1 && m>1)
g=1;
if(diff3%2==0 && g==1)
{
f=1;
if(mov1>=mov2 && min>mov1)
min=mov1;
else if(mov2>mov1 && min>mov2)
min=mov2;
}
}
if(f==1)
printf("%d\n",min);
else
printf("Poor Inna and pony!\n");
return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i,j,a,b;
    scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
    int right=m-j;
    int left=j-1;
    int top=i-1;
    int bottom=n-i;
    int t1=0,t2=0,t3=0,t4=0,m1,m2,m3,m4;
    if((((right%b)!=0)&&((left%b)!=0))||(((top%a)!=0)&&((bottom%a)!=0)))
    {
        printf("Poor Inna and pony!");
        return 0;
    }
    if(((right%b==0)&&((right/b)!=0))||((left%b==0)&&((left/b)!=0)))
    {
        if((right%b==0)&&((right/b)!=0))
        {
            int minright=right/b;
            int mintop,minleft,minbottom;
            if(((top%a)==0)&&((top/a)!=0))
            {
                mintop=top/a;
                if(mintop<minright)
                {
                    t1=0;
                }
                else if(mintop==minright)
                {
                    m1=minright;
                    t1=1;
                }
                else if(mintop>minright)
                {
                    int k;
                    k=mintop-minright;
                    if(k%2==0)
                    {
                        m1=mintop;
                        t1=1;
                    }
                    else
                    {
                        t1=0;
                    }
                }
            }
            if(((bottom%a)==0)&&((bottom/a)!=0))
            {
                minbottom=bottom/a;
                if(minbottom<minright)
                {
                    t2=0;
                }
                else if(minbottom==minright)
                {
                    m2=minright;
                    t2=1;
                }
                else if(minbottom>minright)
                {
                    int k;
                    k=minbottom-minright;
                    if(k%2==0)
                    {
                        m2=minbottom;
                        t2=1;
                    }
                    else
                    {
                        t2=0;
                    }
                }
            }

        }

            if((left%b==0)&&((left/b)!=0))
            {
                 int minleft=left/b;
                 int mintop,minbottom;
                 if(((top%a)==0)&&((top/a)!=0))
                 {
                      mintop=top/a;
                      if(mintop<minleft)
                      {
                         t3=0;
                      }
                      else if(mintop==minleft)
                      {
                         m3=minleft;
                         t2=1;
                      }
                      else if(mintop>minleft)
                      {
                          int k;
                          k=mintop-minleft;
                          if(k%2==0)
                          {
                              m3=mintop;
                              t2=1;
                          }
                          else
                          {
                               t1=0;
                          }
                       }
              }
               if(((bottom%a)==0)&&((bottom/a)!=0))
               {
                   minbottom=bottom/a;
                   if(minbottom<minleft)
                   {
                       t4=0;
                   }
                    else if(minbottom==minleft)
                   {
                       m4=minleft;
                       t4=1;
                   }
                    else if(minbottom>minleft)
                   {
                       int k;
                       k=minbottom-minleft;
                       if(k%2==0)
                       {
                          m4=minbottom;
                          t4=1;
                       }
                       else
                       {
                          t4=0;
                       }
                   }
               }
            }
     }
     if((t1==0)&&(t2==0)&&(t3==0)&&(t4==0))
     {
         printf("Poor Inna and pony!");
         return 0;
     }
     int min,p=0;
     if(t1==1)
     {
         if(p==0)
         {
             min=m1;
             p++;
         }
     }
     if(t2==1)
     {
         if(p==0)
         {
             min=m2;
             p++;
         }
         else
         {
             if(m2<min)
             {
                 min=m2;
             }
         }
     }
     if(t3==1)
     {
         if(p==0)
         {
             min=m3;
             p++;
         }
         else
         {
             if(m3<min)
             {
                 min=m3;
             }
         }
     }
     if(t4==1)
     {
         if(p==0)
         {
             min=m4;
             p++;
         }
         else
         {
             if(m4<min)
             {
                 min=m4;
             }
         }
     }
     printf("%d",min);
     return 0;
}

#include<stdio.h>

int max(int a,int b)
{
    return a>b?a:b;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int n,m,i,j,a,b,ans=-1,x,y,an,flag=0;
    scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
    x=i-1;y=j-1;
    if(((i-1)>a || (n-i)>a) && ((j-1)>b || (m-j)>b))
        flag=1;

    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=i-1;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=j-1;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    if(ans==-1 || (ans!=0 && flag==0)) printf("Poor Inna and pony!");
    else printf("%d",ans);
    return 0;
}

#include <stdio.h>
#include <string.h>
int mn(int a,int b){
	if(a==-1)return b;
	if(b==-1)return a;
	return a<b?a:b;
}
int ch(int a,int b){
	if(a==-1)return 0;
	if(b==-1)return 0;
	int c=a-b;
	if(c<0)c*=-1;
	return ((c%2)==0);
}
int mx(int a,int b){
	return a>b?a:b;
}
int main(){
	int n,m,i,j,a,b,p1,q1,p2,q2;
	int w,x,y,z;
	scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
	if((i==1||i==n)&&(j==1||j==m)){
		printf("0");return 0;
	}
	if((i+a>n)&&(i-a<1)||(j+b>m)&&(j-b<1)){
		printf("Poor Inna and pony!");
		return 0;
	}
	p1=q1=-1;
	if((n-i)%a==0)p1=(n-i)/a;
	if((i-1)%a==0)q1=(i-1)/a;
	p2=q2=-1;
	if((m-j)%b==0)p2=(m-j)/b;
	if((j-1)%b==0)q2=(j-1)/b;
	w=x=y=z=-1;
	if(ch(p1,p2))w=mx(p1,p2);
	if(ch(p1,q2))x=mx(p1,q2);
	if(ch(q1,p2))y=mx(q1,p2);
	if(ch(q1,q2))z=mx(q1,q2);
	n=mn(mn(w,x),mn(y,z));
	printf("%d %d %d %d ",p1,p2,q1,q2);
	if(n==-1)
		printf("Poor Inna and pony!");
	else
		printf("%d",n);
}

#include<stdio.h>
#define INF 1000000009
int max(int x,int y){
    if(x>y){
        return x;
    }
    return y;
}
int min(int x, int y){
    if(x>y){
        return y;
    }
    return x;
}
int main(){
    int n,m,i,j,a,b,cnt1=INF,cnt2=INF,cnt3=INF,cnt4=INF;
    int ans1=INF,ans2=INF,ans3=INF,ans4=INF,s,t,ret;
    scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
    if((i-1)%a!=0){
        if((n-i)%a!=0){
            if((j-1)%b!=0){
                if((m-j)%b!=0){
                    printf("Poor Inna and pony!\n");
                    return 0;
                }
            }
        }
    }
    if((i-1)%a==0){
        cnt1=(i-1)/a;
    }
    if((n-i)%a==0){
        cnt2=(n-i)/a;
    }
    if((j-1)%b==0){
        cnt3=(j-1)/b;
    }
    if((m-j)%b==0){
        cnt4=(m-j)/b;
    }
    if((cnt1-cnt3)%2==0 && cnt1!=INF && cnt3!=INF){
        ans1=max(cnt1,cnt3);
    }
    if((cnt1-cnt4)%2==0 && cnt1!=INF && cnt4!=INF){
        ans2=max(cnt1,cnt4);
    }
    if((cnt2-cnt3)%2==0 && cnt2!=INF && cnt3!=INF){
        ans3=max(cnt2,cnt3);
    }
    if((cnt2-cnt4)%2==0 && cnt2!=INF && cnt4!=INF){
        ans4=max(cnt2,cnt4);
    }
    if(ans1==INF && ans2==INF && ans3==INF && ans4==INF){
        printf("Poor Inna and pony!\n");
        return 0;
    }
    s=min(ans1,ans2);
    t=min(ans3,ans4);
    ret=min(s,t);
    printf("%d\n",ret);
    return 0;
}