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

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Bit manipulation

Constructive algorithms

Geometry

Implementation

Complete search

Mathematics


Solutions:
__author__ = 'Admin'

def f(n):
	return max(n[0], n[1])
t = True
(x1, y1, x2, y2, x3, y3) = map(int, input().split())
m = [x1, y1, x2, y2, x3, y3]
m1 = [[x1, y1, 'A'], [x2, y2, 'B'], [x3, y3, 'C']]
m1.sort(key=f)
maxi = max(m1[-1][0], m1[-1][1])
mini = min(m1[-1][0], m1[-1][1])
maxj = max(m1[-2][1], m1[-2][0])
minj = min(m1[-2][1], m1[-2][0])
maxk = max(m1[0][1], m1[0][0])
mink = min(m1[0][1], m1[0][0])
s = m1[-1][2]
s1 = m1[-2][2]
s2 = m1[0][2]
matr = [[0] * maxi for i in range(maxi)]
for i in range(mini):
	for j in range(maxi):
		matr[i][j] = s
if maxj == maxi and mini + minj <= maxi:
	for i in range(mini, minj + mini):
		for j in range(maxj):
			matr[i][j] = s1
	if maxk == maxi and mini + minj + mink == maxi:
		for i in range(minj + mini, mink + minj + mini):
			for j in range(maxk):
				matr[i][j] = s2
	else:
		t = False
elif maxj == maxi - mini:
	for i in range(mini, mini + maxj):
		for j in range(minj):
			matr[i][j] = s1
	if maxk == maxj and mink == maxi - minj:
		for i in range(mini, mini + maxk):
			for j in range(minj, minj + mink):
				matr[i][j] = s2
	else:
		t = False
elif minj == maxi - mini:
	for i in range(mini, mini + minj):
		for j in range(maxj):
			matr[i][j] = s1
	if mink == minj and maxk == maxi - maxj:
		for i in range(mini, mini + mink):
			for j in range(maxj, maxj + maxk):
				matr[i][j] = s2
	elif maxk == minj and mink == maxi - maxj:
		for i in range(mini, mini + maxk):
			for j in range(maxj, maxj + mink):
				matr[i][j] = s2
	else:
		t = False
else:
	t = False
if t == True:
	print(maxi)
	for i in range(maxi):
		print(*matr[i], sep='')
else:
	print(-1)


(x1, y1, x2, y2, x3, y3) = list(map(int, input().split()))

def solve(x1, y1, x2, y2, x3, y3):
	n = max(x1, y1, x2, y2, x3, y3)
	sum_area = x1 * y1 + x2 * y2 + x3 * y3
	if sum_area != n * n:
		return (-1, None)
	if x1 < y1:
		(x1, y1) = (y1, x1)
	if x2 < y2:
		(x2, y2) = (y2, x2)
	if x3 < y3:
		(x3, y3) = (y3, x3)
	if x1 == x2 == x3:
		bil = ['A' * n for i in range(y1)]
		bil.extend(['B' * n for i in range(y2)])
		bil.extend(['C' * n for i in range(y3)])
		return (n, bil)
	xys = [(x1, y1, 'A'), (x2, y2, 'B'), (x3, y3, 'C')]
	xys.sort(reverse=True)
	(x1, y1, C1) = xys[0]
	(x2, y2, C2) = xys[1]
	(x3, y3, C3) = xys[2]
	if x2 == x1:
		return (-1, None)
	m = n - y1
	if (x2 == m or y2 == m) and (x3 == m or y3 == m):
		bil = [C1 * n for i in range(y1)]
		w2 = x2 + y2 - m
		w3 = x3 + y3 - m
		bil.extend([C2 * w2 + C3 * w3 for i in range(m)])
		return (n, bil)
	return (-1, None)
(n, pattern) = solve(x1, y1, x2, y2, x3, y3)
if n == -1:
	print(-1)
else:
	print(n)
	for row in pattern:
		print(row)


(w1, h1, w2, h2, w3, h3) = map(int, input().split())
(r1, r2, r3) = (sorted((w1, h1)), sorted((w2, h2)), sorted((w3, h3)))
for i in range(3):
	(ra, ca) = ((r1, r2, r3)[i], 'ABC'[i])
	(rb, cb) = ((r1, r2, r3)[(i + 1) % 3], 'ABC'[(i + 1) % 3])
	(rc, cc) = ((r1, r2, r3)[(i + 2) % 3], 'ABC'[(i + 2) % 3])
	if ra[0] == ra[1]:
		continue
	(w, h) = (ra[1] - ra[0], ra[1])
	rs = []
	(wtot, whit, ws) = (0, 0, [])
	(htot, hhit, hs) = (0, 0, [])
	for r in (rb, rc):
		rs.append(r)
		if r[0] != r[1]:
			rs.append((r[1], r[0]))
	for r in rs:
		if r[0] == w:
			wtot += r[1]
			whit += 1
			ws.append(r[1])
		if r[0] == h:
			htot += r[1]
			hhit += 1
			hs.append(r[1])
	if whit == 2 and wtot == h:
		n = ra[1]
		xb = rb[0] if rb[1] == w else rb[1]
		xc = rc[0] if rc[1] == w else rc[1]
		print(n)
		print((ca * n + '\n') * ra[0], end='')
		print((cb * xb + cc * xc + '\n') * w, end='')
		break
	if hhit == 2 and htot == w:
		n = ra[1]
		xb = rb[0] if rb[1] == h else rb[1]
		xc = rc[0] if rc[1] == h else rc[1]
		print(n)
		print((ca * n + '\n') * ra[0], end='')
		print((cb * n + '\n') * xb, end='')
		print((cc * n + '\n') * xc, end='')
		break
