Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. 

Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.

Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.


-----Input-----

The first line of the input contains six positive integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, y_1, x_2, y_2, x_3, y_3 ≤ 100), where x_{i} and y_{i} determine the length and width of the logo of the i-th company respectively.


-----Output-----

If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).

If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:  the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,  the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,  the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company, 

Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.

See the samples to better understand the statement.


-----Examples-----
Input
5 1 2 5 5 2

Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC

Input
4 4 2 6 4 2

Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC

Difficulty: MEDIUM_HARD

Solutions:
def stripe(a, b, c):
	ans = [str(a[0])]
	ans.append('\n'.join((a[2] * a[0] for _ in range(a[1]))))
	ans.append('\n'.join((b[2] * b[0] for _ in range(b[1]))))
	ans.append('\n'.join((c[2] * c[0] for _ in range(c[1]))))
	return '\n'.join(ans)

def tt(a):
	return (a[1], a[0], a[2])

def one_two(a, b, c):
	ans = [str(a[0])]
	ans.append('\n'.join((a[2] * a[0] for _ in range(a[1]))))
	for _ in range(b[1]):
		ans.append(b[2] * b[0] + c[2] * c[0])
	return '\n'.join(ans)

def solve():
	(x1, y1, x2, y2, x3, y3) = map(int, input().split())
	a = (x1, y1, 'A')
	b = (x2, y2, 'B')
	c = (x3, y3, 'C')
	from itertools import permutations
	for (a, b, c) in permutations((a, b, c)):
		for (a, b, c) in ((a, b, c), (tt(a), b, c), (a, tt(b), c), (a, b, tt(c)), (tt(a), tt(b), c), (tt(a), b, tt(c)), (a, tt(b), tt(c)), (tt(a), tt(b), tt(c))):
			if a[0] == a[1] + b[1] + c[1]:
				return stripe(a, b, c)
			if a[0] == b[0] + c[0] and b[1] == c[1] and (a[0] == a[1] + b[1]):
				return one_two(a, b, c)
	return -1
print(solve())


def main():
	mode = 'filee'
	if mode == 'file':
		p = open('test.txt', 'r')
	get = lambda : [int(x) for x in (p.readline() if mode == 'file' else input()).split()]
	[a, b, c, d, e, f] = get()
	g = [[a, b, 'A'], [c, d, 'B'], [e, f, 'C']]
	n = 0
	for i in g:
		n = max(n, max(i[:2]))
	if a * b + c * d + e * f != n * n:
		print('-1')
		return
	h = []
	print(n)
	for i in g:
		if n in i:
			for j in range(min(i[:2])):
				print(i[2] * max(i[:2]))
		else:
			h.append(i)
	if len(h) > 0:
		for j in range(2):
			for k in range(2):
				if h[0][j] == h[1][k] and h[0][1 - j] + h[1][1 - k] == n:
					l1 = h[0][1 - j]
					l2 = h[1][1 - k]
					times = h[0][j]
					c1 = h[0][2]
					c2 = h[1][2]
					break
		for i in range(times):
			print(c1 * l1 + c2 * l2)
	if mode == 'file':
		p.close()
main()


def out(t, x1, y1, x2, y2, x3, y3, m):
	if t == 1:
		print(x1)
		for i in range(y1):
			for j in range(x1):
				print('A', end='')
			print()
		for i in range(y2):
			for j in range(x1):
				print('B', end='')
			print()
		for i in range(y3):
			for j in range(x1):
				print('C', end='')
			print()
	elif m == 1:
		print(x1)
		for i in range(y1):
			for j in range(x1):
				print('A', end='')
			print()
		for i in range(x1 - y1):
			for j in range(x1):
				if x2 > j:
					print('B', end='')
				else:
					print('C', end='')
			print()
	elif m == 2:
		print(x2)
		for i in range(y2):
			for j in range(x2):
				print('B', end='')
			print()
		for i in range(x2 - y2):
			for j in range(x2):
				if x1 > j:
					print('A', end='')
				else:
					print('C', end='')
			print()
	else:
		print(x3)
		for i in range(y3):
			for j in range(x3):
				print('C', end='')
			print()
		for i in range(x3 - y3):
			for j in range(x3):
				if x1 > j:
					print('A', end='')
				else:
					print('B', end='')
			print()

