def unique(a1,a2,b1,b2):
    if a1!=a2 and a1!=b1 and a1!=b2 and a2!=b1 and a2!=b2 and b1!=b2:
        return True
    else:
        return False
        
r1,r2=list(map(int,input().split()))
c1,c2=list(map(int,input().split()))
d1,d2=list(map(int,input().split()))

flag=1
for a1 in range(1,10):
    if flag==0:
        break
    else:
        for a2 in range(1,10):
            if flag==0:
                break
            else:
                for b1 in range(1,10):
                    if flag==0:
                        break
                    else:
                        for b2 in range(1,10):
                            if flag==0:
                                break
                            else:
                                if a1+a2==r1 and b1+b2==r2 and a1+b1==c1 and a2+b2==c2 and a1+b2==d1 and a2+b1==d2 and unique(a1,a2,b1,b2):
                                    print(a1,a2)
                                    print(b1,b2)
                                    flag=0
                                    break
else:
    print(-1)