# coding:utf-8
#!/usr/bin/env python

r=raw_input()
c=raw_input()
d=raw_input()

r1=int(r.split(' ')[0])
r2=int(r.split(' ')[1])
c1=int(c.split(' ')[0])
c2=int(c.split(' ')[1])
d1=int(d.split(' ')[0])
d2=int(d.split(' ')[1])

answer1='-1'
answer2='-1'

frag=0
for i in xrange(1,10):
    for j in xrange(1,10):
        #if i==j:
        #    continue
        for k in xrange(1,10):
            #if (k==i) or (k==j):
            #    continue
            for l in xrange(1,10):
                #if (l==i) or (l==j) or (l==k):
                #    continue
                    if (i+j==r1):
                        if (k+l==r2):
                            if (i+k==c1):
                                if (j+l==c2):
                                    if (i+l==d1):
                                        if (j+k==d2):
                                            answer1=str(i)+' '+str(j)
                                            answer2=str(k)+' '+str(l)


#print r1,r2,c1,c2,d1,d2
if answer1==answer2:
    print answer2
else:
    print answer1
    print answer2