from sys import stdin
from sys import stdout
import itertools

[r1, r2] = map(int, stdin.readline().split(" "))
[c1, c2] = map(int, stdin.readline().split(" "))
[d1, d2] = map(int, stdin.readline().split(" "))

result = [-1]
gems = range(1, 10)
for comb in itertools.combinations(gems, 4):
	
	for perm in itertools.permutations(comb):
		
		if (perm[0] + perm[1]) == r1 and \
			(perm[2] + perm[3]) == r2 and \
			(perm[0] + perm[2]) == c1 and \
			(perm[1] + perm[3]) == c2 and \
			(perm[0] + perm[3]) == d1 and \
			(perm[1] + perm[2]) == d2:
				result = perm
				break

for idx in range(0, len(result) - 1):
	stdout.write(str(result[idx]) + " ")
print result[-1]