else:
	print(-1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(x1, y1, x2, y2, x3, y3) = sep()
	arr = x1 * y1 + x2 * y2 + x3 * y3
	for jj in range(8):
		if x1 == x2 and x2 == x3 and (y1 + y2 + y3 == x1):
			print(x1)
			g = [[0 for _ in range(x1)] for __ in range(x1)]
			for i in range(x1):
				for j in range(y1):
					g[i][j] = 'A'
			for i in range(x1):
				for j in range(y1, y1 + y2):
					g[i][j] = 'B'
			for i in range(x1):
				for j in range(y1 + y2, y1 + y2 + y3):
					g[i][j] = 'C'
			for i in range(x1):
				print(''.join(g[i]))
			return
		else:
			pass
		(x1, y1) = (y1, x1)
		if jj % 2 == 1:
			(x2, y2) = (y2, x2)
		if jj % 4 == 3:
			(x3, y3) = (y3, x3)
	for jj in range(8):
		n = [x1 + x2, x1 + x3, x2 + x3]
		for i in range(len(n)):
			if arr != n[i] * n[i]:
				continue
			if i == 0 and y3 != max(y1, y2) - min(y1, y2):
				continue
			if i == 1 and y2 != max(y1, y3) - min(y1, y3):
				continue
			if i == 2 and y1 != max(y2, y3) - min(y2, y3):
				continue
			g = [[0 for _ in range(n[i])] for __ in range(n[i])]
			if i == 0 or i == 5:
				for j in range(x1):
					for k in range(y1):
						g[j][k] = 'A'
				for j in range(x1, x1 + x2):
					for k in range(y2):
						g[j][k] = 'B'
				for j in range(n[i]):
					for k in range(n[i]):
						if g[j][k] == 0:
							g[j][k] = 'C'
				print(n[i])
				for ii in range(n[i]):
					print(''.join(g[ii]))
				return
			if i == 1 or i == 4:
				for j in range(x1):
					for k in range(y1):
						g[j][k] = 'A'
				for j in range(x1, x1 + x3):
					for k in range(y3):
						g[j][k] = 'C'
				for j in range(n[i]):
					for k in range(n[i]):
						if g[j][k] == 0:
							g[j][k] = 'B'
				print(n[i])
				for ii in range(n[i]):
					print(''.join(g[ii]))
				return
			if i == 2 or i == 3:
				for j in range(x2):
					for k in range(y2):
						g[j][k] = 'B'
				for j in range(x2, x3 + x2):
					for k in range(y3):
						g[j][k] = 'C'
				for j in range(n[i]):
					for k in range(n[i]):
						if g[j][k] == 0:
							g[j][k] = 'A'
				print(n[i])
				for ii in range(n[i]):
					print(''.join(g[ii]))
				return
		(x1, y1) = (y1, x1)
		if jj % 2 == 1:
			(x2, y2) = (y2, x2)
		if jj % 4 == 3:
			(x3, y3) = (y3, x3)
	print(-1)
testcase(1)


(a, b, c, d, e, f) = list(map(int, input().split()))
m = sorted([(max(a, b), min(a, b), 'A'), (max(c, d), min(c, d), 'B'), (max(e, f), min(e, f), 'C')])
ma = m[-1][0]
ma2 = ma - m[-1][1]
ans = [['A'] * ma for i in range(ma)]
if a * b + c * d + e * f != ma * ma:
	print(-1)
elif m[0][0] * m[0][1] + m[1][0] * m[1][1] != ma2 * ma:
	print(-1)
elif m[0][0] != m[1][0]:
	if m[0][0] != m[1][1] and m[0][1] != m[1][1]:
		print(-1)
	else:
		for i in range(m[-1][1]):
			for j in range(ma):
				ans[i][j] = m[-1][2]
		for i in range(m[-1][1], ma):
			for j in range(m[0][0] + m[0][1] - ma2):
				ans[i][j] = m[0][2]
		for i in range(m[-1][1], ma):
			for j in range(m[0][0] + m[0][1] - ma2, ma):
				ans[i][j] = m[1][2]
		print(ma)
		for x in ans:
			print(''.join(x))
else:
	for i in range(m[-1][1]):
		for j in range(ma):
			ans[i][j] = m[-1][2]
	if m[0][0] == ma:
		for i in range(m[-1][1], m[-1][1] + m[0][1]):
			for j in range(ma):
				ans[i][j] = m[0][2]
		for i in range(m[-1][1] + m[0][1], ma):
			for j in range(ma):
				ans[i][j] = m[1][2]
	else:
		for i in range(m[-1][1], ma):
			for j in range(m[0][1]):
				ans[i][j] = m[0][2]
		for i in range(m[-1][1], ma):
			for j in range(m[0][1], ma):
				ans[i][j] = m[1][2]
	print(ma)
	for x in ans:
		print(''.join(x))


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())


import sys
import itertools

def can(h1, w1, h2, w2, h3, w3, c1, c2, c3, tot):
	if tot % h1 == 0 and tot // h1 == h1:
		if h1 == h2 == h3:
			print(h1)
			for r in range(h1):
				temp = ''
				for c in range(w1 + w2 + w3):
					if c < w1:
						temp += c1
					elif c < w1 + w2:
						temp += c2
					else:
						temp += c3
				print(temp)
			return True
		if h2 + h3 == h1 and w2 == w3:
			print(h1)
			for r in range(h1):
				temp = ''
				for c in range(w1 + w2):
					if c < w1:
						temp += c1
					elif r < h2:
						temp += c2
					else:
						temp += c3
				print(temp)
			return True
	return False

def solve(perm):
	(x1, y1) = (perm[0][0][0], perm[0][0][1])
	(x2, y2) = (perm[1][0][0], perm[1][0][1])
	(x3, y3) = (perm[2][0][0], perm[2][0][1])
	c1 = perm[0][1]
	c2 = perm[1][1]
	c3 = perm[2][1]
	tot = x1 * y1 + x2 * y2 + x3 * y3
	for sw1 in range(2):
		for sw2 in range(2):
			for sw3 in range(2):
				(h1, w1, h2, w2, h3, w3) = (x1, y1, x2, y2, x3, y3)
				if sw1 == 1:
					(h1, w1) = (w1, h1)
				if sw2 == 1:
					(h2, w2) = (w2, h2)
				if sw3 == 1:
					(h3, w3) = (w3, h3)
				if can(h1, w1, h2, w2, h3, w3, c1, c2, c3, tot):
					return True

def supersolve():
	(x1, y1, x2, y2, x3, y3) = rv()
	a = [([x1, y1], 'A'), ([x2, y2], 'B'), ([x3, y3], 'C')]
	for perm in itertools.permutations(a):
		if solve(perm):
			return
	print(-1)

def prt(l):
	return print(' '.join(map(str, l)))

def rs():
	return map(str, input().split())

def rv():
	return map(int, input().split())

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
supersolve()


import sys

def get_sol(a, b, c, n, reverse):
	if reverse[0]:
		a = (a[1], a[0], a[2])
	if reverse[1]:
		b = (b[1], b[0], b[2])
	if reverse[2]:
		c = (c[1], c[0], c[2])
	ans = []
	if a[0] == b[0] == c[0] == n:
		if a[1] + b[1] + c[1] == n:
			for i in range(a[1]):
				ans.append(a[2] * n)
			for i in range(b[1]):
				ans.append(b[2] * n)
			for i in range(c[1]):
				ans.append(c[2] * n)
			return (True, ans)
	if a[0] + c[0] == b[0] + c[0] == n and c[1] == n == a[1] + b[1]:
		for i in range(a[1]):
			ans.append(a[2] * a[0] + c[2] * c[0])
		for i in range(b[1]):
			ans.append(b[2] * b[0] + c[2] * c[0])
		return (True, ans)
	return (False, ans)

def printans(ans, n):
	print(n)
	for line in ans:
		print(line)
	return
(x1, y1, x2, y2, x3, y3) = [int(i) for i in input().split()]
total_area = x1 * y1 + x2 * y2 + x3 * y3
n = 0
while n ** 2 < total_area:
	n += 1
if n ** 2 != total_area:
	print(-1)
