def read(t=int):
	return map(t,raw_input().split())
r1,r2=read()
c1,c2=read()
d1,d2=read()
for i in xrange(1111,10000):
	l=map(int,list(str(i)))
	if len(set(l))!= 4 or 0 in l : continue
	if l[0]+l[1]==r1 and l[2]+l[3]==r2 and l[0]+l[2]==c1 and l[1]+l[3]==c2 and l[0]+l[3]==d1 and l[1]+l[2]==d2:
		print l[0],l[1]
		print l[2],l[3]
		exit(0)
print -1
