Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.

Dima put the chessboard in front of Inna and placed the candy in position (i, j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:

  move the candy from position (x, y) on the board to position (x - a, y - b);  move the candy from position (x, y) on the board to position (x + a, y - b);  move the candy from position (x, y) on the board to position (x - a, y + b);  move the candy from position (x, y) on the board to position (x + a, y + b). 

Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.

Inna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i, j) to one of the chessboard corners. Help them cope with the task! 


-----Input-----

The first line of the input contains six integers n, m, i, j, a, b (1 ≤ n, m ≤ 10^6; 1 ≤ i ≤ n; 1 ≤ j ≤ m; 1 ≤ a, b ≤ 10^6).

You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right. Position (i, j) in the statement is a chessboard cell on the intersection of the i-th row and the j-th column. You can consider that the corners are: (1, m), (n, 1), (n, m), (1, 1).


-----Output-----

In a single line print a single integer — the minimum number of moves needed to get the candy.

If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes.


-----Examples-----
Input
5 7 1 3 2 2

Output
2

Input
5 5 2 3 1 1

Output
Poor Inna and pony!



-----Note-----

Note to sample 1:

Inna and the pony can move the candy to position (1 + 2, 3 + 2) = (3, 5), from there they can move it to positions (3 - 2, 5 + 2) = (1, 7) and (3 + 2, 5 + 2) = (5, 7). These positions correspond to the corner squares of the chess board. Thus, the answer to the test sample equals two.

Difficulty: interview

Starter code:

Solutions:
n,m,i,j,a,b=list(map(int,input().split()))

ans=100000000000

if((i,j)==(n,1) or (i,j)==(1,1) or (i,j)==(1,m) or (i,j)==(n,m)):
    print(0)

else:
    #Corner (1,1)

    hor=i-1
    ver=j-1

    if(hor%a==0 and ver%b==0):
        x=hor//a
        y=ver//b
        if(x%2==y%2 and a<=n-1 and b<=m-1):
            ans=min(ans,max(x,y))

    #Corner (n,m)

    hor=abs(i-n)
    ver=abs(j-m)

    if(hor%a==0 and ver%b==0):
        x=hor//a
        y=ver//b
        if(x%2==y%2 and a<=n-1 and b<=m-1):
            ans=min(ans,max(x,y))

    #Corner (1,m)

    hor=i-1
    ver=abs(j-m)

    if(hor%a==0 and ver%b==0):
        x=hor//a
        y=ver//b
        if(x%2==y%2 and a<=n-1 and b<=m-1):
            ans=min(ans,max(x,y))

    #Corner (n,1)

    hor=abs(n-i)
    ver=j-1

    if(hor%a==0 and ver%b==0):
        x=hor//a
        y=ver//b
        if(x%2==y%2 and a<=n-1 and b<=m-1):
            ans=min(ans,max(x,y))
    if(ans!=100000000000):
        print(ans)
    else:
        print("Poor Inna and pony!")
        


3

def readln(): return list(map(int, input().split()))

n, m, i, j, a, b = readln()

def solve(w, h):
    if w == 0 and h == 0:
        return 0
    if w == 0 and a < n and h % 2 == 0:
        return h
    if h == 0 and b < m and w % 2 == 0:
        return w
    if w == 0 or h == 0:
        return 1 << 30
    if (w + h) % 2 == 0:
        return max(w, h)
    return 1 << 30

