import sys

r1, r2 = [int(x) for x in raw_input().split()]
c1, c2 = [int(x) for x in raw_input().split()]
d1, d2 = [int(x) for x in raw_input().split()]

for i in range(1, 10):
    for j in range(1, 10):
        for k in range(1, 10):
            for l in range(1, 10):
                if i==j or i==k or i==l or j==k or j==l or k==l:
                    continue
                else:
                    if i+j==r1 and k+l==r2 and i+k==c1 and j+l==c2 and i+l==d1 and j+k==d2:
                        print i, j
                        print k, l
                        sys.exit(0)
print -1