else:
	first = (x1, y1, 'A')
	second = (x2, y2, 'B')
	third = (x3, y3, 'C')
	pereb = ((first, second, third), (first, third, second), (second, first, third), (second, third, first), (third, first, second), (third, second, first))
	for rev1 in (False, True):
		for rev2 in (False, True):
			for rev3 in (False, True):
				for per in pereb:
					reverse = (rev1, rev2, rev3)
					(is_ans, ans) = get_sol(per[0], per[1], per[2], n, reverse)
					if is_ans:
						printans(ans, n)
	print(-1)


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()


a = list(map(int, input().split()))
from math import sqrt
t = a[0] * a[1] + a[2] * a[3] + a[4] * a[5]
c = ('A', 'B', 'C')
p = int(sqrt(t))
if p ** 2 != t:
	print('-1')
	exit()
k = 0
for i in a:
	if i == p:
		k += 1
if k == 0 or k == 2:
	print('-1')
	exit()
b = list()
ans = ''
if k == 3:
	for i in a:
		if i != p:
			b.append(i)
	if sum(b) != p:
		print('-1')
		exit()
	for i in range(p):
		for j in range(3):
			ans += c[j] * b[j]
		ans += '\n'
	print(p)
	print(ans)
	exit()
arr = []
arr.append([a[0], a[1]])
arr.append([a[2], a[3]])
arr.append([a[4], a[5]])
arr[0].sort(reverse=True)
arr[1].sort(reverse=True)
arr[2].sort(reverse=True)
arr[0] += [0]
arr[1] += [1]
arr[2] += [2]
arr.sort()
(arr[0][0], arr[0][1]) = (arr[0][1], arr[0][0])
(arr[1][0], arr[1][1]) = (arr[1][1], arr[1][0])
(arr[2][0], arr[2][1]) = (arr[2][1], arr[2][0])
kol = p - arr[2][0]
for i in range(2):
	for j in range(2):
		if arr[0][i] == arr[1][j] == kol and arr[0][1 - i] + arr[1][1 - j] == p:
			ans = (((c[arr[2][2]] + '') * p).__str__() + '\n') * arr[2][0]
			ans += ((c[arr[0][2]] + '') * arr[0][1 - i] + (c[arr[1][2]] + '') * arr[1][1 - j] + '\n') * kol
			print(p)
			print(ans)
			exit()
print('-1')


def possible(arr):
	(a, b, c, d, e, f) = arr
	if a == c == e and b + d + f == a:
		one = 'A' * b + 'B' * d + 'C' * f
		print(a)
		for i in range(a):
			print(one)
		return True
	if b == d == f and a + c + e == d:
		print(b)
		for i in range(a):
			print('A' * b)
		for i in range(c):
			print('B' * b)
		for i in range(e):
			print('C' * b)
		return True
	ns = [(a, b, 'A'), (c, d, 'B'), (e, f, 'C')]
	fs = [(b, a, 'A'), (d, c, 'B'), (f, e, 'C')]
	ns.sort(reverse=True)
	(x, y, z) = ns
	(a, b, t1) = x
	(c, d, t2) = y
	(e, f, t3) = z
	if c + e == a and d == f and (d + b == a):
		print(a)
		mat = [['.' for i in range(a)] for j in range(a)]
		for i in range(a):
			for j in range(b):
				mat[i][j] = t1
		for i in range(c):
			for j in range(b, a):
				mat[i][j] = t2
		for i in range(c, a):
			for j in range(b, a):
				mat[i][j] = t3
		for i in range(a):
			print(''.join(mat[i]))
		return True
	fs.sort(reverse=True)
	(x, y, z) = fs
	(b, a, t1) = x
	(d, c, t2) = y
	(f, e, t3) = z
	if d + f == b and c == e and (c + a == b):
		print(b)
		mat = [['.' for i in range(b)] for j in range(b)]
		for i in range(a):
			for j in range(b):
				mat[i][j] = t1
		for i in range(a, b):
			for j in range(d):
				mat[i][j] = t2
		for i in range(a, b):
			for j in range(d, b):
				mat[i][j] = t3
		for i in range(b):
			print(''.join(mat[i]))
		return True
	return False
arr = [int(x) for x in input().split()]
cnt = 0
ok = False
for i in range(8):
	send = [x for x in arr]
	if i & 1:
		(send[0], send[1]) = (send[1], send[0])
	if i & 2:
		(send[2], send[3]) = (send[3], send[2])
	if i & 4:
		(send[4], send[5]) = (send[5], send[4])
	if possible(send):
		ok = True
		break
if not ok:
	print(-1)


v = list(map(int, input().split()))

def funk(a):
	if a[0] == a[2] + a[4] and a[1] + a[3] == a[0] and (a[3] == a[5]):
		print(a[0])
		for i in range(a[1]):
			print('A' * a[0])
		for i in range(a[3]):
			print('B' * a[2] + 'C' * a[4])
	elif a[0] == a[2] == a[4] and a[1] + a[3] + a[5] == a[0]:
		print(a[0])
		for i in range(a[1]):
			print('A' * a[0])
		for i in range(a[3]):
			print('B' * a[2])
		for i in range(a[5]):
			print('C' * a[4])
	elif a[0] + a[2] + a[4] == a[1] and a[1] == a[3] == a[5]:
		print(a[1])
		for i in range(a[1]):
			print('A' * a[0] + 'B' * a[2] + 'C' * a[4])
	elif a[0] + a[2] == a[4] and a[1] == a[3] and (a[1] + a[5] == a[4]):
		print(a[4])
		for i in range(a[1]):
			print('A' * a[0] + 'B' * a[2])
		for i in range(a[5]):
			print('C' * a[4])
	elif a[0] + a[2] == a[1] and a[2] == a[4] and (a[3] + a[5] == a[1]):
		print(a[1])
		for i in range(a[3]):
			print('A' * a[0] + 'B' * a[2])
		for i in range(a[5]):
			print('A' * a[0] + 'C' * a[4])
	elif a[0] + a[2] == a[3] and a[0] == a[4] and (a[1] + a[5] == a[3]):
		print(a[3])
		for i in range(a[1]):
			print('A' * a[0] + 'B' * a[2])
		for i in range(a[5]):
			print('C' * a[4] + 'B' * a[2])
	else:
		return 0
	return 1
s = 0
for i in range(2):
	(v[0], v[1]) = (v[1], v[0])
	for i1 in range(2):
		(v[2], v[3]) = (v[3], v[2])
		for i2 in range(2):
			(v[4], v[5]) = (v[5], v[4])
			if s == 0:
				s = funk(v)
			if s:
				break
if s == 0:
	print('-1')


(a1, a2, b1, b2, c1, c2) = map(int, input().split())
l = max([a1, a2, b1, b2, c1, c2])
if a1 * a2 + b1 * b2 + c1 * c2 != l ** 2:
	print(-1)
