B=[4,3,2,1]
def g():
    print B[0],B[1]
    print B[2],B[3]
    exit()
def f():
    for i in range(len(B)):
        if B[i] < 9 :
            t=B[i]+1
            while t in B[i+1:]:
                t+=1
            if t <= 9:
                B[i]=t
                for j in range(i):
                    t=1
                    while t in B:
                        t+=1
                    B[j]=t
                return
            else:
                continue
            
A=[ map(int,raw_input().split()) for i in range(3) ]
C=[6,7,8,9]

while B != C:
    if B[0]+B[1] == A[0][0] and B[2]+B[3] == A[0][1] and  B[0]+B[2]==A[1][0] and B[1]+B[3]==A[1][1] and B[0]+B[3]==A[2][0] and B[1]+B[2]==A[2][1]:
        g()
    f()
if B[0]+B[1] == A[0][0] and B[2]+B[3] == A[0][1] and  B[0]+B[2]==A[1][0] and B[1]+B[3]==A[1][1] and B[0]+B[3]==A[2][0] and B[1]+B[2]==A[2][1]:
        g()
print '-1'
