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()]

w=range(1,10)
x=range(1,10)
y=range(1,10)
z=range(1,10)
p=0
o=0
i=0
u=0
lock=False
for p in w:
    for o in x:
        for i in y:
            for u in z:
                if i+u==r2 and p+o==r1 and p+u==d1 and p+i==c1 and o+u==c2 and o+i==d2 and p!=o and p!=i and p!=u and o!=i and o!=u and i!=u:
                    print p, o
                    print i, u
                    lock=True
if not lock:
    print -1

