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

sol = [0, 0, 0, 0]

# [0][1]
# [2][3]
for num in range(1,10):
	numUsed = []
	
	sol[0] = num
	numUsed.append(num)

	second = int(r1) - sol[0]
	if second < 1 or second > 9 or second in numUsed:
		continue
	sol[1] = second
	numUsed.append(sol[1])

	third = int(c1) - sol[0]
	if third < 1 or third > 9 or third in numUsed:
		continue
	sol[2] = third
	numUsed.append(third)

	fourth = int(d1) - sol[0]
	if fourth < 1 or fourth > 9 or fourth in numUsed:
		continue
	sol[3] = fourth
	numUsed.append(fourth)

	#confirm all solutions
	if int(r1) != sol[0] + sol[1]:
		continue
	if int(r2) != sol[2] + sol[3]:
		continue
	if int(c1) != sol[0] + sol[2]:
		continue
	if int(c2) != sol[1] + sol[3]:
		continue
	if int(d1) != sol[0] + sol[3]:
		continue
	if int(d2) != sol[1] + sol[2]:
		continue
	
	print ("%d %d") % (sol[0], sol[1])
	print ("%d %d") % (sol[2], sol[3])
	exit()

print "-1"
