import sys
r1,r2 = map(int, raw_input().split())
c1,c2 = map(int, raw_input().split())
d1,d2 = map(int, raw_input().split())
for a in xrange(1,10):
    for b in xrange(1,10):
        if a == b:
            continue
        if a + b != r1:
            continue
        for c in xrange(1,10):
            if a == c or b == c:
                continue
            if a + c != c1:
                continue
            if b + c != d2:
                continue
            for d in xrange(1,10):
                if a == d or b == d or c == d:
                    continue
                if c + d != r2:
                    continue
                if b + d != c2:
                    continue
                if a + d != d1:
                    continue
                print a, b
                print c, d
                sys.exit(0)
else:
    print -1