else:
	if a1 > a2:
		(a1, a2) = (a2, a1)
	if b1 > b2:
		(b1, b2) = (b2, b1)
	if c1 > c2:
		(c1, c2) = (c2, c1)
	if a2 == b2 and b2 == c2:
		print(l)
		for i in range(a1):
			print('A' * a2)
		for i in range(b1):
			print('B' * b2)
		for i in range(c1):
			print('C' * c2)
	else:
		ls = [[a1, a2, 'A'], [b1, b2, 'B'], [c1, c2, 'C']]
		if b2 == l:
			(ls[0], ls[1]) = (ls[1], ls[0])
		if c2 == l:
			(ls[0], ls[2]) = (ls[2], ls[0])
		valid = True
		if ls[1][0] == ls[2][0]:
			pass
		elif ls[1][1] == ls[2][1]:
			(ls[1][0], ls[1][1]) = (ls[1][1], ls[1][0])
			(ls[2][0], ls[2][1]) = (ls[2][1], ls[2][0])
		elif ls[1][0] == ls[2][1]:
			(ls[2][0], ls[2][1]) = (ls[2][1], ls[2][0])
		elif ls[1][1] == ls[2][0]:
			(ls[1][0], ls[1][1]) = (ls[1][1], ls[1][0])
		else:
			valid = False
		if ls[1][0] + ls[0][0] != l or ls[1][1] + ls[2][1] != l:
			valid = False
		if not valid:
			print(-1)
		else:
			print(l)
			for i in range(ls[0][0]):
				print(ls[0][2] * l)
			for i in range(ls[1][0]):
				print(ls[1][2] * ls[1][1] + ls[2][2] * ls[2][1])


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)


ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(a, b, c, d, e, f) = kk()
al = [a, b, c, d, e, f]
s = sum(al)
area = a * b + c * d + e * f
side = int(area ** 0.5)
if side ** 2 != area or side not in al:
	print(-1)
	exit()
if al.count(side) == 3:
	if s == 4 * side:
		rest = [a for a in al if a != side]
		print(side)
		for _ in range(side):
			print(''.join(['A' * rest[0], 'B' * rest[1], 'C' * rest[2]]))
elif al.count(side) > 1:
	print(-1)
else:
	x = al.index(side)
	y = x ^ 1
	res = al[y]
	(a, b) = (min(x, y), max(x, y))
	s1 = 'ABC'[a // 2]
	s23 = [s for s in 'ABC' if s != s1]
	rest = al[:a] + al[b + 1:]
	res = side - res
	(a, b) = ([rest[0], rest[1]], [rest[2], rest[3]])
	if not (res in a and res in b):
		print(-1)
		exit()
	(o1, o2) = (a[a.index(res) ^ 1], b[b.index(res) ^ 1])
	print(side)
	for _ in range(al[y]):
		print(s1 * side)
	for _ in range(res):
		print(''.join([s23[0] * o1, s23[1] * o2]))


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)


(a, b, c, d, e, f) = map(int, input().split())
(n, n1) = (1, a * b + c * d + e * f)
while n ** 2 < n1:
	n += 1
if n ** 2 > n1:
	print(-1)
	exit()
l = sorted([[max(a, b), min(a, b), 'A'], [max(c, d), min(c, d), 'B'], [max(e, f), min(e, f), 'C']])
if l[2][0] != n:
	print(-1)
	exit()
v = str(n) + '\n' + (l[2][2] * n + '\n') * l[2][1]
if l[0][0] == n and l[1][0] == n:
	for i in range(2):
		v += (l[i][2] * n + '\n') * l[i][1]
else:
	s = n - l[2][1]
	if s not in l[0] or s not in l[1]:
		print(-1)
		exit()
	(x, y) = (l[0][1] if s == l[0][0] else l[0][0], l[1][1] if s == l[1][0] else l[1][0])
	v += (l[0][2] * x + l[1][2] * y + '\n') * s
print(v)


def print_if_possible(w, h):
	(xw, xh) = (max(w), max(h))
	(nw, nh) = (min(w), min(h))
	x = max(xw, xh)
	(wm, hm) = (w.count(xw), h.count(xh))
	if hm == 1 and xh == x:
		q = h.index(xh)
		(i, j) = ((q + 1) % 3, (q + 2) % 3)
		if xh != sum(w) - w[i] or h[q] != h[i] + h[j] or w[i] != w[j]:
			return False
		print(x)
		for yi in range(h[i]):
			print('%s%s' % ('ABC'[i] * w[i], 'ABC'[q] * w[q]))
		for yi in range(h[j]):
			print('%s%s' % ('ABC'[j] * w[j], 'ABC'[q] * w[q]))
		return True
	elif wm == 1 and xw == x:
		q = w.index(xw)
		(i, j) = ((q + 1) % 3, (q + 2) % 3)
		if xw != sum(h) - h[i] or w[q] != w[i] + w[j] or h[i] != h[j]:
			return False
		print(x)
		for yi in range(h[i]):
			print('%s%s' % ('ABC'[i] * w[i], 'ABC'[j] * w[j]))
		for yi in range(h[q]):
			print('ABC'[q] * w[q])
		return True
	elif wm == 3 and xw == sum(h):
		q = w.index(xw)
		(i, j) = ((q + 1) % 3, (q + 2) % 3)
		print(x)
		for yi in range(h[i]):
			print('ABC'[i] * w[i])
		for yi in range(h[j]):
			print('ABC'[j] * w[j])
		for yi in range(h[q]):
			print('ABC'[q] * w[q])
		return True
	elif hm == 3 and xh == sum(w):
		q = h.index(xh)
		(i, j) = ((q + 1) % 3, (q + 2) % 3)
		print(x)
		for yi in range(h[i]):
			print('%s%s%s' % ('ABC'[i] * w[i], 'ABC'[j] * w[j], 'ABC'[q] * w[q]))
		return True
	else:
		return False

def rec(i, w, h):
	if i == 3:
		if print_if_possible(w, h):
			return
		return
	rec(i + 1, w, h)
	(w[i], h[i]) = (h[i], w[i])
	rec(i + 1, w, h)
	(w[i], h[i]) = (h[i], w[i])
(w, h) = ([0, 0, 0], [0, 0, 0])
(w[0], h[0], w[1], h[1], w[2], h[2]) = [int(i) for i in input().split()]
rec(0, w, h)
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)


__author__ = 'User'

def f(arr, value, deep, vis):
	global flag
	if flag == True:
		return
	fl = False
	pos = (0, 0)
	for i in range(n):
		for j in range(n):
			if arr[i][j] == 0:
				pos = (i, j)
				fl = True
				break
		if fl == True:
			break
	symbol = value[2]
	for (y, x) in value[:-1]:
		tarr = arr[:]
		(y0, x0) = (pos[0], pos[1])
		if y0 < n and x0 < n and (arr[y0][x0] == 0):
			if x0 + x - 1 < n and y0 + y - 1 < n:
				tr = True
				for i in range(y0, y0 + y):
					for j in range(x0, x0 + x):
						if arr[i][j] != 0:
							tr = False
							break
						arr[i][j] = symbol
					if tr == False:
						break
				if tr:
					if deep == 0:
						print(n)
						flag = True
						for i in range(n):
							print(*arr[i], sep='')
						return
					for k in range(3):
						if vis[k] == 0:
							vis[k] = -1
							f(arr, val[k], deep - 1, vis)
				tr = True
				for i in range(y0, y0 + y):
					for j in range(x0, x0 + x):
						if arr[i][j] == symbol:
							arr[i][j] = 0
						else:
							tr = False
							break
					if tr == False:
						break
