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: interview

Starter code:

Solutions:
import sys


def get_sol(a, b, c, n, reverse):
	#1
	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

#sys.stdin = open('input.txt')
#sys.stdout = open('output.txt', 'w')

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)


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
    # solve a ra[1]-ra[0] x ra[1] rectangle with 2 remaining rectangles
    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)


import sys

#this solves only a specific orientation
#is fine because we consider all orientations
import itertools


def can(h1, w1, h2, w2, h3, w3, c1, c2, c3, tot):
    #height = h1
    if tot % h1 == 0 and tot // h1 == h1:
        # side by side or on top of each other are the two options
        # side by side
        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
                    else:
                        if 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()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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()
#print(finish - start)


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)


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))
#1
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))
#2
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))
#3
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)



def main():
    mode="filee"
    if mode=="file":p=open("test.txt","r")
    #f.readline()
    #input()
    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()


def __starting_point():
    main()

__starting_point()

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


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')
    return

k = 0
for i in a:
    if i == p:
        k += 1

if k == 0 or k == 2:
    print('-1')
    return

b = list()
ans = ''
if (k == 3):
    for i in a:
        if i != p:
            b.append(i)
    if sum(b) != p:
        print('-1')
        return
    for i in range(p):
        for j in range(3):
            ans += (c[j] * b[j])
        ans += '\n'
    print(p)
    print(ans)
    return

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)
            return
print('-1')

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)

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


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()
    else:
        if 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)
        return
    bt = x2 + y3
    if (bt == a) and (y2 == a - b) and (x3 == a - b):
        out(2, a, b, x2, y2, y3, x3, 1)
        return
    bt = y2 + x3
    if (bt == a) and (x2 == a - b) and (y3 == a - b):
        out(2, a, b, y2, x2, x3, y3, 1)
        return
    bt = y2 + y3
    if (bt == a) and (x2 == a - b) and (x3 == a - b):
        out(2, a, b, y2, x2, y3, x3, 1)
        return

    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)
        return
    bt = x1 + y3
    if (bt == a) and (y1 == a - b) and (x3 == a - b):
        out(2, x1, y1, a, b, y3, x3, 2)
        return
    bt = y1 + x3
    if (bt == a) and (x1 == a - b) and (y3 == a - b):
        out(2, y1, x1, a, b, x3, y3, 2)
        return
    bt = y1 + y3
    if (bt == a) and (x1 == a - b) and (x3 == a - b):
        out(2, y1, x1, a, b, y3, x3, 2)
        return

    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)
        return
    bt = x2 + y1
    if (bt == a) and (y2 == a - b) and (x1 == a - b):
        out(2, y1, x1, x2, y2, a, b, 3)
        return
    bt = y2 + x1
    if (bt == a) and (x2 == a - b) and (y1 == a - b):
        out(2, x1, y1, y2, x2, a, b, 3)
        return
    bt = y2 + y1
    if (bt == a) and (x2 == a - b) and (x1 == a - b):
        out(2, y1, x1, y2, x2, a, b, 3)
        return


x1, y1, x2, y2, x3, y3 = [int(x) for x in input().split()]
b = check1(x1, y1, x2, y2, x3, y3)
if b:
    return
b = check2(x1, y1, x2, y2, x3, y3)
if b:
    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]
#print(first)
#print(second)

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

def check_first(x):
    #print(x)
    fla = (x[0][0] == x[1][0] + x[2][0])
    #print(x[0][0], "==", x[1][0], "+", x[2][0])
    #print(fla)
    flb = (x[1][1] == x[2][1] == (x[0][0] - x[0][1]))
    #print(x[1][1], "==", x[2][1], "==", x[0][0] - x[0][1])
    #print(flb)
    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 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="")
                
               # print(i, j, k)
                return

                
                
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="")
            return
#print(r)
# not possible, return - 1


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]: # flip logo 1
    if done:
        break
    for b in [True, False]: # flip logo 2
        if done: break

        for c in [True, False]: # flip logo 3
            # try 3 side-by-side
            width  = (x1 if a else y1) + (x2 if b else y2) + (x3 if c else y3)
            # all heights are correct
            if width == (y1 if a else x1) and \
               width == (y2 if b else x2) and \
               width == (y3 if c else x3):
                   # success!
                   print_logos({'a': a, 'b': b, 'c': c}, {}, y1 if a else x1, 0)
                   done = True
                   break

            # otherwise, try combinations [a, b] c, [a, c] b and [b, c] a

            # [a, b], c
            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

            # [a, c], b
            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

            # [b, c], a
            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)


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:
		#~ print('-1')
		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')

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)


__author__ = 'User'
def f(arr, value, deep, vis):
    nonlocal flag
    if flag == True:
        return
    fl = False
    #print("Num")
    pos = (0, 0)
    for i in range(n):
        for j in range(n):
            #print(i, j, arr[i][j], end = " ")
            if arr[i][j] == 0:
                pos = (i, j)
                fl = True
                break
        if fl == True:
            break
    #print()    
    #print(n, "N")    
    #print(arr, "AAAAAA")
    #print(pos, vis)
    symbol = value[2]
    for y, x in value[:-1]:
        #print(y, x, "YX" + symbol)
        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:
                    """print(tr)
                    for i in range(n):
                        print(*tarr[i])
    
                    print()"""                   
                    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
                            #print(tarr, val[k], deep - 1, vis)
                            f(arr, val[k], deep - 1, vis)
                    """
                    for i in range(n):
                        print(*arr[i])  
                    print()
                    """
                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
        #print(n, "N")
        f(arr, val[i], deep - 1, vis)
    if flag == False:
        print(-1)
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:
                        # AAA
                        # BBB
                        # CCC
                        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:
                        # AAA
                        # BBC
                        # BBC
                        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()


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 = '')
            else :
                if 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 = '')
            else :
                if 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 = '')
            else :
                if 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 = '')
            else :
                if j < y2 :
                    print(s2, end = '')
                else :
                    print(s3, end = '')                 
        print()
else :
    print(-1)



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 = '')
			else :
				if 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 = '')
			else :
				if 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 = '')
			else :
				if 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 = '')
			else :
				if j < y2 :
					print(s2, end = '')
				else :
					print(s3, end = '')					
		print()
else :
	print(-1)


"""
Codeforces Round #322 (Div. 2)

Problem 581 D. Three Logos

@author yamaton
@date 2015-10-06
"""

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)

    # case1: stacking
    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)])

    # case2: spliting
    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()

__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
else:
    if 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)

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)