r1, r2 = map(int, raw_input().split())
c1, c2 = map(int, raw_input().split())
d1, d2 = map(int, raw_input().split())
r = -1
for a in range(1, 10):
	b = r1 - a
	c = c1 - a
	d = c2 - r1 + a
	if c + d == r2 and a + d == d1 and b + c == d2 and len(set(map(str, [a, b, c, d])) & set('123456789')) == 4:
		r = '{0} {1}\n{2} {3}'.format(a, b, c, d)
		break
print r