from itertools import permutations as perms


r1, r2 = map(int, raw_input().split(' '))
c1, c2 = map(int, raw_input().split(' '))
d1, d2 = map(int, raw_input().split(' '))


items = [a for a in range(1,10)]

res = []
for perm in perms(items):
    comb = perm[:4]
    if comb[0] + comb[3] == d1 and \
       comb[1] + comb[2] == d2 and \
       comb[0] + comb[2] == c1 and \
       comb[1] + comb[3] == c2 and \
       comb[0] + comb[1] == r1 and \
       comb[2] + comb[3] == r2:
        res = map(str, comb)
        break


if res:
    print ' '.join(res[:2])
    print ' '.join(res[2:])
else:
    print '-1'
