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

for a in range(1, 10):
    for b in range(1, 10):
        for c in range(1, 10):
            for d in range(1, 10):
                cnt = [ 0 for i in range(10) ]
                cnt[a] += 1
                cnt[b] += 1
                cnt[c] += 1
                cnt[d] += 1
                if max(*cnt) > 1:
                    continue

                if a + b != r1: continue
                if c + d != r2: continue
                if a + c != c1: continue
                if b + d != c2: continue
                if a + d != d1: continue
                if b + c != d2: continue
                print a, b
                print c, d
                quit()
print -1
