while True:
    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(" "))
        # 初始化表格是否成功
        print(0 if 0 < m <= 9 and 0 < n <= 9 else -1)

        # 交换单元格是否成功
        print(0 if 0 <= x1 < m and 0 <= x2 < m and 0 <= y1 < n and 0 <= y2 < n else -1)
    
        # 插入行是否成功
        print(0 if 0 <= x < m and m + 1 <= 9 else -1)
    
        # 插入列是否成功
        print(0 if 0 <= y < n and n + 1 <= 9 else -1)
    
        # 要查询的单元格的坐标
        print(0 if 0 <= xx < m and 0 <= yy < n else - 1)
    except:
        break