# 20241015
while True:
    try:
        m, n = list(map(int, input().split()))
        x1, y1, x2, y2 = list(map(int, input().split()))
        x = int(input())
        y = int(input())
        x3, y3 = list(map(int, input().split()))
        # 1
        if 0 <= m <= 9 and 0 <= n <= 9:
            print("0")
        else:
            print("-1")

        # 2
        if 0 <= x1 < m and 0 <= y1 < n and 0 <= x2 < m and 0 <= y2 < n:
            print("0")
        else:
            print("-1")
        # 3
        if 0 <= x < m and m < 9:
            print("0")
        else:
            print("-1")

        # 4
        if 0 <= y < n and n < 9:
            print("0")
        else:
            print("-1")

        # 5
        if 0 <= x3 < m and 0 <= y3 < n:
            print("0")
        else:
            print("-1")
    except:
        break