5089: 三个标志

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:6 通过:4

题目描述

三家公司决定订购一块印有其标志图片的广告牌。广告牌是一块方形的大板子。每个公司的徽标是一个非零区域的矩形。

只有在广告牌上可以放置所有三个标志,使它们不重叠,并且广告牌上没有剩余空间的情况下,广告商才会张贴广告。当您在广告牌上放置徽标时,应旋转它,使其两侧与广告牌的两侧平行。

你的任务是确定是否有可能在不违反任何规定的情况下,将这三家公司的标志放在某个方形广告牌上。

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 x1,y1,x2,y2,x3,y3 (1≤x1,y1,x2,y2,x3,y3≤100), where xi and yi 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

输入格式

输入的第一行包含六个正整数x1y1x2y2x3y31≤x1yx2y2x3y3≤100),其中xiyi分别确定第i家公司徽标的长度和宽度。

输出格式

如果不可能将所有三个徽标都放在方形盾牌上,请打印一个整数“-1”(不带引号)。

如果可能的话,在第一行中打印正方形n的边的长度,您可以在其中放置所有三个徽标。接下来的n行中的每一行应包含n个大写英文字母“A”“B”“C”。相同字母组应形成实心矩形,前提是:

由字母“A”组成的矩形的大小应等于第一家公司的标志的大小,

由字母“B”组成的矩形的大小应该等于第二家公司的标志的大小,

由字母“C”组成的矩形的大小应等于第三家公司的标志的大小,

请注意,公司的徽标可以旋转以在广告牌上打印。广告牌上不能有空白。如果一个正方形的广告牌可以用多种方式填充徽标,您可以打印其中任何一个。

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



输入样例 复制

5 1 2 5 5 2

输出样例 复制

5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC