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: HARD

Solutions:
def fun(x, y):
	if abs(x - i) % a == 0 and abs(y - j) % b == 0 and ((abs(x - i) // a - abs(y - j) // b) % 2 == 0):
		return max(abs(x - i) // a, abs(y - j) // b)
	return 1000000000
(n, m, i, j, a, b) = map(int, input().split())
ans = min(fun(1, 1), fun(n, m), fun(1, m), fun(n, 1))
if ans > 0 and (n <= a or m <= b):
	print('Poor Inna and pony!')
elif ans == 1000000000:
	print('Poor Inna and pony!')
else:
	print(ans)


(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))


import sys
input = sys.stdin.readline
(n, m, i, j, a, b) = map(int, input().split())
MIN = 10 ** 18

def calc(u, v):
	global MIN
	if (u - i) % a == 0 and (v - j) % b == 0:
		x = abs(u - i) // a
		y = abs(v - j) // b
		if x % 2 == y % 2 and 1 + a <= n and (1 + b <= m):
			MIN = min(MIN, max(x, y))
		if x == y == 0:
			MIN = 0
calc(1, 1)
calc(1, m)
calc(n, 1)
calc(n, m)
if MIN == 10 ** 18:
	print('Poor Inna and pony!')
else:
	print(MIN)


(n, m, i, j, a, b) = 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:
	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))
	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))
	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))
	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!')


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) = (0, 0, 0, 0, 0, 0)
inf = 1000000000

def check(x, y):
	if x == i and y == j:
		return 0
	if i - a < 1 and i + a > n:
		return inf
	if j - b < 1 and j + b > m:
		return inf
	if abs(x - i) % a != 0:
		return inf
	if abs(y - j) % b != 0:
		return inf
	cost = 0
	cost = max(abs(x - i) // a, abs(y - j) // b)
	tmp = abs(x - i) // a + abs(y - j) // b
	if tmp & 1:
		return inf
	return cost

def solve():
	ans = inf
	ans = min(check(1, m), check(n, 1))
	ans = min(ans, min(check(n, m), check(1, 1)))
	if ans == inf:
		return 'Poor Inna and pony!'
	else:
		return ans
(n, m, i, j, a, b) = map(int, input().split())
print(solve())


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()
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))
	if not corners:
		print('Poor Inna and pony!')
	else:
		print(min(corners))


(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))


def inna_and_pink_pony(n_int, m_int, i_int, j_int, a_int, b_int) -> str:
	corner_1 = (1, 1)
	corner_2 = (1, m_int)
	corner_3 = (n_int, 1)
	corner_4 = (n_int, m_int)
	corners = [corner_1, corner_2, corner_3, corner_4]
	c = max(n_int, m_int)
	for each in corners:
		if abs(each[0] - i_int) % a_int != 0 or abs(each[1] - j_int) % b_int != 0:
			continue
		horizontal_moves = abs(each[0] - i_int) // a_int
		vertical_moves = abs(each[1] - j_int) // b_int
		if horizontal_moves % 2 != vertical_moves % 2:
			continue
		each_move = max(horizontal_moves, vertical_moves)
		if a_int > max(i_int - 1, n_int - i) and abs(each[1] - j_int) > 0 or (b_int > max(j - 1, m - j) and abs(each[0] - i_int) > 0):
			break
		c = min(c, each_move)
	if c < max(n_int, m_int):
		return c
	else:
		return 'Poor Inna and pony!'
(n, m, i, j, a, b) = list(map(int, input().split()))
print(inna_and_pink_pony(n, m, i, j, a, b))


(n, m, i, j, a, b) = map(int, input().split())
cor = [[1, 1], [1, m], [n, 1], [n, m]]
flag = 0
dis = 100000001
for k in cor:
	x1 = abs(k[0] - i)
	y1 = abs(k[1] - j)
	if x1 % a != 0 or y1 % b != 0:
		continue
	x1 = int(x1 / a)
	y1 = int(y1 / b)
	if x1 % 2 != y1 % 2:
		continue
	else:
		flag = 1
		temp = max(x1, y1)
		if temp < dis:
			dis = temp
if [i, j] in cor:
	print(0)
elif flag == 0 or n <= a or m <= b:
	print('Poor Inna and pony!')
else:
	print(dis)


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)
	exit(0)
if x - a <= 0 and x + a > n or (y + b > m and y - b <= 0):
	print('Poor Inna and pony!')
	exit(0)
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!')


(n, m, i, j, a, b) = 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
	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)))


(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, ix, jy, a, b) = list(map(int, input().rstrip().split()))

def check(x, y):
	ax = abs(x - ix)
	by = abs(y - jy)
	q1 = ax / a
	q2 = by / b
	if q2 == int(q2) and q1 == int(q1):
		maxm = max(int(q1), int(q2))
		minm = min(int(q1), int(q2))
		if maxm % 2 == 0 and minm % 2 == 0 or (maxm % 2 == 1 and minm % 2 == 1):
			return maxm
	return -1
li = [[1, 1], [1, m], [n, 1], [n, m]]
ans = []
if [ix, jy] in li:
	ans += [0]
elif max(abs(m - jy), abs(jy - 1)) >= b and max(abs(n - ix), abs(ix - 1)) >= a:
	for i in li:
		get = check(i[0], i[1])
		if get != -1:
			ans += [get]
if len(ans) == 0:
	print('Poor Inna and pony!')
