while True:
    try:
        m, n = map(int, input().split())
        x1,y1,x2,y2 = map(int, input().split())
        swapX = int(input())
        swapY = int(input())
        SearchX, SearchY = map(int, input().split())
        if 0 <= m <= 9 and 0 <= n <= 9:
            print(0)
        else:
            print(-1)
            
        if x1 < m and x2 < m and y1 < n and y2 < n:
            print(0)
        else:
            print(-1)
            
        if 0 <= swapX < m and m < 9:
            print(0)
        else:
            print(-1)
            
        if 0 <= swapY < n and n < 9:
            print(0)
        else:
            print(-1)
            
        if 0 <= SearchX < m and 0 <= SearchY < n:
            print(0)
        else:
            print(-1)
    except:
        break