(x1, y1, x2, y2, x3, y3) = map(int, input().split())
val = [[(x1, y1), (y1, x1), 'A'], [(x2, y2), (y2, x2), 'B'], [(x3, y3), (y3, x3), 'C']]
s = x1 * y1 + x2 * y2 + x3 * y3
flag = True
mx = max(x1, x2, x3, y1, y2, y3)
if round(s ** (1 / 2)) == round(s ** (1 / 2), 8):
	n = int(s ** 0.5)
	if n < mx:
		flag = False
else:
	flag = False
if flag == True:
	flag = False
	arr = [n * [0] for i in range(n)]
	for i in range(3):
		deep = 3
		vis = [0] * 3
		vis[i] = -1
		f(arr, val[i], deep - 1, vis)
	if flag == False:
		print(-1)
else:
	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())


(x1, y1, x2, y2, x3, y3) = map(int, input().split())
(x1, y1) = (max(x1, y1), min(x1, y1))
(x2, y2) = (max(x2, y2), min(x2, y2))
(x3, y3) = (max(x3, y3), min(x3, y3))
(x1c, y1c, x2c, y2c, x3c, y3c) = (x1, y1, x2, y2, x3, y3)
if x2 == max(x1, x2, x3):
	(x1, y1, x2, y2) = (x2, y2, x1, y1)
elif x3 == max(x1, x2, x3):
	(x1, y1, x3, y3) = (x3, y3, x1, y1)
if x1 == x1c and y1 == y1c and (x2 == x2c) and (y2 == y2c):
	s1 = 'A'
	s2 = 'B'
	s3 = 'C'
elif x1 == x1c and y1 == y1c and (x2 == x3c) and (y2 == y3c):
	s1 = 'A'
	s2 = 'C'
	s3 = 'B'
elif x1 == x2c and y1 == y2c and (x2 == x1c) and (y2 == y1c):
	s1 = 'B'
	s2 = 'A'
	s3 = 'C'
elif x1 == x2c and y1 == y2c and (x2 == x3c) and (y2 == y3c):
	s1 = 'B'
	s2 = 'C'
	s3 = 'A'
elif x1 == x3c and y1 == y3c and (x2 == x1c) and (y2 == y1c):
	s1 = 'C'
	s2 = 'A'
	s3 = 'B'
elif x1 == x3c and y1 == y3c and (x2 == x2c) and (y2 == y2c):
	s1 = 'C'
	s2 = 'B'
	s3 = 'A'
if x1 == x2 == x3 and y1 + y2 + y3 == x1:
	print(x1)
	for i in range(x1):
		for j in range(x1):
			if i < y1:
				print(s1, end='')
			elif y1 <= i < y1 + y2:
				print(s2, end='')
			else:
				print(s3, end='')
		print()
elif x1 == y2 + x3 and x2 + y1 == y3 + y1 == x1:
	print(x1)
	for i in range(x1):
		for j in range(x1):
			if i < y1:
				print(s1, end='')
			elif j < y2:
				print(s2, end='')
			else:
				print(s3, end='')
		print()
elif x1 == x2 + y3 and y2 + y1 == x3 + y1 == x1:
	print(x1)
	for i in range(x1):
		for j in range(x1):
			if i < y1:
				print(s1, end='')
			elif j < x2:
				print(s2, end='')
			else:
				print(s3, end='')
		print()
elif x1 == x2 + x3 and y2 + y1 == y3 + y1 == x1:
	print(x1)
	for i in range(x1):
		for j in range(x1):
			if i < y1:
				print(s1, end='')
			elif j < x2:
				print(s2, end='')
			else:
				print(s3, end='')
		print()
elif x1 == y2 + y3 and x2 + y1 == x3 + y1 == x1:
	print(x1)
	for i in range(x1):
		for j in range(x1):
			if i < y1:
				print(s1, end='')
			elif j < y2:
				print(s2, end='')
			else:
				print(s3, end='')
		print()
else:
	print(-1)


(a, b, c, d, e, f) = map(int, input().split())
if a < b:
	(a, b) = (b, a)
if c < d:
	(c, d) = (d, c)
if e < f:
	(e, f) = (f, e)
sides = [[a, b, 'A'], [c, d, 'B'], [e, f, 'C']]
sides.sort(reverse=True)
(c1, c2, c3) = (sides[0][2], sides[1][2], sides[2][2])
area = a * b + c * d + e * f
if int(area ** 0.5) ** 2 != area:
	print(-1)
else:
	l = int(area ** 0.5)
	if l not in sides[0]:
		print(-1)
	elif l in sides[1] and l in sides[2]:
		print(l)
		for i in range(3):
			sides[i].remove(l)
		for i in range(3):
			for _ in range(sides[i][0]):
				print([c1, c2, c3][i] * l)
	else:
		r = l - sides[0][1]
		if r in sides[1] and r in sides[2]:
			print(l)
			for i in range(1, 3):
				sides[i].remove(r)
			for _ in range(sides[0][1]):
				print(c1 * l)
			for _ in range(r):
				print(c2 * sides[1][0] + c3 * sides[2][0])
		else:
			print(-1)


(x1, y1, x2, y2, x3, y3) = [int(s) for s in input().split()]

def print_logos(top, bottom, h1, h2):
	top_line = ''
	if 'a' in top:
		top_line += (x1 if top['a'] else y1) * 'A'
	if 'b' in top:
		top_line += (x2 if top['b'] else y2) * 'B'
	if 'c' in top:
		top_line += (x3 if top['c'] else y3) * 'C'
	print(len(top_line))
	for i in range(h1):
		print(top_line)
	bottom_line = ''
	if 'a' in bottom:
		bottom_line += (x1 if bottom['a'] else y1) * 'A'
	if 'b' in bottom:
		bottom_line += (x2 if bottom['b'] else y2) * 'B'
	if 'c' in bottom:
		bottom_line += (x3 if bottom['c'] else y3) * 'C'
	for i in range(h2):
		print(bottom_line)
