Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.

He's got problems with some particularly large piece of equipment, which is, of course, turboplows. The problem is that when a turboplow is stored, it takes up not some simply rectangular space. It takes up a T-shaped space like on one of the four pictures below (here character "#" stands for the space occupied by the turboplow and character "." stands for the free space):
    
    
    ###      ..#      .#.      #..  
    .#.      ###      .#.      ###  
    .#.      ..#      ###      #..  
    

Simon faced a quite natural challenge: placing in the given n × m cells warehouse the maximum number of turboplows. As one stores the turboplows, he can rotate them in any manner (so that they take up the space like on one of the four pictures above). However, two turboplows cannot "overlap", that is, they cannot share the same cell in the warehouse.

Simon feels that he alone cannot find the optimal way of positioning the plugs in the warehouse that would maximize their quantity. Can you help him?

Input

The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9).

Output

In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turboplows in your scheme) to mark place for the corresponding turboplows considering that they are positioned in the optimal manner in the warehouse. The order in which you number places for the turboplows does not matter. If there are several optimal solutions for a warehouse of the given size, print any of them.

Examples

Input

3 3


Output

1
AAA
.A.
.A.


Input

5 6


Output

4
A..C..
AAAC..
ABCCCD
.B.DDD
BBB..D


Input

2 2


Output

0
..
..

Difficulty: HARD
Tags: Dynamic programming

Complete search
Skill types: Dynamic programming

Complete search

Starter code:

Solutions:
(n, m) = map(int, input().split())
swapped = False
if n < m:
	(n, m) = (m, n)
	swapped = True
ans = ''
if n == 1 and m == 1:
	ans = '0\n.'
if n == 2 and m == 1:
	ans = '0\n.\n.'
if n == 2 and m == 2:
	ans = '0\n..\n..'
if n == 3 and m == 1:
	ans = '0\n.\n.\n.'
if n == 3 and m == 2:
	ans = '0\n..\n..\n..'
if n == 3 and m == 3:
	ans = '1\n.A.\n.A.\nAAA'
if n == 4 and m == 1:
	ans = '0\n.\n.\n.\n.'
if n == 4 and m == 2:
	ans = '0\n..\n..\n..\n..'
if n == 4 and m == 3:
	ans = '1\n.A.\n.A.\nAAA\n...'
if n == 4 and m == 4:
	ans = '2\n...A\nBAAA\nBBBA\nB...'
if n == 5 and m == 1:
	ans = '0\n.\n.\n.\n.\n.'
if n == 5 and m == 2:
	ans = '0\n..\n..\n..\n..\n..'
if n == 5 and m == 3:
	ans = '2\n..A\nAAA\n.BA\n.B.\nBBB'
if n == 5 and m == 4:
	ans = '2\n.A..\n.A..\nAAAB\n.BBB\n...B'
if n == 5 and m == 5:
	ans = '4\nBBB.A\n.BAAA\nDB.CA\nDDDC.\nD.CCC'
if n == 6 and m == 1:
	ans = '0\n.\n.\n.\n.\n.\n.'
if n == 6 and m == 2:
	ans = '0\n..\n..\n..\n..\n..\n..'
if n == 6 and m == 3:
	ans = '2\n.A.\n.A.\nAAA\n.B.\n.B.\nBBB'
if n == 6 and m == 4:
	ans = '3\n.A..\n.A..\nAAAB\nCBBB\nCCCB\nC...'
if n == 6 and m == 5:
	ans = '4\n.A..B\n.ABBB\nAAACB\n.D.C.\n.DCCC\nDDD..'
if n == 6 and m == 6:
	ans = '5\n.A..B.\n.ABBB.\nAAACB.\nECCCD.\nEEECD.\nE..DDD'
if n == 7 and m == 1:
	ans = '0\n.\n.\n.\n.\n.\n.\n.'
if n == 7 and m == 2:
	ans = '0\n..\n..\n..\n..\n..\n..\n..'
if n == 7 and m == 3:
	ans = '3\n..A\nAAA\nB.A\nBBB\nBC.\n.C.\nCCC'
if n == 7 and m == 4:
	ans = '4\n...A\nBAAA\nBBBA\nB..C\nDCCC\nDDDC\nD...'
if n == 7 and m == 5:
	ans = '5\n.A..B\n.ABBB\nAAACB\n.CCC.\n.D.CE\n.DEEE\nDDD.E'