def check1(x1, y1, x2, y2, x3, y3):
	(a, b) = (max(x1, y1), min(x1, y1))
	b += (y2 if x2 == a else x2) + (y3 if x3 == a else x3)
	if a == b:
		out(1, a, min(x1, y1), a, y2 if x2 == a else x2, a, y3 if x3 == a else x3, 1)
	return a == b

def check2(x1, y1, x2, y2, x3, y3):
	(a, b) = (max(x1, y1), min(x1, y1))
	bt = x2 + x3
	if bt == a and y2 == a - b and (y3 == a - b):
		out(2, a, b, x2, y2, x3, y3, 1)
		exit(0)
	bt = x2 + y3
	if bt == a and y2 == a - b and (x3 == a - b):
		out(2, a, b, x2, y2, y3, x3, 1)
		exit(0)
	bt = y2 + x3
	if bt == a and x2 == a - b and (y3 == a - b):
		out(2, a, b, y2, x2, x3, y3, 1)
		exit(0)
	bt = y2 + y3
	if bt == a and x2 == a - b and (x3 == a - b):
		out(2, a, b, y2, x2, y3, x3, 1)
		exit(0)
	(a, b) = (max(x2, y2), min(x2, y2))
	bt = x1 + x3
	if bt == a and y1 == a - b and (y3 == a - b):
		out(2, x1, y1, a, b, x3, y3, 2)
		exit(0)
	bt = x1 + y3
	if bt == a and y1 == a - b and (x3 == a - b):
		out(2, x1, y1, a, b, y3, x3, 2)
		exit(0)
	bt = y1 + x3
	if bt == a and x1 == a - b and (y3 == a - b):
		out(2, y1, x1, a, b, x3, y3, 2)
		exit(0)
	bt = y1 + y3
	if bt == a and x1 == a - b and (x3 == a - b):
		out(2, y1, x1, a, b, y3, x3, 2)
		exit(0)
	(a, b) = (max(x3, y3), min(x3, y3))
	bt = x2 + x1
	if bt == a and y2 == a - b and (y1 == a - b):
		out(2, x1, y1, x2, y2, a, b, 3)
		exit(0)
	bt = x2 + y1
	if bt == a and y2 == a - b and (x1 == a - b):
		out(2, y1, x1, x2, y2, a, b, 3)
		exit(0)
	bt = y2 + x1
	if bt == a and x2 == a - b and (y1 == a - b):
		out(2, x1, y1, y2, x2, a, b, 3)
		exit(0)
	bt = y2 + y1
	if bt == a and x2 == a - b and (x1 == a - b):
		out(2, y1, x1, y2, x2, a, b, 3)
		exit(0)
(x1, y1, x2, y2, x3, y3) = [int(x) for x in input().split()]
b = check1(x1, y1, x2, y2, x3, y3)
if b:
	exit(0)
b = check2(x1, y1, x2, y2, x3, y3)
if b:
	exit(0)
print(-1)


from math import sqrt
from math import floor
L = list(map(int, input().split()))
G = []
area = 0
for i in range(3):
	G.append([L[2 * i], L[2 * i + 1]])
	area += L[2 * i] * L[2 * i + 1]
side = sqrt(area)
if side != floor(side):
	print(-1)