done = False
for a in [True, False]:
	if done:
		break
	for b in [True, False]:
		if done:
			break
		for c in [True, False]:
			width = (x1 if a else y1) + (x2 if b else y2) + (x3 if c else y3)
			if width == (y1 if a else x1) and width == (y2 if b else x2) and (width == (y3 if c else x3)):
				print_logos({'a': a, 'b': b, 'c': c}, {}, y1 if a else x1, 0)
				done = True
				break
			width = (x1 if a else y1) + (x2 if b else y2)
			if width == (x3 if c else y3) and (y1 if a else x1) == (y2 if b else x2) and ((y1 if a else x1) + (y3 if c else x3) == width):
				print_logos({'a': a, 'b': b}, {'c': c}, y1 if a else x1, y3 if c else x3)
				done = True
				break
			width = (x1 if a else y1) + (x3 if c else y3)
			if width == (x2 if b else y2) and (y1 if a else x1) == (y3 if c else x3) and ((y1 if a else x1) + (y2 if b else x2) == width):
				print_logos({'a': a, 'c': c}, {'b': b}, y1 if a else x1, y2 if b else x2)
				done = True
				break
			width = (x3 if c else y3) + (x2 if b else y2)
			if width == (x1 if a else y1) and (y3 if c else x3) == (y2 if b else x2) and ((y1 if a else x1) + (y3 if c else x3) == width):
				print_logos({'b': b, 'c': c}, {'a': a}, y2 if b else x2, y1 if a else x1)
				done = True
				break
if not done:
	print(-1)


import time

def flag(a, b, c, d, e, f, X, Y, Z):
	if b == d and d == f and (a + c + e == b):
		m = [[0 for i in range(b)] for i in range(b)]
		for i in range(a):
			for j in range(b):
				m[i][j] = X
		for i in range(a, a + c):
			for j in range(b):
				m[i][j] = Y
		for i in range(a + c, a + c + e):
			for j in range(b):
				m[i][j] = Z
		return (b, m)
	return False

def frame(a, b, c, d, e, f, X, Y, Z):
	if a == c + e and a == b + d and (d == f):
		m = [[0 for i in range(a)] for i in range(a)]
		for i in range(a):
			for j in range(b):
				m[i][j] = X
		for i in range(c):
			for j in range(b, a):
				m[i][j] = Y
		for i in range(c, a):
			for j in range(b, a):
				m[i][j] = Z
		return (a, m)
	return False

def test0(a, b, c, d, e, f, X, Y, Z):
	ans = flag(a, b, c, d, e, f, X, Y, Z)
	if ans == False:
		ans = frame(a, b, c, d, e, f, X, Y, Z)
	return ans

def test(a, b, c, d, e, f, X, Y, Z):
	ans = test0(a, b, c, d, e, f, X, Y, Z)
	if ans == False:
		ans = test0(a, b, c, d, f, e, X, Y, Z)
	if ans == False:
		ans = test0(a, b, d, c, e, f, X, Y, Z)
	if ans == False:
		ans = test0(b, a, c, d, e, f, X, Y, Z)
	if ans == False:
		ans = test0(a, b, d, c, f, e, X, Y, Z)
	if ans == False:
		ans = test0(b, a, c, d, f, e, X, Y, Z)
	if ans == False:
		ans = test0(b, a, d, c, e, f, X, Y, Z)
	if ans == False:
		ans = test0(b, a, d, c, f, e, X, Y, Z)
	return ans
(a, b, c, d, e, f) = (int(i) for i in input().split())
start = time.time()
ans = test(a, b, c, d, e, f, 'A', 'B', 'C')
if ans == False:
	ans = test(c, d, a, b, e, f, 'B', 'A', 'C')
if ans == False:
	ans = test(e, f, a, b, c, d, 'C', 'A', 'B')
if ans == False:
	print(-1)
else:
	print(ans[0])
	for i in range(ans[0]):
		for j in range(ans[0]):
			print(ans[1][i][j], end='')
		print()
finish = time.time()


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)


(x1, y1, x2, y2, x3, y3) = list(map(int, input().split(' ')))
if x1 == x2 == x3 == y1 + y2 + y3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(y2):
		print(''.join(['B'] * x1))
	for i in range(y3):
		print(''.join(['C'] * x1))
elif x1 == x2 == y3 == y1 + y2 + x3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(y2):
		print(''.join(['B'] * x1))
	for i in range(x3):
		print(''.join(['C'] * x1))
elif x1 == y2 == x3 == y1 + x2 + y3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(x2):
		print(''.join(['B'] * x1))
	for i in range(y3):
		print(''.join(['C'] * x1))
elif x1 == y2 == y3 == y1 + x2 + x3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(x2):
		print(''.join(['B'] * x1))
	for i in range(x3):
		print(''.join(['C'] * x1))
elif y1 == y2 == y3 == x1 + x2 + x3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(x2):
		print(''.join(['B'] * y1))
	for i in range(x3):
		print(''.join(['C'] * y1))
elif y1 == y2 == x3 == x1 + x2 + y3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(x2):
		print(''.join(['B'] * y1))
	for i in range(y3):
		print(''.join(['C'] * y1))
elif y1 == x2 == y3 == x1 + y2 + x3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(y2):
		print(''.join(['B'] * y1))
	for i in range(x3):
		print(''.join(['C'] * y1))
elif y1 == x2 == x3 == x1 + y2 + y3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(y2):
		print(''.join(['B'] * y1))
	for i in range(y3):
		print(''.join(['C'] * y1))
elif x1 == x2 + x3 == y1 + y2 == y1 + y3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(y2):
		print(''.join(['B'] * x2 + ['C'] * x3))
elif x1 == x2 + y3 == y1 + y2 == y1 + x3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(y2):
		print(''.join(['B'] * x2 + ['C'] * y3))
elif x1 == y2 + x3 == y1 + x2 == y1 + y3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(x2):
		print(''.join(['B'] * y2 + ['C'] * x3))
elif x1 == y2 + y3 == y1 + x2 == y1 + x3:
	print(x1)
	for i in range(y1):
		print(''.join(['A'] * x1))
	for i in range(x2):
		print(''.join(['B'] * y2 + ['C'] * y3))
elif y1 == y2 + y3 == x1 + x2 == x1 + x3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(x2):
		print(''.join(['B'] * y2 + ['C'] * y3))
elif y1 == y2 + x3 == x1 + x2 == x1 + y3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(x2):
		print(''.join(['B'] * y2 + ['C'] * x3))
elif y1 == x2 + y3 == x1 + y2 == x1 + x3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(y2):
		print(''.join(['B'] * x2 + ['C'] * y3))
elif y1 == x2 + x3 == x1 + y2 == x1 + x3:
	print(y1)
	for i in range(x1):
		print(''.join(['A'] * y1))
	for i in range(y2):
		print(''.join(['B'] * x2 + ['C'] * x3))
elif x2 == x1 + x3 == y1 + y2 == y2 + y3:
	print(x2)
	for i in range(y2):
		print(''.join(['B'] * x2))
	for i in range(y1):
		print(''.join(['A'] * x1 + ['C'] * x3))
elif x2 == x1 + y3 == y1 + y2 == y2 + x3:
	print(x2)
	for i in range(y2):
		print(''.join(['B'] * x2))
	for i in range(y1):
		print(''.join(['A'] * x1 + ['C'] * y3))
elif x2 == y1 + x3 == x1 + y2 == y2 + y3:
	print(x2)
	for i in range(y2):
		print(''.join(['B'] * x2))
	for i in range(x1):
		print(''.join(['A'] * y1 + ['C'] * x3))
