注意初始化范围19,但行列号08

while True:
    try:
        a, b = map(int,input().split())
        c, d, e, f = map(int, input().split())
        g = int(input())
        h = int(input())
        i, j = map(int,input().split())
        
        if 1 <= a <= 9 and 1 <= b <= 9:
            print(0)
        else:
            print(-1)
        if 0<=c<a and 0<=d<b and 0<=e<a and 0<=f<b:
            print(0)
        else:
            print(-1)
        if 0<= g <a and a<9:
            print(0)
        else:
            print(-1)
        if 0<= h <b and b<9:
            print(0)
        else:
            print(-1)
        if 0<=i<a and 0<=j<b:
            print(0)
        else:
            print(-1)
    except:
        break