else:
	side = int(side)
	dict = {0: 'A', 1: 'B', 2: 'C'}
	index = 0
	bool = True
	while index <= len(G) - 1:
		if G[index][0] == side or G[index][1] == side:
			if G[index][0] == side:
				long = side - G[index][1]
				width = side
			else:
				long = side - G[index][0]
				width = side
			if index == 1:
				(r, s) = (0, 2)
			else:
				r = (3 - index) // 2
				s = r + 1
			if side == long:
				bool = False
				break
			G.pop(index)
			if G[0][0] == side or G[0][1] == side:
				if G[1][0] == side or G[1][1] == side:
					print(side)
					for i in range(side - long):
						t = dict[index]
						print(t * side)
					for i in range(2):
						for j in range(G[i][0] * G[i][1] // side):
							if i == 0:
								b = dict[r]
							else:
								b = dict[s]
							print(b * side)
					break
				else:
					bool = False
					break
			elif G[0][0] == long or G[0][1] == long:
				if G[1][0] == long or G[1][1] == long:
					print(side)
					for i in range(side - long):
						t = dict[index]
						print(t * side)
					for i in range(long):
						f = G[0][0] * G[0][1] // long
						g = G[1][0] * G[1][1] // long
						print(dict[r] * f + dict[s] * g)
					break
				else:
					bool = False
					break
			else:
				bool = False
				break
		else:
			index += 1
	if index == 3 or not bool:
		print(-1)


from itertools import permutations

def isqrt(x):
	(l, r) = (0, 10 ** 100)
	while l < r - 1:
		mid = (l + r) // 2
		if mid ** 2 > x:
			r = mid
		else:
			l = mid
	return l
(x1, y1, x2, y2, x3, y3) = map(int, input().split())
p = [(x1, y1, 'A'), (x2, y2, 'B'), (x3, y3, 'C')]
s = x1 * y1 + x2 * y2 + x3 * y3
x = isqrt(s)
if x * x != s:
	print(-1)
	exit(0)
for mask in range(1 << 3):
	q = []
	for i in range(3):
		if mask >> i & 1:
			q.append((p[i][0], p[i][1], p[i][2]))
		else:
			q.append((p[i][1], p[i][0], p[i][2]))
	if q[0][0] == q[1][0] == q[2][0] == x:
		print(x)
		for i in range(q[0][1]):
			print('A' * x)
		for i in range(q[1][1]):
			print('B' * x)
		for i in range(q[2][1]):
			print('C' * x)
		exit(0)
	for r in permutations(q):
		t = list(r)
		if t[0][0] == x and t[0][1] + t[1][1] == x and (t[0][1] + t[2][1] == x) and (t[1][0] + t[2][0] == x):
			print(x)
			for i in range(t[0][1]):
				print(t[0][2] * x)
			for i in range(x - t[0][1]):
				print(t[1][2] * t[1][0] + t[2][2] * t[2][0])
			exit(0)
print(-1)


import itertools
(a, b, c) = [[0 for _ in range(2)] for _ in range(3)]
(a[0], a[1], b[0], b[1], c[0], c[1]) = [int(i) for i in input().split()]
if max(a) == max(b) == max(c) == min(a) + min(b) + min(c):
	print(max(a))
	for _ in range(min(a)):
		print(''.join(['A' for __ in range(max(a))]))
	for _ in range(min(b)):
		print(''.join(['B' for __ in range(max(a))]))
	for _ in range(min(c)):
		print(''.join(['C' for __ in range(max(a))]))
else:
	fl = False
	for i in itertools.permutations(a):
		for j in itertools.permutations(b):
			for k in itertools.permutations(c):
				for l in itertools.permutations([('A', i), ('B', j), ('C', k)]):
					if l[0][1][1] == l[0][1][0] + l[1][1][0] and l[0][1][1] == l[1][1][1] + l[2][1][1] and (l[1][1][0] == l[2][1][0]):
						if fl:
							break
						print(l[0][1][1])
						for _ in range(l[0][1][0]):
							print(''.join([l[0][0] for __ in range(l[0][1][1])]))
						for _ in range(l[1][1][0]):
							print(''.join([l[1][0] for __ in range(l[1][1][1])] + [l[2][0] for __ in range(l[2][1][1])]))
						fl = True
	if not fl:
		print(-1)


def getprint(c1, c2, c3, maxi, ost, delta):
	ans = str(maxi) + '\n' + (c1 * maxi + '\n') * ost
	return ans + (c2 * delta + c3 * (maxi - delta) + '\n') * (maxi - ost)

def solve():
	a = list(map(int, input().split()))
	if max(a) ** 2 != a[0] * a[1] + a[2] * a[3] + a[4] * a[5]:
		return -1
	maxi = max(a)
	if maxi in a[:2] and maxi in a[2:4] and (maxi in a[4:]):
		return str(maxi) + '\n' + ('A' * maxi + '\n') * min(a[:2]) + ('B' * maxi + '\n') * min(a[2:4]) + ('C' * maxi + '\n') * min(a[4:])
	ind = a.index(maxi)
	ost = a[ind ^ 1]
	if ind // 2 == 0 and maxi - ost in a[2:4] and (maxi - ost in a[4:]):
		return getprint('A', 'B', 'C', maxi, ost, a[2] * a[3] // (maxi - ost))
	elif ind // 2 == 1 and maxi - ost in a[:2] and (maxi - ost in a[4:]):
		return getprint('B', 'A', 'C', maxi, ost, a[0] * a[1] // (maxi - ost))
	elif ind // 2 == 2 and maxi - ost in a[:2] and (maxi - ost in a[2:4]):
		return getprint('C', 'A', 'B', maxi, ost, a[0] * a[1] // (maxi - ost))
	return -1
print(solve())


import sys
(x1, y1, x2, y2, x3, y3) = map(int, input().split())
a = (x1, y1)
b = (x2, y2)
c = (x3, y3)
for i in range(2):
	for j in range(2):
		for k in range(2):
			if a[i] == b[j] == c[k] and a[1 - i] + b[1 - j] + c[1 - k] == a[i]:
				print(a[i])
				print(('A' * a[i] + '\n') * a[1 - i], end='')
				print(('B' * b[j] + '\n') * b[1 - j], end='')
				print(('C' * c[k] + '\n') * c[1 - k], end='')
				sys.exit(0)
r = max(max(a), max(b), max(c))
xs = [a, b, c]
for (i, t) in enumerate(xs):
	if r == max(t):
		index = i
		break
o = xs[index][:]
s = o[1] if o[0] == r else o[0]
del xs[index]
for i in range(2):
	for j in range(2):
		if xs[0][i] == xs[1][j] == r - s and xs[0][1 - i] + xs[1][1 - j] == r:
			print(r)
			symb = chr(ord('A') + index)
			print((symb * r + '\n') * s, end='')
			syms = ['A', 'B', 'C']
			syms.remove(symb)
			print((syms[0] * xs[0][1 - i] + syms[1] * xs[1][1 - j] + '\n') * (r - s), end='')
			sys.exit(0)
print(-1)


from collections import namedtuple
from itertools import permutations
Rect = namedtuple('Rect', 'h w c')

def rotations(r):
	yield r
	yield Rect(r[1], r[0], r[2])

def main():
	(a, b, c, d, e, f) = map(int, input().split())
	a = Rect(a, b, 'A')
	b = Rect(c, d, 'B')
	c = Rect(e, f, 'C')
	del d, e, f
	for a0 in rotations(a):
		for b0 in rotations(b):
			for c0 in rotations(c):
				for (x, y, z) in permutations((a0, b0, c0), 3):
					if x.w == y.w == z.w == x.h + y.h + z.h:
						print(x.w)
						for i in range(x.h):
							print(x.c * x.w)
						for i in range(y.h):
							print(y.c * y.w)
						for i in range(z.h):
							print(z.c * z.w)
						return
					elif x.w == y.w + z.w == x.h + y.h and y.h == z.h:
						print(x.w)
						for i in range(x.h):
							print(x.c * x.w)
						for i in range(y.h):
							print(y.c * y.w, end='')
							print(z.c * z.w)
						return
	print(-1)
main()


import math
xy = list(map(int, input().split()))
x = [[xy[0], xy[2], xy[4]], [xy[1], xy[3], xy[5]]]
aa = 0
max_ll = 0
for i in range(3):
	aa += x[0][i] * x[1][i]
	max_ll = max(max_ll, x[0][i], x[1][i])
bb = math.sqrt(aa)
if bb * bb != aa or max_ll != bb:
	print(-1)
else:
	bb = int(bb)
	mt = [[''] * bb for _ in range(bb)]
	max_l = 0
	chars = ['A', 'B', 'C']
	x = [[xy[0], xy[1]], [xy[2], xy[3]], [xy[4], xy[5]]]
	max_lp = -1
	max_li = -1
	ii = 0
	oh = []
	for i in x:
		if max(i) >= max_l:
			max_l = max(i)
			max_lp = sum(i) - max(i)
			max_li = ii
		ii += 1
	max_ls = []
	ii = 0
	for i in x:
		if max(i) == max_l:
			max_ls.append(i + [ii])
		else:
			oh += [ii]
		ii += 1
	if len(max_ls) == 3:
		for i in range(max_l):
			for j in range(max_l):
				if i < max_ls[0][0] + max_ls[0][1] - max_l:
					mt[i][j] = chars[max_ls[0][2]]
				elif i < max_ls[0][0] + max_ls[0][1] - max_l + max_ls[1][0] + max_ls[1][1] - max_l:
					mt[i][j] = chars[max_ls[1][2]]
				else:
					mt[i][j] = chars[max_ls[2][2]]
	else:
		for i in range(max_lp):
			for j in range(max_l):
				mt[i][j] = chars[max_li]
		bb = max_l - max_lp
		for i in range(max_lp, max_l):
			for j in range(max_l):
				if j < sum(x[oh[0]]) - bb:
					mt[i][j] = chars[oh[0]]
				else:
					mt[i][j] = chars[oh[1]]
	print(max_l)
	for j in mt:
		print(''.join(j))


import itertools as it
import functools
import operator
import collections
import math
import sys
import bisect

def solve(x1, y1, x2, y2, x3, y3):
	(x1, y1) = (min(x1, y1), max(x1, y1))
	(x2, y2) = (min(x2, y2), max(x2, y2))
	(x3, y3) = (min(x3, y3), max(x3, y3))
	pairs = [(x1, y1), (x2, y2), (x3, y3)]
	area = sum((x * y for (x, y) in pairs))
	side = math.floor(math.sqrt(area))
	if side * side != area:
		return None
	count = [y1, y2, y3].count(side)
	if count == 3:
		if x1 + x2 + x3 == side:
			As = 'A' * side
			Bs = 'B' * side
			Cs = 'C' * side
			return [As for _ in range(x1)] + [Bs for _ in range(x2)] + [Cs for _ in range(x3)]
	result = []
	abc = 'ABC'
	if count == 1:
		(i, x, y) = next(((i, x, y) for (i, (x, y)) in enumerate(pairs) if y == side))
		result.append((abc[i], (x, y)))
		length = side - x
		tmp = 0
		for (k, (x, y)) in enumerate(pairs):
			if k == i:
				continue
			if x == length:
				tmp += y
				result.append((abc[k], (x, y)))
			elif y == length:
				tmp += x
				result.append((abc[k], (y, x)))
			else:
				return None
		if tmp == side:
			(c, (x0, y0)) = result[0]
			(c1, (x1, y1)) = result[1]
			(c2, (x2, y2)) = result[2]
			top = [c * side for _ in range(x0)]
			bottom = [c1 * y1 + c2 * y2 for _ in range(x1)]
			return top + bottom
	return None

def main():
	xys = [int(i) for i in input().strip().split()]
	assert len(xys) == 6
	result = solve(*xys)
	if result is None:
		print(-1)
	else:
		print(len(result))
		for line in result:
			print(line)

def __starting_point():
	main()
__starting_point()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def ok(a, b, c):
	n = a[0][-1]
	ans = []
	for i in range(a[0][0]):
		ans.append([a[1]] * n)
	l = n
	r = n - a[0][0]
	for i in range(2):
		for j in range(2):
			(l1, r1) = b[0]
			(l2, r2) = c[0]
			if i:
				(l1, r1) = (r1, l1)
			if j:
				(l2, r2) = (r2, l2)
			if l1 == l:
				if l2 != l or r1 + r2 != r:
					continue
				for k in range(r1):
					ans.append([b[1]] * n)
				for k in range(r2):
					ans.append([c[1]] * n)
				return ans
			if l1 == r:
				if l2 != r or r1 + r2 != l:
					continue
				for k in range(r):
					ans.append([b[1]] * r1 + [c[1]] * r2)
				return ans
	return False
(l1, r1, l2, r2, l3, r3) = value()
a = [sorted((l1, r1)), 'A']
b = [sorted((l2, r2)), 'B']
c = [sorted((l3, r3)), 'C']
A = ok(a, b, c)
B = ok(b, a, c)
C = ok(c, a, b)
if A:
	print(len(A))
	for i in A:
		print(*i, sep='')
elif B:
	print(len(B))
	for i in B:
		print(*i, sep='')
elif C:
	print(len(C))
	for i in C:
		print(*i, sep='')
else:
	print(-1)