elif x2 == y1 + y3 == x1 + y2 == y2 + x3:
	print(x2)
	for i in range(y2):
		print(''.join(['B'] * x2))
	for i in range(x1):
		print(''.join(['A'] * y1 + ['C'] * y3))
elif y2 == y1 + y3 == x1 + x2 == x2 + x3:
	print(y2)
	for i in range(x2):
		print(''.join(['B'] * y2))
	for i in range(x1):
		print(''.join(['A'] * y1 + ['C'] * y3))
elif y2 == y1 + x3 == x1 + x2 == x2 + y3:
	print(y2)
	for i in range(x2):
		print(''.join(['B'] * y2))
	for i in range(x1):
		print(''.join(['A'] * y1 + ['C'] * x3))
elif y2 == x1 + y3 == y1 + x2 == x2 + x3:
	print(y2)
	for i in range(x2):
		print(''.join(['B'] * y2))
	for i in range(y1):
		print(''.join(['A'] * x1 + ['C'] * y3))
elif y2 == x1 + x3 == y1 + x2 == x2 + y3:
	print(y2)
	for i in range(x2):
		print(''.join(['B'] * y2))
	for i in range(y1):
		print(''.join(['A'] * x1 + ['C'] * x3))
elif x3 == x2 + x1 == y1 + y3 == y2 + y3:
	print(x3)
	for i in range(y3):
		print(''.join(['C'] * x3))
	for i in range(y1):
		print(''.join(['B'] * x2 + ['A'] * x1))
elif x3 == x2 + y1 == x1 + y3 == y2 + y3:
	print(x3)
	for i in range(y3):
		print(''.join(['C'] * x3))
	for i in range(x1):
		print(''.join(['B'] * x2 + ['A'] * y1))
elif x3 == y2 + x1 == y1 + y3 == x2 + y3:
	print(x3)
	for i in range(y3):
		print(''.join(['C'] * x3))
	for i in range(y1):
		print(''.join(['B'] * y2 + ['A'] * x1))
elif x3 == y2 + y1 == x1 + y3 == x2 + y3:
	print(x3)
	for i in range(y3):
		print(''.join(['C'] * x3))
	for i in range(x1):
		print(''.join(['B'] * y2 + ['A'] * y1))
elif y3 == y2 + y1 == x1 + x3 == x2 + x3:
	print(y3)
	for i in range(x3):
		print(''.join(['C'] * y3))
	for i in range(x1):
		print(''.join(['B'] * y2 + ['A'] * y1))
elif y3 == y2 + x1 == y1 + x3 == x2 + x3:
	print(y3)
	for i in range(x3):
		print(''.join(['C'] * y3))
	for i in range(y1):
		print(''.join(['B'] * y2 + ['A'] * x1))
elif y3 == x2 + y1 == x1 + x3 == y2 + x3:
	print(y3)
	for i in range(x3):
		print(''.join(['C'] * y3))
	for i in range(x1):
		print(''.join(['B'] * x2 + ['A'] * y1))
elif y3 == x2 + x1 == y1 + x3 == y2 + x3:
	print(y3)
	for i in range(x3):
		print(''.join(['C'] * y3))
	for i in range(y1):
		print(''.join(['B'] * x2 + ['A'] * x1))
else:
	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))


(x1, y1, x2, y2, x3, y3) = map(int, input().split())
rect1 = [x1, y1]
rect2 = [x2, y2]
rect3 = [x3, y3]

def func():
	rect11 = [x1, y1]
	rect22 = [x2, y2]
	rect33 = [x3, y3]
	rect1 = [x1, y1]
	rect2 = [x2, y2]
	rect3 = [x3, y3]
	recta = [x1, y1]
	rectb = [x2, y2]
	rectc = [x3, y3]
	for i in rect11:
		for ii in rect22:
			for iii in rect33:
				if i == ii:
					rect1.remove(i)
					rect2.remove(ii)
					if rect1[0] + rect2[0] == iii:
						rect3.remove(iii)
						if i + rect3[0] == iii:
							print(iii)
							for j in range(iii):
								if j < rect1[0]:
									print('C' * rect3[0] + 'A' * i)
								else:
									print('C' * rect3[0] + 'B' * ii)
							exit()
				rect1 = recta.copy()
				rect2 = rectb.copy()
				rect3 = rectc.copy()
				if i == iii:
					rect1.remove(i)
					rect3.remove(iii)
					if rect1[0] + rect3[0] == ii:
						rect2.remove(ii)
						if i + rect2[0] == ii:
							print(ii)
							for j in range(ii):
								if j < rect1[0]:
									print('B' * rect2[0] + 'A' * i)
								else:
									print('B' * rect2[0] + 'C' * iii)
							exit()
				rect1 = recta.copy()
				rect2 = rectb.copy()
				rect3 = rectc.copy()
				if ii == iii:
					rect2.remove(ii)
					rect3.remove(iii)
					if rect2[0] + rect3[0] == i:
						rect1.remove(i)
						if i == rect1[0] + ii:
							print(i)
							for j in range(i):
								if j < rect2[0]:
									print('A' * rect1[0] + 'B' * ii)
								else:
									print('A' * rect1[0] + 'C' * iii)
							exit()
				rect1 = recta.copy()
				rect2 = rectb.copy()
				rect3 = rectc.copy()
	return print(-1)
for i in rect1:
	for ii in rect2:
		for iii in rect3:
			recta = [x1, y1]
			rectb = [x2, y2]
			rectc = [x3, y3]
			if i == ii == iii:
				rect1.remove(i)
				rect2.remove(i)
				rect3.remove(i)
			if rect1[0] + rect2[0] + rect3[0] == i:
				print(i)
				for j in range(i):
					print('A' * rect1[0] + 'B' * rect2[0] + 'C' * rect3[0])
				exit()
			rect1 = recta
			rect2 = rectb
			rect3 = rectc
func()


import itertools
(x1, y1, x2, y2, x3, y3) = list(map(int, input().split(' ')[:6]))
(A, B, C) = ((x1, y1, 'A'), (x2, y2, 'B'), (x3, y3, 'C'))

def rot(X, do_rot):
	return (X[1], X[0], X[2]) if do_rot else X

def solve_1(A, B, C):
	w = A[0] + B[0] + C[0]
	if A[1] == B[1] == C[1] == w:
		res = [['' for j in range(w)] for i in range(w)]
		for i in range(w):
			for j in range(w):
				if j < A[0]:
					res[i][j] = A[2]
				elif j < A[0] + B[0]:
					res[i][j] = B[2]
				else:
					res[i][j] = C[2]
		return res

def solve_2(A, B, C):
	w = A[0] + B[0]
	if w == A[1] + C[1] and C[0] == w and (B[1] == A[1]):
		res = [['' for j in range(w)] for i in range(w)]
		for i in range(w):
			for j in range(w):
				if i < A[1]:
					if j < A[0]:
						res[i][j] = A[2]
					else:
						res[i][j] = B[2]
				else:
					res[i][j] = C[2]
		return res
