from random import randint
r1r2 = list(map(int, input().split()))
c1c2 = list(map(int, input().split()))
d1d2 = list(map(int, input().split()))
allNumbers = r1r2 + c1c2 + d1d2
no = 0
for i in allNumbers:
    if i < 3 or sum(allNumbers) > 81 or len(set(allNumbers)) < 5:
        print(-1)
        no = 1
        break

sum = r1r2[0] + c1c2[0] + d1d2[0]
number = [i for i in str(randint(1000, 9999))]
x = y = z = k = 0
while(True and no == 0):
    if(len(set(number)) == 4 and x+y == r1r2[0] and z+k == r1r2[1]
       and x+k == d1d2[0] and z+y == d1d2[1] and x+z == c1c2[0] and y+k == c1c2[1]):
        print(x, y)
        print(z, k)
        break
    else:
        number = [i for i in str(randint(1000, 9999))]
        x = int(number[0])
        k = int(number[1])
        z = int(number[2])
        y = int(number[3])