if n == 7 and m == 6:
	ans = '6\n.A..B.\n.ABBB.\nAAACB.\nEEECCC\n.EDC.F\n.EDFFF\n.DDD.F'
if n == 7 and m == 7:
	ans = '8\nB..ACCC\nBBBA.C.\nBDAAACE\n.DDDEEE\nGDHHHFE\nGGGH.F.\nG..HFFF'
if n == 8 and m == 1:
	ans = '0\n.\n.\n.\n.\n.\n.\n.\n.'
if n == 8 and m == 2:
	ans = '0\n..\n..\n..\n..\n..\n..\n..\n..'
if n == 8 and m == 3:
	ans = '3\n.A.\n.A.\nAAA\n..B\nBBB\n.CB\n.C.\nCCC'
if n == 8 and m == 4:
	ans = '4\n.A..\n.A..\nAAAB\nCBBB\nCCCB\nCD..\n.D..\nDDD.'
if n == 8 and m == 5:
	ans = '6\n.A..B\n.ABBB\nAAACB\nDDDC.\n.DCCC\nFD.E.\nFFFE.\nF.EEE'
if n == 8 and m == 6:
	ans = '7\n.A..B.\n.ABBB.\nAAA.BC\nDDDCCC\n.DGGGC\n.DFGE.\nFFFGE.\n..FEEE'
if n == 8 and m == 7:
	ans = '9\nB..ACCC\nBBBA.C.\nBDAAACE\n.DDDEEE\nFD.IIIE\nFFFHIG.\nFHHHIG.\n...HGGG'
if n == 9 and m == 8:
	ans = '12\n.A..BDDD\n.ABBBCD.\nAAAEBCD.\nFEEECCCG\nFFFEHGGG\nFKKKHHHG\n.IKLH.J.\n.IKLLLJ.\nIIIL.JJJ'
if n == 8 and m == 8:
	ans = '10\n.A..BCCC\n.A..B.C.\nAAABBBCD\nE.GGGDDD\nEEEGJJJD\nEF.GIJH.\n.FIIIJH.\nFFF.IHHH'
if n == 9 and m == 9:
	ans = '13\nAAA.BCCC.\n.ABBB.CD.\n.AE.BFCD.\nEEEFFFDDD\nG.E.HFIII\nGGGJHHHI.\nGK.JHL.IM\n.KJJJLMMM\nKKK.LLL.M'
if n == 9 and m == 1:
	ans = '0\n.\n.\n.\n.\n.\n.\n.\n.\n.'
if n == 9 and m == 2:
	ans = '0\n..\n..\n..\n..\n..\n..\n..\n..\n..'
if n == 9 and m == 3:
	ans = '4\n..A\nAAA\nB.A\nBBB\nB.C\nCCC\n.DC\n.D.\nDDD'
if n == 9 and m == 4:
	ans = '5\n.A..\n.A..\nAAAB\nCBBB\nCCCB\nC..D\nEDDD\nEEED\nE...'
if n == 9 and m == 5:
	ans = '7\n.A..B\n.ABBB\nAAACB\nDCCC.\nDDDCF\nDEFFF\n.E.GF\nEEEG.\n..GGG'
if n == 9 and m == 6:
	ans = '8\n.A..B.\n.ABBB.\nAAACB.\nECCCD.\nEEECD.\nE.GDDD\n.FGGGH\n.FGHHH\nFFF..H'
if n == 9 and m == 7:
	ans = '10\n.ACCC.B\n.A.CBBB\nAAACD.B\n...EDDD\nFEEED.G\nFFFEGGG\nFHJJJIG\n.H.J.I.\nHHHJIII'
if swapped:
	cnt = ans.split('\n')[0]
	lst = ans.split('\n')[1:]
	ans = ''
	for j in range(m):
		for i in range(n):
			ans = ans + lst[i][j]
		ans += '\n'
	ans = cnt + '\n' + ans
print(ans)