for (I, J, K) in itertools.permutations([A, B, C]):
	for i in range(2):
		for j in range(2):
			for k in range(2):
				L = rot(I, i)
				M = rot(J, j)
				N = rot(K, k)
				v = solve_1(L, M, N)
				if not v:
					v = solve_2(L, M, N)
				if v:
					print(len(v))
					for l in v:
						print(''.join(map(str, l)))
					return
print(-1)


inp = input().split()
a = [int(inp[0]), int(inp[1])]
b = [int(inp[2]), int(inp[3])]
c = [int(inp[4]), int(inp[5])]
a.sort()
a.reverse()
a.append('A')
b.sort()
b.reverse()
b.append('B')
c.sort()
c.reverse()
c.append('C')
first = [a, b, c]
first.sort()
first.reverse()
second = [a, b, c]
second.sort()
second.reverse()
third = [a, b, c]

def swap(a):
	temp = a[0]
	a[0] = a[1]
	a[1] = temp

def check_first(x):
	fla = x[0][0] == x[1][0] + x[2][0]
	flb = x[1][1] == x[2][1] == x[0][0] - x[0][1]
	return fla and flb

def check_second(x):
	if x[0][0] == x[1][0] and x[0][1] + x[1][1] == x[2][0] == x[0][0]:
		return True
	else:
		return False
flag = False
ind = 0
res = -1
s = ''
while not flag:
	ind = 1
	if check_first(first):
		break
	swap(first[1])
	if check_first(first):
		break
	swap(first[2])
	if check_first(first):
		break
	swap(first[1])
	if check_first(first):
		break
	ind = 2
	if check_second(second):
		break
	swap(second[2])
	if check_second(second):
		break
	if third[0][0] == third[1][0] == third[2][0] and third[0][0] == third[0][1] + third[1][1] + third[2][1]:
		ind = 3
		break
	flag = True
if flag:
	print(-1)
elif ind == 1:
	print(first[0][0])
	for i in range(first[0][1]):
		print(first[0][2] * first[0][0])
	for i in range(first[1][1]):
		print(first[1][2] * first[1][0] + first[2][2] * first[2][0])
elif ind == 2:
	print(second[2][1])
	for i in range(second[0][1]):
		print(second[0][2] * second[0][0] + second[2][2] * second[2][0])
	for i in range(second[1][1]):
		print(second[1][2] * second[1][0] + second[2][2] * second[2][0])
elif ind == 3:
	print(third[0][0])
	for i in range(third[0][1]):
		print(third[0][2] * third[0][0])
	for i in range(third[1][1]):
		print(third[1][2] * third[0][0])
	for i in range(third[2][1]):
		print(third[2][2] * third[0][0])


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)


def chnge(last, cap, ini=(0, 0)):
	for i in range(ini[1], last[1]):
		fin[i][ini[0]:last[0]] = [cap] * (last[0] - ini[0])
(x1, y1, x2, y2, x3, y3) = map(int, input().split())
a = (max(x1, y1), [x1, y1], 'A')
b = (max(x2, y2), [x2, y2], 'B')
c = (max(x3, y3), [x3, y3], 'C')
m = max(a[0], b[0], c[0])
fin = [['*' for i in range(m)] for j in range(m)]
if x1 * y1 + x2 * y2 + x3 * y3 != m ** 2:
	print(-1)
else:
	l = sorted([a] + [b] + [c], reverse=True)
	l[0][1].sort(reverse=True)
	chnge(l[0][1], l[0][2])
	ini = [0, l[0][1][1]]
	last = l[1][1]
	if m in [ini[0] + last[0], ini[1] + last[1]] and ini[0] + last[0] + ini[1] + last[1] <= 2 * m:
		last = [ini[0] + last[0], ini[1] + last[1]]
	else:
		last = [ini[0] + last[1], ini[1] + last[0]]
	chnge(last, l[1][2], ini)
	chr = l[2][2]
	print(m)
	for i in fin:
		print(''.join(i).replace('*', chr))


from sys import *
inp = lambda : stdin.readline()

def main():
	(x1, y1, x2, y2, x3, y3) = map(int, inp().split())
	m = max(x1, x2, x3, y1, y2, y3)
	l = [(x1, y1), (x2, y2), (x3, y3)]
	ans = [['C' for i in range(m)] for i in range(m)]
	bools = True
	if all([m in x for x in l]):
		if min(x1, y1) + min(x2, y2) + min(x3, y3) != m:
			bools = False
		else:
			for i in range(0, min(x1, y1)):
				ans[i] = ['A' for i in range(m)]
			for i in range(min(x1, y1), min(x1, y1) + min(x2, y2)):
				ans[i] = ['B' for i in range(m)]
	elif x2 * y2 + x3 * y3 + x1 * y1 != m * m:
		bools = False
	elif m in l[0]:
		if not all([m - min(x1, y1) in i for i in [l[1], l[2]]]):
			bools = False
		else:
			for i in range(0, min(x1, y1)):
				ans[i] = ['A' for i in range(m)]
			if min(x2, y2) + min(x1, y1) == m:
				for i in range(min(x1, y1), m):
					ans[i] = ['B' for i in range(max(x2, y2))] + ['C' for i in range(m - max(x2, y2))]
			else:
				for i in range(min(x1, y1), m):
					ans[i] = ['B' for i in range(min(x2, y2))] + ['C' for i in range(m - min(x2, y2))]
	elif m in l[1]:
		if not all([m - min(x2, y2) in i for i in [l[0], l[2]]]):
			bools = False
		else:
			(x1, x2) = (x2, x1)
			(y1, y2) = (y2, y1)
			for i in range(0, min(x1, y1)):
				ans[i] = ['B' for i in range(m)]
			if min(x2, y2) + min(x1, y1) == m:
				for i in range(min(x1, y1), m):
					ans[i] = ['A' for i in range(max(x2, y2))] + ['C' for i in range(m - max(x2, y2))]
			else:
				for i in range(min(x1, y1), m):
					ans[i] = ['A' for i in range(min(x2, y2))] + ['C' for i in range(m - min(x2, y2))]
	elif m in l[2]:
		if not all([m - min(x3, y3) in i for i in [l[1], l[0]]]):
			bools = False
		else:
			(x1, x3) = (x3, x1)
			(y1, y3) = (y3, y2)
			for i in range(0, min(x1, y1)):
				ans[i] = ['C' for i in range(m)]
			if min(x2, y2) + min(x1, y1) == m:
				for i in range(min(x1, y1), m):
					ans[i] = ['B' for i in range(max(x2, y2))] + ['A' for i in range(m - max(x2, y2))]
			else:
				for i in range(min(x1, y1), m):
					ans[i] = ['B' for i in range(min(x2, y2))] + ['A' for i in range(m - min(x2, y2))]
	if bools:
		print(m)
		for i in ans:
			print(''.join(map(str, i)))
	else:
		print(-1)
main()