r1, r2 = map(int, raw_input().strip().split())
c1, c2 = map(int, raw_input().strip().split())
d1, d2 = map(int, raw_input().strip().split())
ij = []
hf = []
for i in range(1,10):
    for j in range(1,10):
        for h in range(1,10):
            for f in range(1,10):
                if i + j == r1 and h + f == r2 and i + f == d1 and j + h == d2 and i + h == c1 and j + f == c2:
                    ij.append(i)
                    ij.append(j)
                    hf.append(h)
                    hf.append(f)

if ij == [] and hf == []:
    print -1
else:
    print ' '.join(str(x) for x in ij)
    print ' '.join(str(y) for y in hf)