ans = min([1 << 30] + [solve(abs(i - p) // a, abs(j - q) // b) for p, q in ((1, 1), (1, m), (n, 1), (n, m)) if abs(i - p) % a == 0 and abs(j - q) % b == 0])
print('Poor Inna and pony!' if ans == 2**30 else ans)


n, m, i, j, a, b = map(int, input().split())
Good = lambda i, a, n, d: None if abs(i-d)%a != 0 else (abs(i-d)//a%2 if abs(i-d)//a >= 1 else (0 if i+a <= n or i-a >= 1 else -1))
res = None
xx, yy = [1, n], [1, m]
for dx in xx:
    for dy in yy:
        tx, ty = Good(i, a, n, dx), Good(j, b, m, dy)
        if tx is None or ty is None:
            continue
        if tx == -1 or ty == -1:
            if (tx == -1 and abs(j-dy)//b == 0) or (ty == -1 and abs(i-dx)//a == 0):
                res = 0
            continue
        if tx != ty:
            continue
        new_res = max(abs(i-dx)//a, abs(j-dy)//b)
        res = new_res if res is None or res > new_res else res
print('Poor Inna and pony!' if res is None else res)

def num_steps(x, y):
    if i == x and j == y:
        return 0
    
    dx = abs(j-y)
    dy = abs(i-x)

    if (dy == 0 and i-a < 1 and i+a > n) or (dx == 0 and j-b < 1 and j+b > m):
        return -1

    if dy % a != 0 or dx % b != 0:
        return -1

    ny = dy // a
    nx = dx // b

    if nx % 2 != ny % 2:
        return -1

    return max(nx, ny)

n, m, i, j, a, b = map(int, input().split())
cand = list(filter(lambda x: x >= 0, (num_steps(1, 1), num_steps(n, 1), num_steps(1, m), num_steps(n, m))))

if not cand:
    print("Poor Inna and pony!")
else:
    print(min(cand))

n, m, i, j, a, b = map(int, input().split())
x, y, t = [i - 1, n - i], [j - 1, m - j], []
if all(i < a for i in x) or all(j < b for j in y):
    if 0 in x and 0 in y: t = [0]
else:
    u = [d // a for d in x if d % a == 0]
    v = [d // b for d in y if d % b == 0]
    t = [max(i, j) for i in u for j in v if (i + j) % 2 == 0]
print(min(t) if t else 'Poor Inna and pony!')

inf = 1000 * 1000 * 1000
def calc(x, y):
	if(x % a != 0 or y % b != 0):
		return inf
	s = x / a + y / b
	if(s % 2 == 1):
		return inf
	return max(x / a, y / b)
n, m, x, y, a, b = map(int, input().split())
if(x == 1 and y == 1 or x == 1 and y == m or x == n and y == 1 or x == n and y == m):
	print(0)
	return
if(x - a <= 0 and x + a > n or y + b > m and y - b <= 0):
	print('Poor Inna and pony!')
	return	
ans = calc(x-1, y-1)
ans = min(ans, calc(x-1, m-y))
ans = min(ans, calc(n-x, y-1))
ans = min(ans, calc(n-x, m-y))
ans = int(ans)
print(ans if ans != inf else 'Poor Inna and pony!')

import sys

def solve():
    n, m, i, j, a, b = map(int, input().split())
    i -= 1
    j -= 1
    n -= 1
    m -= 1
    if (i == 0 or i == n) and (j == 0 or j == m): return 0
    # print(i, j)
    if (i - a < 0 and i + a > n) or (j - b < 0 and j + b > m): return "Poor Inna and pony!"
    uprow = i
    downrows = n - i
    leftcol = j
    rightcol = m - j
    # print(uprow, downrows, leftcol, rightcol)
    ans = 10000000000
    if uprow % a == 0 and leftcol % b == 0 and abs(uprow//a - leftcol//b) % 2 == 0: #upperleft
        ans = min(ans, max(uprow//a,leftcol//b))
    if uprow % a == 0 and rightcol % b == 0 and abs(uprow//a - rightcol//b) % 2 == 0: #upperright
        ans = min(ans, max(uprow//a,rightcol//b))
    if downrows % a == 0 and leftcol % b == 0 and abs(downrows//a - leftcol//b) % 2 == 0: #lowerleft
        ans = min(ans, max(downrows//a ,leftcol//b))
    if downrows % a == 0 and rightcol % b == 0 and abs(downrows//a - rightcol//b) % 2 == 0: #lowerright
        ans = min(ans, max(downrows//a , rightcol//b))

    return ans if ans != 10000000000 else "Poor Inna and pony!"



if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
print(solve())

n, m, i, j, a, b = list(map(int, input().split()))
def f(x, y):
    dx, dy = abs(x - i), abs(y - j)
    if dx % a or dy % b:
        return -1
    elif dx // a % 2 != dy // b % 2:
        return -1
    elif dx == 0 and dy == 0:
        return 0
    elif (i - a < 1 and i + a > n) or (j - b < 1 and j + b > m):
        return -1
    else:
        return max(dx // a, dy // b)
v = -1
for p in ((1, m), (n, 1), (n, m), (1, 1)):
    c = f(*p)
    if c != -1 and (v == -1 or c < v):
        v = c
print(v if v != -1 else 'Poor Inna and pony!')


from sys import setrecursionlimit, exit
from math import ceil, floor, acos, pi
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce
import itertools
setrecursionlimit(10**7)
RI=lambda x=' ': list(map(int,input().split(x)))
RS=lambda x=' ': input().rstrip().split(x)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
mod=int(1e9+7)
eps=1e-6
MAX=1e9
#################################################
n, m, i, j, a, b = RI()
min_val=MAX
if (i,j)==(1,1) or (i,j)==(1,m) or (i,j)==(n,1) or (i,j)==(n,m):
    print(0)
else:
    if (n-i)%a==0 and (m-j)%b==0 and  ((n-i)//a - (m-j)//b)%2==0 and a<=n-1 and b<=m-1:
        min_val=min(min_val, max((n-i)//a,(m-j)//b))
    if (i-1)%a==0 and (m-j)%b==0 and  ((i-1)//a - (m-j)//b)%2==0 and a<=n-1 and b<=m-1:
        min_val=min(min_val, max((i-1)//a,(m-j)//b))
    if (n-i)%a==0 and (j-1)%b==0 and  ((n-i)//a - (j-1)//b)%2==0 and a<=n-1 and b<=m-1:
        min_val=min(min_val, max((n-i)//a,(j-1)//b))
    if (i-1)%a==0 and (j-1)%b==0 and  ((i-1)//a - (j-1)//b)%2==0 and a<=n-1 and b<=m-1:
        min_val=min(min_val, max((i-1)//a,(j-1)//b))
    if min_val==MAX:
        print("Poor Inna and pony!")
    else:
        print(min_val)


n, m, i, j, a, b = list(map(int, input().split()))
p = [(1, m), (n, 1), (n, m), (1, 1)]
c = 0
mn = 1e9
fnd = False
for c in range(4):
    if abs(p[c][0] - i) % a == 0 and abs(p[c][1] - j) % b == 0 and ((p[c][0] - i) / a + (p[c][1] - j) / b) % 2 == 0:
        a1 = abs(p[c][0] - i) / a
        b1 = abs(p[c][1] - j) / b
        if (1 <= i - a or i + a <= n or max(a1, b1) == 0)and(1 <= j - b or j + b <= m or max(a1, b1) == 0) :
            mn = min(mn, int(max(a1, b1)))
            fnd = True
if fnd:
    print(mn)
else:
    print('Poor Inna and pony!')


n, m, i, j, a, b = map(int, input().split())
x, y, t = [i - 1, n - i], [j - 1, m - j], []
if all(i < a for i in x) or all(j < b for j in y):
    if 0 in x and 0 in y: t = [0]
else:
    u = [d // a for d in x if d % a == 0]
    v = [d // b for d in y if d % b == 0]
    t = [max(i, j) for i in u for j in v if (i + j) % 2 == 0]
print(min(t) if t else 'Poor Inna and pony!')

def main():
    (n, m, x, y, a, b) = list(map(int, input().split(' ')))
    mi = int(1e9)
    for x2, y2 in [(1, m), (n, 1), (n, m), (1, 1)]:
        if x == x2 and y == y2:
            return 0
        if abs(x2 - x) % a != 0 or abs(y2 - y) % b != 0:
            continue
        o = abs(x2 - x) // a
        p = abs(y2 - y) // b
        if not o % 2 == p % 2:
            continue
        mi = min(mi, max(o, p))
    if int(mi) == int(1e9) or n <= a or m <= b:
        return "Poor Inna and pony!"
    return int(mi)
print(main())


lst = list(map(int, input().strip().split()))
n = lst[0]
m = lst[1]
corners = [[1, 1], [1, m], [n, m], [n, 1]]
point = [lst[2], lst[3]]
a = lst[4]
b = lst[5]
corners2 = []
for corner in corners:
    if (corner[0] - point[0]) % a == 0 and (corner[1] - point[1]) % b == 0 and corner not in corners2:
        corners2.append(corner)
corners.clear()

#print(corners2)

if not corners2:
    print("Poor Inna and pony!")
else:
    for i in range(len(corners2)):
        corner = corners2[i]
        if point in corners2:
            corners.append(0)
        else:
            move1 = abs(corner[0] - point[0]) // a
            move2 = abs(corner[1] - point[1]) // b
            if (move1 - move2) % 2 == 0 and (point[0] + a in range(1, n+1) or point[0] - a  in range(1, n+1)) and (point[1] + b in range(1, m+1) or point[1] - b in range(1, m+1)):
                corners.append(max(move1, move2))
            #print(move1, move2)
    if not corners:
        print("Poor Inna and pony!")
    else:
        print(min(corners))

# Made By Mostafa_Khaled 
bot = True 
n, m, i, j, a, b = list(map(int, input().split()))

x, y, t = [i - 1, n - i], [j - 1, m - j], []

if all(i < a for i in x) or all(j < b for j in y):

    if 0 in x and 0 in y: t = [0]

else:

    u = [d // a for d in x if d % a == 0]

    v = [d // b for d in y if d % b == 0]

    t = [max(i, j) for i in u for j in v if (i + j) % 2 == 0]

print(min(t) if t else 'Poor Inna and pony!')

# Made By Mostafa_Khaled


n, m, i, j, a, b = list(map(int, input().split()))

def solve(x, y):
    dx, dy = abs(x - i), abs(y - j)
    if dx % a or dy % b:
        return -1
    elif dx // a % 2 != dy // b % 2:
        return -1
    elif dx == 0 and dy == 0:
        return 0
    elif (i - a < 1 and i + a > n) or (j - b < 1 and j + b > m):
        return -1
    else:
        return max(dx // a, dy // b)

res = -1
for k in ((1, m), (n, 1), (n, m), (1, 1)):
    curr = solve(k[0], k[1])
    if curr != -1 and (res == -1 or curr < res):
        res = curr
print(res if res != -1 else 'Poor Inna and pony!')


n,m,i,j,a,b = list(map(int,input().split()))

path1=path2=path3=path4=10000000000

temp1 =temp2=temp3=temp4=0
if int((i-1)/a) == (i-1)/a and int((j-1)/b) == (j-1)/b:


    path1 = (i-1)/a
    path_1 = (j-1)/b
    # print(path1,path_1)
    if path1%2 == 0 and path_1%2 == 0 :
        path1 = max(path1,path_1)
        temp1 = 1
    elif path1%2 != 0 and path_1%2 !=0 :
        path1 = max(path1,path_1)
        temp1 = 1

    else:
        path1 = 100000000000
        temp1 = 0

if int((i-1)/a) == (i-1)/a and int((m-j)/b) == (m-j)/b:
    temp = 1
    path2 = (i-1)/a
    path_2 = (m-j)/b
    if path2%2 == 0 and path_2%2 ==0 :
        path2 = max(path2,path_2)
        temp2 = 1
    elif path2%2 != 0 and path_2%2 !=0 :
        path2 = max(path2,path_2)
        temp2 = 1

    else:
        path2 = 100000000000
        temp2 = 0



if int((n-i)/a) == (n-i)/a and int((j-1)/b) == (j-1)/b:
    temp = 1
    path3 = (n-i)/a
    path_3 = (j-1)/b
    if path3%2 == 0 and path_3%2 ==0 :
        path3 = max(path3,path_3)
        temp3 = 1

    elif path3%2 != 0 and path_3%2 !=0 :
        path3 = max(path3,path_3)
        temp3 = 1

    else:
        path3 = 10000000000000
        temp3 = 0

if int((n-i)/a) == (n-i)/a and int((m-j)/b) == (m-j)/b:
    temp = 1
    path4 = (n-i)/a
    path_4 = (m-j)/b
    if path4%2 == 0 and path_4%2 ==0 :
        path4 = max(path4,path_4)
        temp4 = 1
    elif path4%2 != 0 and path_4%2 !=0 :
        path4 = max(path4,path_4)
        temp4 = 1
    else:
        path4 = 1900000000000
        temp4 = 0

mini = min(path1,path2,path3,path4)
if ((i + a > n and i - a < 1) or (j+b > m and j-b < 1)) and mini!=0:
    print("Poor Inna and pony!")

elif temp1==0 and temp2==0 and temp3==0 and temp4==0:
    print("Poor Inna and pony!")
else:
    print(int(min(path1,path2,path3,path4)))


bot = True 
n, m, i, j, a, b = map(int, input().split())

x, y, t = [i - 1, n - i], [j - 1, m - j], []

if all(i < a for i in x) or all(j < b for j in y):

    if 0 in x and 0 in y: t = [0]

else:

    u = [d // a for d in x if d % a == 0]

    v = [d // b for d in y if d % b == 0]

    t = [max(i, j) for i in u for j in v if (i + j) % 2 == 0]

print(min(t) if t else 'Poor Inna and pony!')

n,m,i,j,a,b=map(int,input().split())
ans=n*m+1
if (i-1)%a==0 and (m-j)%b==0:
    x=min( (i-1)//a,(m-j)//b)
    y=max( (i-1)//a,(m-j)//b)
    if (y-x)%2==0:
        if (y-x)==0 or ( ((i-a)>=1 or(i+a)<=n) and ((j+b)<=m or (j-b)>=1) ):
            ans=min(ans,x+(y-x))
if (n-i)%a==0 and (j-1)%b==0:
    x=min( (n-i)//a,(j-1)//b)
    y=max( (n-i)//a,(j-1)//b)
    if (y-x)%2==0:
        if (y-x)==0 or ( ((i-a)>=1 or(i+a)<=n) and ((j+b)<=m or (j-b)>=1) ):
            ans=min(ans,x+(y-x))
if (i-1)%a==0 and (j-1)%b==0:
    x=min( (i-1)//a,(j-1)//b)
    y=max( (i-1)//a,(j-1)//b)
    if (y-x)%2==0:
        if (y-x)==0 or ( ((i-a)>=1 or(i+a)<=n) and ((j+b)<=m or (j-b)>=1) ):
            ans=min(ans,x+(y-x))
if (n-i)%a==0 and (m-j)%b==0:
    x=min( (n-i)//a,(m-j)//b)
    y=max( (n-i)//a,(m-j)//b)
    if (y-x)%2==0 :
        if (y-x)==0 or ( ((i-a)>=1 or(i+a)<=n) and ((j+b)<=m or (j-b)>=1) ):
            ans=min(ans,x+(y-x))
if ans!=(n*m+1):
    print(ans)
else :
    print("Poor Inna and pony!")

n,m,i,j,a,b=list(map(int,input().split()))
l=[]
if (i-1)%a==0 and (j-1)%b==0:
    s1=(i-1)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i-1)%a==0 and (m-j)%b==0:
    s1=(i-1)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (j-1)%b==0:
    s1=(n-i)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (m-j)%b==0:
    s1=(n-i)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i,j)==(0,0) or (i,j)==(n,m) or (i,j)==(n,1) or (i,j)==(1,m):print(0)
elif i+a>n and i-a<1:print( "Poor Inna and pony!")
elif j+b>m and j-b<1:print( "Poor Inna and pony!")
elif len(l)==0:print( "Poor Inna and pony!")
else:print(min(l))


n,m,i,j,a,b=map(int,input().split())
l=[]
if (i-1)%a==0 and (j-1)%b==0:
    s1=(i-1)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i-1)%a==0 and (m-j)%b==0:
    s1=(i-1)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (j-1)%b==0:
    s1=(n-i)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (m-j)%b==0:
    s1=(n-i)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i,j)==(0,0) or (i,j)==(n,m) or (i,j)==(n,1) or (i,j)==(1,m):print(0)
elif i+a>n and i-a<1:print( "Poor Inna and pony!")
elif j+b>m and j-b<1:print( "Poor Inna and pony!")
elif len(l)==0:print( "Poor Inna and pony!")
else:print(min(l))

n, m, i, j, a, b = map(int, input().split())
x, y, t = [i - 1, n - i], [j - 1, m - j], []
if all(i < a for i in x) or all(j < b for j in y):
    if 0 in x and 0 in y: t = [0]
else:
    u = [d // a for d in x if d % a == 0]
    v = [d // b for d in y if d % b == 0]
    t = [max(i, j) for i in u for j in v if (i + j) % 2 == 0]
print(min(t) if t else 'Poor Inna and pony!')

n,m,i,j,a,b=map(int,input().split())
l=[]
if (i-1)%a==0 and (j-1)%b==0:
    s1=(i-1)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i-1)%a==0 and (m-j)%b==0:
    s1=(i-1)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (j-1)%b==0:
    s1=(n-i)//a
    s2=(j-1)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (n-i)%a==0 and (m-j)%b==0:
    s1=(n-i)//a
    s2=(m-j)//b
    if (s1+s2)%2==0:l.append(max(s1,s2))
if (i,j)==(0,0) or (i,j)==(n,m) or (i,j)==(n,1) or (i,j)==(1,m):print(0)
elif i+a>n and i-a<1:print( "Poor Inna and pony!")
elif j+b>m and j-b<1:print( "Poor Inna and pony!")
elif len(l)==0:print( "Poor Inna and pony!")
else:print(min(l))

n, m, i, j, a, b = map(int, input().split())
corners = [(1, 1), (1, m), (n, 1), (n, m)]
result = False
ans = -1
for cnt in corners:
    if (abs(cnt[0] - i) % a == 0) and (abs(cnt[1] - j) % b == 0):
        result = True
        t1, t2 = abs(cnt[0] - i) // a, abs(cnt[1] - j) // b
        if (t1 + t2) % 2 == 0:
            if ans == -1:
                ans = max(abs(cnt[0] - i) // a, abs(cnt[1] - j) // b)
            else:
                ans = min(max(abs(cnt[0] - i) // a, abs(cnt[1] - j) // b), ans)
if ans == 0:
    print(ans)
elif not result or (i+a > n and i-a < 1) or (j+b > m and j-b < 1) or ans == -1:
    print("Poor Inna and pony!")
else:
    print(ans)

#import math
#n, m = input().split()
#n = int (n)
#m = int (m)
#n, m, k= input().split()
#n = int (n)
#m = int (m)
#k = int (k)
#l = int(l)
#m = int(input())
#s = input()
##t = input()
#a = list(map(char, input().split()))
#a.append('.')
#print(l)
#a = list(map(int, input().split()))
#c = sorted(c)
#x1, y1, x2, y2 =map(int,input().split())
#n = int(input())
#f = []
#t = [0]*n
#f = [(int(s1[0]),s1[1]), (int(s2[0]),s2[1]), (int(s3[0]), s3[1])]
#f1 = sorted(t, key = lambda tup: tup[0])
x1, y1, x3, y3, x2, y2 = input().split()
x1 = int(x1)
x2 = int(x2)
x3 = int(x3)
y1 = int(y1)
y2 = int(y2)
y3 = int(y3)
mi =  x1*y1
if((x3-1) % x2 == 0 and (y3-1) % y2 == 0 and ((x3-1) / x2) %2 == ((y3-1)/ y2)%2):
    mi = min(mi, max((x3-1)/x2,(y3-1)/y2))  
if((x3-1) % x2 == 0 and (y1-y3) % y2 == 0 and ((x3-1) / x2) %2 == ((y1-y3)/ y2)%2):
    mi = min(mi, max((x3-1)/x2,(y1-y3)/y2))  
if((x1-x3) % x2 == 0 and (y3-1) % y2 == 0 and ((x1-x3) / x2) % 2 == ((y3-1)/ y2)%2):
    mi = min(mi, max((x1-x3)/x2,(y3-1)/y2)) 
if((x1-x3) % x2 == 0 and (y1-y3) % y2 == 0 and ((x1-x3) / x2)%2 == ((y1-y3)/ y2)%2):
    mi = min(mi, max((x1-x3)/x2,(y1-y3)/y2))   
if (mi == x1*y1 or ( (x2 >= x3 and x2 > x1-x3)  and mi != 0)or ((y2 >= y3 and y2 > y1-y3)  and mi != 0)):
    print("Poor Inna and pony!")
else:
    print(int(mi))