#代码不难,审题要仔细,多个if判断,以及插入后要恢复原来的行列数,并且输入的都是坐标值
while True:
    try:
        x,y=map(int,input().split())
        lb=[[0 for i in range(y)]for j in range(x)] #初始化下表格
        a1=list(map(int,input().split()))  #将两个坐标点,4个值直接存到列表
        a2=int(input())
        a3=int(input())
        a4=list(map(int,input().split()))  #将查询的坐标,2个值直接存到列表
        if 0<x<10 and 1<y<10: #判断初始化表格是否符合要求,符合输出0,不符合输入-1
            print(0)
            if 0<=a1[0]<x and 0<=a1[2]<x and 0<=a1[1]<y and 0<=a1[3]<y:  #判断坐标是否在表格里
                print(0)
                lb[a1[0]][a1[1]],lb[a1[2]][a1[3]]=lb[a1[2]][a1[3]],lb[a1[0]][a1[1]] 
            else:
                print(-1)
            if x+1<=9 and 0<=a2<x:
                print(0)
                lb.insert(a2,[0 for i in range(y)])
                lb.pop()
            else:
                print(-1)
            if y+1<=9 and 0<=a3<y:
                print(0)
                for i in range(len(lb)):
                    lb[i].insert(a3,0)
                    lb[i].pop()
            else:
                print(-1)
            if 0<=a4[0]<x and 0<=a4[1]<y:
                print(0)
            else:
                print(-1)
        else:
            print(-1)
    except:
        break