else:
	print(min(ans))


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
	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
	ans = 10000000000
	if uprow % a == 0 and leftcol % b == 0 and (abs(uprow // a - leftcol // b) % 2 == 0):
		ans = min(ans, max(uprow // a, leftcol // b))
	if uprow % a == 0 and rightcol % b == 0 and (abs(uprow // a - rightcol // b) % 2 == 0):
		ans = min(ans, max(uprow // a, rightcol // b))
	if downrows % a == 0 and leftcol % b == 0 and (abs(downrows // a - leftcol // b) % 2 == 0):
		ans = min(ans, max(downrows // a, leftcol // b))
	if downrows % a == 0 and rightcol % b == 0 and (abs(downrows // a - rightcol // b) % 2 == 0):
		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!')


(n, m, i, j, a, b) = map(int, input().split())
p = [(1, m), (n, 1), (n, m), (1, 1)]
c = 0
mn = 1000000000.0
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!')


def main():
	(n, m, x, y, a, b) = map(int, input().split(' '))
	mi = int(1000000000.0)
	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(1000000000.0) or n <= a or m <= b:
		return 'Poor Inna and pony!'
	return int(mi)
print(main())


(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)


z = input()
x = z.split(' ')
y = [int(o) for o in x]
n = y[0]
m = y[1]
i = y[2]
j = y[3]
a = y[4]
b = y[5]
l = []
if (n - i) % a == 0 and (m - j) % b == 0:
	if ((n - i) / a - (m - j) / b) % 2 == 0:
		if not (i == n and j != m and (n - 1 < a)) and (not (i != n and j == m and (m - 1 < b))):
			l.append(max((n - i) / a, (m - j) / b))
if (i - 1) % a == 0 and (j - 1) % b == 0:
	if ((i - 1) / a - (j - 1) / b) % 2 == 0:
		if not (i == 1 and j != 1 and (n - 1 < a)) and (not (i != 1 and j == 1 and (m - 1 < b))):
			l.append(max((i - 1) / a, (j - 1) / b))
if (i - 1) % a == 0 and (m - j) % b == 0:
	if ((i - 1) / a - (m - j) / b) % 2 == 0:
		if not (i == 1 and j != m and (n - 1 < a)) and (not (i != 1 and j == m and (m - 1 < b))):
			l.append(max((i - 1) / a, (m - j) / b))
if (n - i) % a == 0 and (j - 1) % b == 0:
	if ((n - i) / a - (j - 1) / b) % 2 == 0:
		if not (i == n and j != 1 and (n - 1 < a)) and (not (i != n and j == 1 and (m - 1 < b))):
			l.append(max((n - i) / a, (j - 1) / b))
if len(l) == 0:
	print('Poor Inna and pony!')
else:
	print(int(min(l)))


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())
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)


def find(x, y):
	distx = abs(x - i)
	disty = abs(y - j)
	if distx == 0 and disty == 0:
		return 0
	if distx % a != 0 or disty % b != 0:
		return float('inf')
	elif abs(distx // a - disty // b) % 2 != 0:
		return float('inf')
	elif distx == 0 and (x + a > n and x - a < 1):
		return float('inf')
	elif disty == 0 and (y + b > m and y - b < 1):
		return float('inf')
	else:
		return max(distx // a, disty // b)
(n, m, i, j, a, b) = map(int, input().split())
ans = min(find(1, 1), find(1, m), find(n, 1), find(n, m))
print(ans if ans != float('inf') else 'Poor Inna and pony!')


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())

def solve(x, y):
	if i - x == 0 and j - y == 0:
		return 0
	if i - a < 1 and i + a > n or (j - b < 1 and j + b > m):
		return -1
	elif not abs(x - i) % a and (not abs(j - y) % b) and (not (abs(x - i) // a + (y - j) // b) % 2):
		return max(abs(x - i) // a, abs(y - j) // b)
	else:
		return -1
vals = [(1, 1), (n, 1), (1, m), (n, m)]
ans = -1
for values in vals:
	res = solve(values[0], values[1])
	if res != -1 and (ans == -1 or res < ans):
		ans = res
if ans == -1:
	print('Poor Inna and pony!')
else:
	print(ans)


(n, m, i, j, a, b) = [int(x) for x in input().split()]
i -= 1
j -= 1
best = float('inf')

def find(x, y, a, b, n, m):
	n = n // a
	m = m // b
	x = x // a
	y = y // b
	total = min(x, y)
	x -= total
	y -= total
	if (y + x) % 2 == 0:
		if y == 0 and m > 1:
			return y + x + total
		elif x == 0 and n > 1:
			return y + x + total
		elif y == 0 and x == 0:
			return y + x + total
		else:
			return float('inf')
	else:
		return float('inf')
if i % a == 0:
	x = i
	if j % b == 0:
		y = j
		best = min(best, find(x, y, a, b, n, m))
	if (m - j - 1) % b == 0:
		y = m - j - 1
		best = min(best, find(x, y, a, b, n, m))
if (n - i - 1) % a == 0:
	x = n - i - 1
	if j % b == 0:
		y = j
		best = min(best, find(x, y, a, b, n, m))
	if (m - j - 1) % b == 0:
		y = m - j - 1
		best = min(best, find(x, y, a, b, n, m))
if best == float('inf'):
	print('Poor Inna and pony!')
else:
	print(best)