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>
using namespace std;
void Zero(int M, int N) {
  printf("0\n");
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) putchar('.');
    putchar('\n');
  }
}
void Print3(int N) {
  if (N == 3) {
    cout << 1 << endl;
    cout << "AAA" << endl;
    cout << ".A." << endl;
    cout << ".A." << endl;
  }
  if (N == 4) {
    cout << 1 << endl;
    cout << "AAA." << endl;
    cout << ".A.." << endl;
    cout << ".A.." << endl;
  }
  if (N == 5) {
    cout << 2 << endl;
    cout << "AAAB." << endl;
    cout << ".A.B." << endl;
    cout << ".ABBB" << endl;
  }
  if (N == 6) {
    cout << 2 << endl;
    cout << "AAAB.." << endl;
    cout << ".A.B.." << endl;
    cout << ".ABBB." << endl;
  }
  if (N == 7) {
    cout << 3 << endl;
    cout << "AAABCCC" << endl;
    cout << ".A.B.C." << endl;
    cout << ".ABBBC." << endl;
  }
  if (N == 8) {
    cout << 3 << endl;
    cout << "AAABCCC." << endl;
    cout << ".A.B.C.." << endl;
    cout << ".ABBBC.." << endl;
  }
  if (N == 9) {
    cout << 4 << endl;
    cout << "AAABCCCD." << endl;
    cout << ".A.B.C.D." << endl;
    cout << ".ABBBCDDD" << endl;
  }
}
void Print4(int N) {
  if (N == 3) {
    cout << 1 << endl;
    cout << "AAA" << endl;
    cout << ".A." << endl;
    cout << ".A." << endl;
    cout << "..." << endl;
  }
  if (N == 4) {
    cout << 2 << endl;
    cout << "AAA." << endl;
    cout << ".AB." << endl;
    cout << ".AB." << endl;
    cout << ".BBB" << endl;
  }
  if (N == 5) {
    cout << 2 << endl;
    cout << "AAA.." << endl;
    cout << ".AB.." << endl;
    cout << ".AB.." << endl;
    cout << ".BBB." << endl;
  }
  if (N == 6) {
    cout << 3 << endl;
    cout << "AAA..." << endl;
    cout << ".AB..C" << endl;
    cout << ".ABCCC" << endl;
    cout << ".BBB.C" << endl;
  }
  if (N == 7) {
    cout << 4 << endl;
    cout << "AAADDD." << endl;
    cout << ".AB.DC." << endl;
    cout << ".AB.DC." << endl;
    cout << ".BBBCCC" << endl;
  }
  if (N == 8) {
    cout << 4 << endl;
    cout << "A.BBBCCC" << endl;
    cout << "AAAB.DC." << endl;
    cout << "A..B.DC." << endl;
    cout << "....DDD." << endl;
  }
  if (N == 9) {
    cout << 5 << endl;
    cout << "AAACCC..." << endl;
    cout << ".AB.CD..E" << endl;
    cout << ".AB.CDEEE" << endl;
    cout << ".BBBDDD.E" << endl;
  }
}
void Print5(int N) {
  if (N == 3) {
    cout << 2 << endl;
    cout << "A.." << endl;
    cout << "AAA" << endl;
    cout << "A.B" << endl;
    cout << "BBB" << endl;
    cout << "..B" << endl;
  }
  if (N == 4) {
    cout << 2 << endl;
    cout << "A..." << endl;
    cout << "AAA." << endl;
    cout << "A..B" << endl;
    cout << ".BBB" << endl;
    cout << "...B" << endl;
  }
  if (N == 5) {
    cout << 4 << endl;
    cout << "AAA.B" << endl;
    cout << ".ABBB" << endl;
    cout << "CA.DB" << endl;
    cout << "CCCD." << endl;
    cout << "C.DDD" << endl;
  }
  if (N == 6) {
    cout << 4 << endl;
    cout << "AAA.B." << endl;
    cout << ".ABBB." << endl;
    cout << "CA.DB." << endl;
    cout << "CCCD.." << endl;
    cout << "C.DDD." << endl;
  }
  if (N == 7) {
    cout << 5 << endl;
    cout << "AAA.E.." << endl;
    cout << ".AEEE.." << endl;
    cout << "BA.CE.D" << endl;
    cout << "BBBCDDD" << endl;
    cout << "B.CCC.D" << endl;
  }
  if (N == 8) {
    cout << 6 << endl;
    cout << "AAA.F..E" << endl;
    cout << ".AFFFEEE" << endl;
    cout << "BA.CF.DE" << endl;
    cout << "BBBC..D." << endl;
    cout << "B.CCCDDD" << endl;
  }
  if (N == 9) {
    cout << 7 << endl;
    cout << "AAA.EEE.C" << endl;
    cout << ".AFFFECCC" << endl;
    cout << "DA.FGE.BC" << endl;
    cout << "DDDFG..B." << endl;
    cout << "D..GGGBBB" << endl;
  }
}
void Print6(int N) {
  if (N == 3) {
    cout << 2 << endl;
    cout << "A.." << endl;
    cout << "AAA" << endl;
    cout << "A.." << endl;
    cout << "B.." << endl;
    cout << "BBB" << endl;
    cout << "B.." << endl;
  }
  if (N == 4) {
    cout << 3 << endl;
    cout << "AAA." << endl;
    cout << ".AB." << endl;
    cout << ".AB." << endl;
    cout << "CBBB" << endl;
    cout << "CCC." << endl;
    cout << "C..." << endl;
  }
  if (N == 5) {
    cout << 4 << endl;
    cout << "AAA.B" << endl;
    cout << ".ABBB" << endl;
    cout << "CA..B" << endl;
    cout << "CCC.D" << endl;
    cout << "C.DDD" << endl;
    cout << "....D" << endl;
  }
  if (N == 6) {
    cout << 5 << endl;
    cout << "AAA..C" << endl;
    cout << ".ABCCC" << endl;
    cout << ".ABBBC" << endl;
    cout << ".EBDDD" << endl;
    cout << ".E..D." << endl;
    cout << "EEE.D." << endl;
  }
  if (N == 7) {
    cout << 6 << endl;
    cout << "AAAD..." << endl;
    cout << ".ABDDDE" << endl;
    cout << ".ABDEEE" << endl;
    cout << "CBBB.FE" << endl;
    cout << "CCCFFF." << endl;
    cout << "C....F." << endl;
  }
  if (N == 8) {
    cout << 7 << endl;
    cout << "AAAD..E." << endl;
    cout << ".A.DEEE." << endl;
    cout << "BADDD.EF" << endl;
    cout << "BBBCGFFF" << endl;
    cout << "BCCCGGGF" << endl;
    cout << "...CG..." << endl;
  }
  if (N == 9) {
    cout << 8 << endl;
    cout << "AAABCCCD." << endl;
    cout << ".A.B.C.D." << endl;
    cout << ".ABBBCDDD" << endl;
    cout << ".EFFFGHHH" << endl;
    cout << ".E.F.G.H." << endl;
    cout << "EEEFGGGH." << endl;
  }
}
void Print7(int N) {
  if (N == 3) {
    cout << 3 << endl;
    cout << "A.." << endl;
    cout << "AAA" << endl;
    cout << "A.B" << endl;
    cout << "BBB" << endl;
    cout << "C.B" << endl;
    cout << "CCC" << endl;
    cout << "C.." << endl;
  }
  if (N == 4) {
    cout << 4 << endl;
    cout << "A..." << endl;
    cout << "AAAB" << endl;
    cout << "ABBB" << endl;
    cout << "C..B" << endl;
    cout << "CCCD" << endl;
    cout << "CDDD" << endl;
    cout << "...D" << endl;
  }
  if (N == 5) {
    cout << 5 << endl;
    cout << "AAA.B" << endl;
    cout << ".ABBB" << endl;
    cout << "CA..B" << endl;
    cout << "CCC.D" << endl;
    cout << "CEDDD" << endl;
    cout << ".EEED" << endl;
    cout << ".E..." << endl;
  }
  if (N == 6) {
    cout << 6 << endl;
    cout << "AAADDD" << endl;
    cout << ".A..D." << endl;
    cout << "BA..DE" << endl;
    cout << "BBBEEE" << endl;
    cout << "BC..FE" << endl;
    cout << ".C..F." << endl;
    cout << "CCCFFF" << endl;
  }
  if (N == 7) {
    cout << 8 << endl;
    cout << "AAADEEE" << endl;
    cout << ".A.D.E." << endl;
    cout << "BADDDEF" << endl;
    cout << "BBBGFFF" << endl;
    cout << "BC.G.HF" << endl;
    cout << ".CGGGH." << endl;
    cout << "CCC.HHH" << endl;
  }
  if (N == 8) {
    cout << 9 << endl;
    cout << "A..III.H" << endl;
    cout << "AAABIHHH" << endl;
    cout << "ABBBIG.H" << endl;
    cout << "CCCBEGGG" << endl;
    cout << ".CD.EGF." << endl;
    cout << ".CDEEEF." << endl;
    cout << ".DDD.FFF" << endl;
  }
  if (N == 9) {
    cout << 10 << endl;
    cout << "AAADIII.J" << endl;
    cout << ".A.D.IJJJ" << endl;
    cout << "BADDDIG.J" << endl;
    cout << "BBBEGGG.." << endl;
    cout << "BC.E.FG.H" << endl;
    cout << ".CEEEFHHH" << endl;
    cout << "CCC.FFF.H" << endl;
  }
}
void Print8(int N) {
  if (N == 3) {
    cout << 3 << endl;
    cout << "A.." << endl;
    cout << "AAA" << endl;
    cout << "A.B" << endl;
    cout << "BBB" << endl;
    cout << "C.B" << endl;
    cout << "CCC" << endl;
    cout << "C.." << endl;
    cout << "..." << endl;
  }
  if (N == 4) {
    cout << 4 << endl;
    cout << "A..." << endl;
    cout << "AAAB" << endl;
    cout << "ABBB" << endl;
    cout << "C..B" << endl;
    cout << "CCCD" << endl;
    cout << "CDDD" << endl;
    cout << "...D" << endl;
    cout << "...." << endl;
  }
  if (N == 5) {
    cout << 6 << endl;
    cout << "AAA.B" << endl;
    cout << ".ABBB" << endl;
    cout << "CA.DB" << endl;
    cout << "CCCD." << endl;
    cout << "C.DDD" << endl;
    cout << "E..F." << endl;
    cout << "EEEF." << endl;
    cout << "E.FFF" << endl;
  }
  if (N == 6) {
    cout << 7 << endl;
    cout << "AAAD.." << endl;
    cout << ".A.DDD" << endl;
    cout << "BA.D.E" << endl;
    cout << "BBBEEE" << endl;
    cout << "B.FFFE" << endl;
    cout << "C..FG." << endl;
    cout << "CCCFG." << endl;
    cout << "C..GGG" << endl;
  }
  if (N == 7) {
    cout << 9 << endl;
    cout << "AAAD..C" << endl;
    cout << ".A.DCCC" << endl;
    cout << "BADDDEC" << endl;
    cout << "BBBEEE." << endl;
    cout << "BGGG.EH" << endl;
    cout << ".FGIHHH" << endl;
    cout << ".FGIIIH" << endl;
    cout << "FFFI..." << endl;
  }
  if (N == 8) {
    cout << 10 << endl;
    cout << "AAA.BCCC" << endl;
    cout << ".ABBBEC." << endl;
    cout << "DA.GBEC." << endl;
    cout << "DDDGEEEF" << endl;
    cout << "DHGGGFFF" << endl;
    cout << ".H.I.J.F" << endl;
    cout << "HHHI.JJJ" << endl;
    cout << "..IIIJ.." << endl;
  }
  if (N == 9) {
    cout << 12 << endl;
    cout << "A.BBBD..." << endl;
    cout << "AAABCDDDE" << endl;
    cout << "A.FBCDEEE" << endl;
    cout << "FFFCCCG.E" << endl;
    cout << "K.FJJJGGG" << endl;
    cout << "KKKLJIG.H" << endl;
    cout << "KLLLJIHHH" << endl;
    cout << "...LIII.H" << endl;
  }
}
void Print9(int N) {
  if (N == 3) {
    cout << 4 << endl;
    cout << "A.." << endl;
    cout << "AAA" << endl;
    cout << "A.B" << endl;
    cout << "BBB" << endl;
    cout << "C.B" << endl;
    cout << "CCC" << endl;
    cout << "C.D" << endl;
    cout << "DDD" << endl;
    cout << "..D" << endl;
  }
  if (N == 4) {
    cout << 5 << endl;
    cout << "A..." << endl;
    cout << "AAAB" << endl;
    cout << "ABBB" << endl;
    cout << "C..B" << endl;
    cout << "CCCD" << endl;
    cout << "CDDD" << endl;
    cout << "E..D" << endl;
    cout << "EEE." << endl;
    cout << "E..." << endl;
  }
  if (N == 5) {
    cout << 7 << endl;
    cout << "AAA.B" << endl;
    cout << ".ABBB" << endl;
    cout << "EA..B" << endl;
    cout << "EEE.F" << endl;
    cout << "EGFFF" << endl;
    cout << ".GGGF" << endl;
    cout << "DG.C." << endl;
    cout << "DDDC." << endl;
    cout << "D.CCC" << endl;
  }
  if (N == 6) {
    cout << 8 << endl;
    cout << "A..E.." << endl;
    cout << "AAAEEE" << endl;
    cout << "A.BE.F" << endl;
    cout << "BBBFFF" << endl;
    cout << "C.BG.F" << endl;
    cout << "CCCGGG" << endl;
    cout << "C.DG.H" << endl;
    cout << "DDDHHH" << endl;
    cout << "..D..H" << endl;
  }
  if (N == 7) {
    cout << 10 << endl;
    cout << "AAA..J." << endl;
    cout << ".A.JJJ." << endl;
    cout << "BAIIIJH" << endl;
    cout << "BBBIHHH" << endl;
    cout << "B.CI.GH" << endl;
    cout << "CCCGGG." << endl;
    cout << "D.CE.GF" << endl;
    cout << "DDDEFFF" << endl;
    cout << "D.EEE.F" << endl;
  }
  if (N == 8) {
    cout << 12 << endl;
    cout << "AAAFGGG." << endl;
    cout << ".A.F.GH." << endl;
    cout << "BAFFFGH." << endl;
    cout << "BBBDIHHH" << endl;
    cout << "BDDDIIIJ" << endl;
    cout << "CCCDIJJJ" << endl;
    cout << ".CEKKKLJ" << endl;
    cout << ".CE.K.L." << endl;
    cout << ".EEEKLLL" << endl;
  }
  if (N == 9) {
    cout << 13 << endl;
    cout << "AAAKKK..." << endl;
    cout << ".AB.KLMMM" << endl;
    cout << ".AB.KL.M." << endl;
    cout << "CBBBLLLMJ" << endl;
    cout << "CCCFFFJJJ" << endl;
    cout << "CDDDFIIIJ" << endl;
    cout << ".EDGF.IH." << endl;
    cout << ".EDGGGIH." << endl;
    cout << "EEEG..HHH" << endl;
  }
}
int main() {
  int M, N;
  scanf("%d%d", &M, &N);
  if (M < 3 || N < 3)
    Zero(M, N);
  else if (M == 3)
    Print3(N);
  else if (M == 4)
    Print4(N);
  else if (M == 5)
    Print5(N);
  else if (M == 6)
    Print6(N);
  else if (M == 7)
    Print7(N);
  else if (M == 8)
    Print8(N);
  else if (M == 9)
    Print9(N);
  return 0;
};