while True:
try:
m, n = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x = int(input())
y = int(input())
a, b = map(int, input().split())
if m in [1, 2, 3, 4, 5, 6, 7, 8, 9] and n in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
print(0)
else:
print(-1)
if x1 >= m or x2 >= m or y1 >= n or y2 >= n:
print(-1)
else:
print(0)
if x < m and m + 1 <= 9:
print(0)
else:
print(-1)
if y < n and n + 1 <= 9:
print(0)
else:
print(-1)
if a >= m or b >= n:
print(-1)
else:
print(0)
except:
break