Problem: 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
..
..

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  if (N == 1 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
  }
  if (N == 1 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
  }
  if (N == 2 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 3) {
    printf("%d\n", 0);
    printf("...\n");
  }
  if (N == 3 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 4) {
    printf("%d\n", 0);
    printf("....\n");
  }
  if (N == 4 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 5) {
    printf("%d\n", 0);
    printf(".....\n");
  }
  if (N == 5 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 6) {
    printf("%d\n", 0);
    printf("......\n");
  }
  if (N == 6 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 7) {
    printf("%d\n", 0);
    printf(".......\n");
  }
  if (N == 7 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 8) {
    printf("%d\n", 0);
    printf("........\n");
  }
  if (N == 8 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 1 && M == 9) {
    printf("%d\n", 0);
    printf(".........\n");
  }
  if (N == 9 && M == 1) {
    printf("%d\n", 0);
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
    printf(".\n");
  }
  if (N == 2 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 3) {
    printf("%d\n", 0);
    printf("...\n");
    printf("...\n");
  }
  if (N == 3 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 4) {
    printf("%d\n", 0);
    printf("....\n");
    printf("....\n");
  }
  if (N == 4 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 5) {
    printf("%d\n", 0);
    printf(".....\n");
    printf(".....\n");
  }
  if (N == 5 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 6) {
    printf("%d\n", 0);
    printf("......\n");
    printf("......\n");
  }
  if (N == 6 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 7) {
    printf("%d\n", 0);
    printf(".......\n");
    printf(".......\n");
  }
  if (N == 7 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 8) {
    printf("%d\n", 0);
    printf("........\n");
    printf("........\n");
  }
  if (N == 8 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 2 && M == 9) {
    printf("%d\n", 0);
    printf(".........\n");
    printf(".........\n");
  }
  if (N == 9 && M == 2) {
    printf("%d\n", 0);
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
    printf("..\n");
  }
  if (N == 3 && M == 3) {
    printf("%d\n", 1);
    printf("AAA\n");
    printf(".A.\n");
    printf(".A.\n");
  }
  if (N == 3 && M == 4) {
    printf("%d\n", 1);
    printf(".AAA\n");
    printf("..A.\n");
    printf("..A.\n");
  }
  if (N == 4 && M == 3) {
    printf("%d\n", 1);
    printf("...\n");
    printf("A..\n");
    printf("AAA\n");
    printf("A..\n");
  }
  if (N == 3 && M == 5) {
    printf("%d\n", 2);
    printf("AAAB.\n");
    printf(".A.B.\n");
    printf(".ABBB\n");
  }
  if (N == 5 && M == 3) {
    printf("%d\n", 2);
    printf("A..\n");
    printf("AAA\n");
    printf("A.B\n");
    printf("BBB\n");
    printf("..B\n");
  }
  if (N == 3 && M == 6) {
    printf("%d\n", 2);
    printf(".AAAB.\n");
    printf("..A.B.\n");
    printf("..ABBB\n");
  }
  if (N == 6 && M == 3) {
    printf("%d\n", 2);
    printf("...\n");
    printf("A..\n");
    printf("AAA\n");
    printf("A.B\n");
    printf("BBB\n");
    printf("..B\n");
  }
  if (N == 3 && M == 7) {
    printf("%d\n", 3);
    printf("AAABCCC\n");
    printf(".A.B.C.\n");
    printf(".ABBBC.\n");
  }
  if (N == 7 && M == 3) {
    printf("%d\n", 3);
    printf("A..\n");
    printf("AAA\n");
    printf("A.B\n");
    printf("BBB\n");
    printf("C.B\n");
    printf("CCC\n");
    printf("C..\n");
  }
  if (N == 3 && M == 8) {
    printf("%d\n", 3);
    printf(".AAABCCC\n");
    printf("..A.B.C.\n");
    printf("..ABBBC.\n");
  }
  if (N == 8 && M == 3) {
    printf("%d\n", 3);
    printf("...\n");
    printf("A..\n");
    printf("AAA\n");
    printf("A.B\n");
    printf("BBB\n");
    printf("C.B\n");
    printf("CCC\n");
    printf("C..\n");
  }
  if (N == 3 && M == 9) {
    printf("%d\n", 4);
    printf("AAABCCCD.\n");
    printf(".A.B.C.D.\n");
    printf(".ABBBCDDD\n");
  }
  if (N == 9 && M == 3) {
    printf("%d\n", 4);
    printf("A..\n");
    printf("AAA\n");
    printf("A.B\n");
    printf("BBB\n");
    printf("C.B\n");
    printf("CCC\n");
    printf("C.D\n");
    printf("DDD\n");
    printf("..D\n");
  }
  if (N == 4 && M == 4) {
    printf("%d\n", 2);
    printf(".AAA\n");
    printf(".BA.\n");
    printf(".BA.\n");
    printf("BBB.\n");
  }
  if (N == 4 && M == 5) {
    printf("%d\n", 2);
    printf(".....\n");
    printf("AAAB.\n");
    printf(".A.B.\n");
    printf(".ABBB\n");
  }
  if (N == 5 && M == 4) {
    printf("%d\n", 2);
    printf(".A..\n");
    printf(".AAA\n");
    printf(".A.B\n");
    printf(".BBB\n");
    printf("...B\n");
  }
  if (N == 4 && M == 6) {
    printf("%d\n", 3);
    printf("...AAA\n");
    printf("BBBCA.\n");
    printf(".B.CA.\n");
    printf(".BCCC.\n");
  }
  if (N == 6 && M == 4) {
    printf("%d\n", 3);
    printf(".B..\n");
    printf(".BBB\n");
    printf(".B.C\n");
    printf("ACCC\n");
    printf("AAAC\n");
    printf("A...\n");
  }
  if (N == 4 && M == 7) {
    printf("%d\n", 4);
    printf(".AAABBB\n");
    printf(".CA.DB.\n");
    printf(".CA.DB.\n");
    printf("CCCDDD.\n");
  }
  if (N == 7 && M == 4) {
    printf("%d\n", 4);
    printf("...C\n");
    printf("ACCC\n");
    printf("AAAC\n");
    printf("A..D\n");
    printf("BDDD\n");
    printf("BBBD\n");
    printf("B...\n");
  }
  if (N == 4 && M == 8) {
    printf("%d\n", 4);
    printf(".....AAA\n");
    printf("B.CCCDA.\n");
    printf("BBBC.DA.\n");
    printf("B..CDDD.\n");
  }
  if (N == 8 && M == 4) {
    printf("%d\n", 4);
    printf(".BBB\n");
    printf("..B.\n");
    printf(".CB.\n");
    printf(".CCC\n");
    printf(".C.D\n");
    printf("ADDD\n");
    printf("AAAD\n");
    printf("A...\n");
  }
  if (N == 4 && M == 9) {
    printf("%d\n", 5);
    printf("...AAABBB\n");
    printf("CCCDA.EB.\n");
    printf(".C.DA.EB.\n");
    printf(".CDDDEEE.\n");
  }
  if (N == 9 && M == 4) {
    printf("%d\n", 5);
    printf(".C..\n");
    printf(".CCC\n");
    printf(".C.D\n");
    printf("ADDD\n");
    printf("AAAD\n");
    printf("A..E\n");
    printf("BEEE\n");
    printf("BBBE\n");
    printf("B...\n");
  }
  if (N == 5 && M == 5) {
    printf("%d\n", 4);
    printf("AAA.B\n");
    printf(".ABBB\n");
    printf("CA.DB\n");
    printf("CCCD.\n");
    printf("C.DDD\n");
  }
  if (N == 5 && M == 6) {
    printf("%d\n", 4);
    printf("...AAA\n");
    printf(".BBBA.\n");
    printf(".CBDA.\n");
    printf(".CBDDD\n");
    printf("CCCD..\n");
  }
  if (N == 6 && M == 5) {
    printf("%d\n", 4);
    printf("....C\n");
    printf(".BCCC\n");
    printf(".BBBC\n");
    printf("ABDDD\n");
    printf("AAAD.\n");
    printf("A..D.\n");
  }
  if (N == 5 && M == 7) {
    printf("%d\n", 5);
    printf("..AAA.B\n");
    printf("CCCABBB\n");
    printf(".CDA.EB\n");
    printf(".CDDDE.\n");
    printf("..D.EEE\n");
  }
  if (N == 7 && M == 5) {
    printf("%d\n", 5);
    printf(".C...\n");
    printf(".CCC.\n");
    printf("ACDDD\n");
    printf("AAAD.\n");
    printf("AB.DE\n");
    printf(".BEEE\n");
    printf("BBB.E\n");
  }
  if (N == 5 && M == 8) {
    printf("%d\n", 6);
    printf("...AAA.B\n");
    printf(".CCCABBB\n");
    printf(".DCEA.FB\n");
    printf(".DCEEEF.\n");
    printf("DDDE.FFF\n");
  }
  if (N == 8 && M == 5) {
    printf("%d\n", 6);
    printf("....D\n");
    printf(".CDDD\n");
    printf(".CCCD\n");
    printf("ACEEE\n");
    printf("AAAE.\n");
    printf("AB.EF\n");
    printf(".BFFF\n");
    printf("BBB.F\n");
  }
  if (N == 5 && M == 9) {
    printf("%d\n", 7);
    printf(".AAAB.CCC\n");
    printf("..ADBBBC.\n");
    printf(".EADBF.CG\n");
    printf(".EDDDFGGG\n");
    printf("EEE.FFF.G\n");
  }
  if (N == 9 && M == 5) {
    printf("%d\n", 7);
    printf("....E\n");
    printf("A.EEE\n");
    printf("AAADE\n");
    printf("ADDD.\n");
    printf("BBBDF\n");
    printf(".BFFF\n");
    printf("CB.GF\n");
    printf("CCCG.\n");
    printf("C.GGG\n");
  }
  if (N == 6 && M == 6) {
    printf("%d\n", 5);
    printf("...AAA\n");
    printf("BBBCA.\n");
    printf(".B.CA.\n");
    printf("DBCCCE\n");
    printf("DDDEEE\n");
    printf("D....E\n");
  }
  if (N == 6 && M == 7) {
    printf("%d\n", 6);
    printf("....AAA\n");
    printf("BBB.CA.\n");
    printf(".BCCCA.\n");
    printf("DB.EC.F\n");
    printf("DDDEFFF\n");
    printf("D.EEE.F\n");
  }
  if (N == 7 && M == 6) {
    printf("%d\n", 6);
    printf(".B.DDD\n");
    printf(".BBBD.\n");
    printf(".BC.DE\n");
    printf("..CEEE\n");
    printf("ACCCFE\n");
    printf("AAA.F.\n");
    printf("A..FFF\n");
  }
  if (N == 6 && M == 8) {
    printf("%d\n", 7);
    printf(".......A\n");
    printf("B.CCCAAA\n");
    printf("BBBCDDDA\n");
    printf("BE.CFDG.\n");
    printf(".EFFFDG.\n");
    printf("EEE.FGGG\n");
  }
  if (N == 8 && M == 6) {
    printf("%d\n", 7);
    printf(".BBB.E\n");
    printf("..BEEE\n");
    printf(".CB.FE\n");
    printf(".CCCF.\n");
    printf(".CDFFF\n");
    printf(".ADDDG\n");
    printf(".ADGGG\n");
    printf("AAA..G\n");
  }
  if (N == 6 && M == 9) {
    printf("%d\n", 8);
    printf(".....ABBB\n");
    printf("C.DDDA.B.\n");
    printf("CCCDAAABE\n");
    printf("CF.DGHEEE\n");
    printf(".FGGGHHHE\n");
    printf("FFF.GH...\n");
  }
  if (N == 9 && M == 6) {
    printf("%d\n", 8);
    printf(".CCC.F\n");
    printf("..CFFF\n");
    printf(".DC.GF\n");
    printf(".DDDG.\n");
    printf(".DAGGG\n");
    printf("AAAHHH\n");
    printf("B.AEH.\n");
    printf("BBBEH.\n");
    printf("B.EEE.\n");
  }
  if (N == 7 && M == 7) {
    printf("%d\n", 8);
    printf("AAA.BBB\n");
    printf(".ACCCB.\n");
    printf("DA.C.BE\n");
    printf("DDDCEEE\n");
    printf("DFGGGHE\n");
    printf(".F.G.H.\n");
    printf("FFFGHHH\n");
  }
  if (N == 7 && M == 8) {
    printf("%d\n", 9);
    printf(".AAA.BBB\n");
    printf(".CADDDB.\n");
    printf(".CA.DEB.\n");
    printf("CCCFDEEE\n");
    printf("GFFFHE.I\n");
    printf("GGGFHIII\n");
    printf("G..HHH.I\n");
  }
  if (N == 8 && M == 7) {
    printf("%d\n", 9);
    printf("...CGGG\n");
    printf("ACCCFG.\n");
    printf("AAACFG.\n");
    printf("AD.FFFH\n");
    printf(".DDDHHH\n");
    printf("BDEEEIH\n");
    printf("BBBE.I.\n");
    printf("B..EIII\n");
  }
  if (N == 7 && M == 9) {
    printf("%d\n", 10);
    printf("..AAA.BBB\n");
    printf("CCCADDDB.\n");
    printf(".CEA.D.BF\n");
    printf(".CEEEDFFF\n");
    printf("G.EHIIIJF\n");
    printf("GGGH.I.J.\n");
    printf("G.HHHIJJJ\n");
  }
  if (N == 9 && M == 7) {
    printf("%d\n", 10);
    printf(".C..GGG\n");
    printf(".CCC.G.\n");
    printf("ACEEEGH\n");
    printf("AAAEHHH\n");
    printf("AD.EI.H\n");
    printf(".DDDIII\n");
    printf("BD.FI.J\n");
    printf("BBBFJJJ\n");
    printf("B.FFF.J\n");
  }
  if (N == 8 && M == 8) {
    printf("%d\n", 10);
    printf("...AAA.B\n");
    printf(".CCCABBB\n");
    printf(".DCEA.FB\n");
    printf(".DCEEEF.\n");
    printf("DDDEGFFF\n");
    printf("HHHIGGGJ\n");
    printf(".H.IGJJJ\n");
    printf(".HIII..J\n");
  }
  if (N == 8 && M == 9) {
    printf("%d\n", 12);
    printf("...ABBB.C\n");
    printf("DAAAEBCCC\n");
    printf("DDDAEBF.C\n");
    printf("D.GEEEFFF\n");
    printf("GGGHHHF.I\n");
    printf("J.GKHLIII\n");
    printf("JJJKHLLLI\n");
    printf("J.KKKL...\n");
  }
  if (N == 9 && M == 8) {
    printf("%d\n", 12);
    printf(".DDDGJJJ\n");
    printf(".AD.G.J.\n");
    printf(".ADGGGJK\n");
    printf("AAAEHKKK\n");
    printf("BEEEHHHK\n");
    printf("BBBEHLLL\n");
    printf("BCFFFIL.\n");
    printf(".C.F.IL.\n");
    printf("CCCFIII.\n");
  }
  if (N == 9 && M == 9) {
    printf("%d\n", 13);
    printf("....AAA.B\n");
    printf("C.DDDABBB\n");
    printf("CCCDEA.FB\n");
    printf("C.GDEFFF.\n");
    printf("GGGEEEHF.\n");
    printf("I.GJJJHHH\n");
    printf("IIIKJLH.M\n");
    printf("IKKKJLMMM\n");
    printf("...KLLL.M\n");
  }
  return 0;
}