import sys
import fractions
import string

dic= {}

for i in range(1234, 9877):
    if '0' in str(i):
        continue
    a = list(str(i))
    skip = False
    for j in range(1, 10):
        if a.count( str(j) ) > 1:
            skip = True
            break
    if skip:
        continue
    a = [int(k) for k in a]
    dicKey = [ a[0]+a[1], a[2]+a[3],a[0]+a[2], a[1]+a[3], a[0]+a[3], a[1]+a[2]]
    dicKey = [str(k) for k in dicKey]
    a = [str(k) for k in a]
    dic[" ".join(dicKey)]= a[0]+" "+a[1]+"\n"+a[2]+" "+a[3]

r1, r2 = map(int, raw_input().split())
c1, c2 = map(int, raw_input().split())
d1, d2 = map(int, raw_input().split())
ke = [r1,r2,c1,c2,d1,d2]
ke = [str(k) for k in ke]
try:
    print dic[" ".join(ke)]
except:
    print -1