r = {}
r[1, 1] = '0\n.\n'
r[1, 2] = '0\n..\n'
r[1, 3] = '0\n...\n'
r[1, 4] = '0\n....\n'
r[1, 5] = '0\n.....\n'
r[1, 6] = '0\n......\n'
r[1, 7] = '0\n.......\n'
r[1, 8] = '0\n........\n'
r[1, 9] = '0\n.........\n'
r[2, 2] = '0\n..\n..\n'
r[2, 3] = '0\n...\n...\n'
r[2, 4] = '0\n....\n....\n'
r[2, 5] = '0\n.....\n.....\n'
r[2, 6] = '0\n......\n......\n'
r[2, 7] = '0\n.......\n.......\n'
r[2, 8] = '0\n........\n........\n'
r[2, 9] = '0\n.........\n.........\n'
r[3, 3] = '1\n.A.\n.A.\nAAA\n'
r[3, 4] = '1\n.A..\n.A..\nAAA.\n'
r[3, 5] = '2\nBBBA.\n.B.A.\n.BAAA\n'
r[3, 6] = '2\n.B.A..\n.B.AAA\nBBBA..\n'
r[3, 7] = '3\nA.BBBC.\nAAAB.C.\nA..BCCC\n'
r[3, 8] = '3\n.BCCC.A.\n.B.CAAA.\nBBBC..A.\n'
r[3, 9] = '4\nBBBDAAA.C\n.B.D.ACCC\n.BDDDA..C\n'
r[4, 4] = '2\nBBB.\n.BA.\n.BA.\n.AAA\n'
r[4, 5] = '2\n....A\n.BAAA\n.BBBA\n.B...\n'
r[4, 6] = '3\n..A...\n.CAAAB\n.CABBB\nCCC..B\n'
r[4, 7] = '4\n...ACCC\nBAAADC.\nBBBADC.\nB..DDD.\n'
r[4, 8] = '4\nBBB.A...\n.BD.AAAC\n.BD.ACCC\n.DDD...C\n'
r[4, 9] = '5\n...ACCC..\nDAAAECBBB\nDDDAEC.B.\nD..EEE.B.\n'
r[5, 5] = '4\nD.BBB\nDDDB.\nDA.BC\n.ACCC\nAAA.C\n'
r[5, 6] = '4\nA..DDD\nAAA.D.\nABBBDC\n..BCCC\n..B..C\n'
r[5, 7] = '5\n.A.EEE.\n.AAAEB.\nCA.DEB.\nCCCDBBB\nC.DDD..\n'
r[5, 8] = '6\nA..D.FFF\nAAADDDF.\nAB.DECF.\n.BEEECCC\nBBB.EC..\n'
r[5, 9] = '7\n..CAAAB..\nCCC.AGBBB\nF.CDAGBE.\nFFFDGGGE.\nF.DDD.EEE\n'
r[6, 6] = '5\nAAA...\n.ABCCC\n.AB.C.\nDBBBCE\nDDDEEE\nD....E\n'
r[6, 7] = '6\n..A...B\nAAA.BBB\nE.ADDDB\nEEECDF.\nECCCDF.\n...CFFF\n'
r[6, 8] = '7\nF.DDD..G\nFFFDBGGG\nF.ADBBBG\nAAAEBC..\n..AE.CCC\n..EEEC..\n'
r[6, 9] = '8\nF..AAAGGG\nFFFCA.BG.\nFCCCA.BG.\nHHHCDBBBE\n.HDDD.EEE\n.H..D...E\n'
r[7, 7] = '8\nH..AEEE\nHHHA.E.\nHDAAAEC\n.DDDCCC\nBDFFFGC\nBBBF.G.\nB..FGGG\n'
r[7, 8] = '9\nF.III..G\nFFFIAGGG\nFH.IAAAG\n.HHHADDD\nEHBBBCD.\nEEEB.CD.\nE..BCCC.\n'
r[7, 9] = '10\n...BJJJ.A\n.BBBGJAAA\nE..BGJC.A\nEEEGGGCCC\nEHDDDFC.I\n.H.D.FIII\nHHHDFFF.I\n'
r[8, 8] = '10\nA..BBB..\nAAAJBIII\nAH.JB.I.\n.HJJJGI.\nHHHC.GGG\nECCCDG.F\nEEECDFFF\nE..DDD.F\n'
r[8, 9] = '12\nDDDLLL..H\n.DC.LGHHH\n.DC.LGGGH\nECCCBGKKK\nEEEABBBK.\nEI.ABJ.KF\n.IAAAJFFF\nIII.JJJ.F\n'
r[9, 9] = '13\nK.DDDEMMM\nKKKD.E.M.\nKA.DEEEMF\n.AAALGFFF\nHALLLGGGF\nHHHBLGCCC\nHI.B..JC.\n.IBBB.JC.\nIII..JJJ.\n'
(n, m) = map(int, input().split())
if n < m:
	(print(r[n, m]),)
else:
	s = r[m, n].strip().split('\n')
	print(s[0])
	s = s[1:]
	s = zip(*s)
	for t in s:
		print(''.join(t))