while 1:
try:
m, n = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x = int(input())
y = int(input())
xx, yy = map(int, input().split())
if m >= 0 and n >= 0 and m <= 9 and n <= 9:
print(0)
else:
print(-1)
if x1 >= 0 and y1 >= 0 and x1 <= m-1 and y1 <= n-1 and x2 >= 0 and y2 >= 0 and x2 <= m-1 and y2 <= n-1:
print(0)
else:
print(-1)
if x >= 0 and x <= m-1 and m+1 <= 9:
print(0)
else:
print(-1)
if y >= 0 and y <= n-1 and n+1 <= 9:
print(0)
else:
print(-1)
if xx >= 0 and xx <= m-1 and yy >= 0 and yy <= n-1:
print(0)
else:
print(-1)
except:
break