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;
map<pair<int, int>, pair<int, vector<string>>> mp;
int main() {
  mp[make_pair(1, 1)] = make_pair(0, vector<string>{"."});
  mp[make_pair(1, 2)] = make_pair(0, vector<string>{".."});
  mp[make_pair(1, 3)] = make_pair(0, vector<string>{"..."});
  mp[make_pair(1, 4)] = make_pair(0, vector<string>{"...."});
  mp[make_pair(1, 5)] = make_pair(0, vector<string>{"....."});
  mp[make_pair(1, 6)] = make_pair(0, vector<string>{"......"});
  mp[make_pair(1, 7)] = make_pair(0, vector<string>{"......."});
  mp[make_pair(1, 8)] = make_pair(0, vector<string>{"........"});
  mp[make_pair(1, 9)] = make_pair(0, vector<string>{"........."});
  mp[make_pair(2, 1)] = make_pair(0, vector<string>{".", "."});
  mp[make_pair(2, 2)] = make_pair(0, vector<string>{"..", ".."});
  mp[make_pair(2, 3)] = make_pair(0, vector<string>{"...", "..."});
  mp[make_pair(2, 4)] = make_pair(0, vector<string>{"....", "...."});
  mp[make_pair(2, 5)] = make_pair(0, vector<string>{".....", "....."});
  mp[make_pair(2, 6)] = make_pair(0, vector<string>{"......", "......"});
  mp[make_pair(2, 7)] = make_pair(0, vector<string>{".......", "......."});
  mp[make_pair(2, 8)] = make_pair(0, vector<string>{"........", "........"});
  mp[make_pair(2, 9)] = make_pair(0, vector<string>{".........", "........."});
  mp[make_pair(3, 1)] = make_pair(0, vector<string>{".", ".", "."});
  mp[make_pair(3, 2)] = make_pair(0, vector<string>{"..", "..", ".."});
  mp[make_pair(3, 3)] = make_pair(1, vector<string>{"AAA", ".A.", ".A."});
  mp[make_pair(3, 4)] = make_pair(1, vector<string>{"AAA.", ".A..", ".A.."});
  mp[make_pair(3, 5)] = make_pair(2, vector<string>{"AAA.B", ".ABBB", ".A..B"});
  mp[make_pair(3, 6)] =
      make_pair(2, vector<string>{"AAABBB", ".A..B.", ".A..B."});
  mp[make_pair(3, 7)] =
      make_pair(3, vector<string>{"AAACBBB", ".A.C.B.", ".ACCCB."});
  mp[make_pair(3, 8)] =
      make_pair(3, vector<string>{"AAABBB.C", ".A..BCCC", ".A..B..C"});
  mp[make_pair(3, 9)] =
      make_pair(4, vector<string>{"AAADBBB.C", ".A.D.BCCC", ".ADDDB..C"});
  mp[make_pair(4, 1)] = make_pair(0, vector<string>{".", ".", ".", "."});
  mp[make_pair(4, 2)] = make_pair(0, vector<string>{"..", "..", "..", ".."});
  mp[make_pair(4, 3)] =
      make_pair(1, vector<string>{"AAA", ".A.", ".A.", "..."});
  mp[make_pair(4, 4)] =
      make_pair(2, vector<string>{"AAA.", ".AB.", ".AB.", ".BBB"});
  mp[make_pair(4, 5)] =
      make_pair(2, vector<string>{"AAA..", ".ABBB", ".A.B.", "...B."});
  mp[make_pair(4, 6)] =
      make_pair(3, vector<string>{"AAABBB", ".AC.B.", ".AC.B.", ".CCC.."});
  mp[make_pair(4, 7)] =
      make_pair(4, vector<string>{"AAAB...", ".ADBBBC", ".ADBCCC", ".DDD..C"});
  mp[make_pair(4, 8)] = make_pair(
      4, vector<string>{"AAABBB..", ".AD.BCCC", ".AD.B.C.", ".DDD..C."});
  mp[make_pair(4, 9)] = make_pair(
      5, vector<string>{"AAABBBCCC", ".AD.BE.C.", ".AD.BE.C.", ".DDDEEE.."});
  mp[make_pair(5, 1)] = make_pair(0, vector<string>{".", ".", ".", ".", "."});
  mp[make_pair(5, 2)] =
      make_pair(0, vector<string>{"..", "..", "..", "..", ".."});
  mp[make_pair(5, 3)] =
      make_pair(2, vector<string>{"AAA", ".A.", "BA.", "BBB", "B.."});
  mp[make_pair(5, 4)] =
      make_pair(2, vector<string>{"AAA.", ".A..", "BA..", "BBB.", "B..."});
  mp[make_pair(5, 5)] =
      make_pair(4, vector<string>{"AAA.B", ".ABBB", "CA.DB", "CCCD.", "C.DDD"});
  mp[make_pair(5, 6)] = make_pair(
      4, vector<string>{"AAABBB", ".A..B.", "CA.DB.", "CCCDDD", "C..D.."});
  mp[make_pair(5, 7)] = make_pair(
      5, vector<string>{"AAABBB.", ".A..BD.", "CA.EBD.", "CCCEDDD", "C.EEE.."});
  mp[make_pair(5, 8)] =
      make_pair(6, vector<string>{"AAABBB.C", ".A..BCCC", "DA.EB.FC",
                                  "DDDEEEF.", "D..E.FFF"});
  mp[make_pair(5, 9)] =
      make_pair(7, vector<string>{"AAABBBC..", ".A..BECCC", "DA.FBECG.",
                                  "DDDFEEEG.", "D.FFF.GGG"});
  mp[make_pair(6, 1)] =
      make_pair(0, vector<string>{".", ".", ".", ".", ".", "."});
  mp[make_pair(6, 2)] =
      make_pair(0, vector<string>{"..", "..", "..", "..", "..", ".."});
  mp[make_pair(6, 3)] =
      make_pair(2, vector<string>{"AAA", ".A.", "BA.", "BBB", "B..", "..."});
  mp[make_pair(6, 4)] = make_pair(
      3, vector<string>{"AAA.", ".A..", "BA..", "BBBC", "BCCC", "...C"});
  mp[make_pair(6, 5)] = make_pair(
      4, vector<string>{"AAA..", ".ABBB", "CA.B.", "CCCBD", "C.DDD", "....D"});
  mp[make_pair(6, 6)] =
      make_pair(5, vector<string>{"AAABBB", ".AC.B.", ".AC.B.", "DCCC.E",
                                  "DDDEEE", "D....E"});
  mp[make_pair(6, 7)] =
      make_pair(6, vector<string>{"AAA.BBB", ".AC..B.", ".ACCCB.", "E.CFDDD",
                                  "EEEF.D.", "E.FFFD."});
  mp[make_pair(6, 8)] =
      make_pair(7, vector<string>{"AAABBB..", ".AD.BCCC", ".AD.B.C.",
                                  "EDDDG.CF", "EEE.GFFF", "E..GGG.F"});
  mp[make_pair(6, 9)] =
      make_pair(8, vector<string>{"AAABBBCCC", ".AD.B..C.", ".AD.BE.C.",
                                  "FDDDHEEEG", "FFF.HEGGG", "F..HHH..G"});
  mp[make_pair(7, 1)] =
      make_pair(0, vector<string>{".", ".", ".", ".", ".", ".", "."});
  mp[make_pair(7, 2)] =
      make_pair(0, vector<string>{"..", "..", "..", "..", "..", "..", ".."});
  mp[make_pair(7, 3)] = make_pair(
      3, vector<string>{"AAA", ".A.", "BA.", "BBB", "B.C", "CCC", "..C"});
  mp[make_pair(7, 4)] = make_pair(
      4,
      vector<string>{"AAA.", ".AB.", ".AB.", "CBBB", "CCCD", "CDDD", "...D"});
  mp[make_pair(7, 5)] =
      make_pair(5, vector<string>{"AAA..", ".ABBB", "CA.B.", "CCCB.", "CEDDD",
                                  ".E.D.", "EEED."});
  mp[make_pair(7, 6)] =
      make_pair(6, vector<string>{"AAABBB", ".A..B.", "CA.DB.", "CCCDDD",
                                  "CE.DF.", ".EEEF.", ".E.FFF"});
  mp[make_pair(7, 7)] =
      make_pair(8, vector<string>{"AAA.BBB", ".ACCCB.", "DA.C.BE", "DDDCEEE",
                                  "DGFFFHE", ".G.F.H.", "GGGFHHH"});
  mp[make_pair(7, 8)] = make_pair(
      9, vector<string>{"AAA.BBB.", ".ACCCBE.", ".ADC.BE.", "DDDCFEEE",
                        "G.DIFFFH", "GGGIFHHH", "G.III..H"});
  mp[make_pair(7, 9)] = make_pair(
      10, vector<string>{"AAA.BBB..", ".ACCCBDDD", ".AECFB.D.", "EEECFFFDG",
                         "H.EJFIGGG", "HHHJ.IIIG", "H.JJJI..."});
  mp[make_pair(8, 1)] =
      make_pair(0, vector<string>{".", ".", ".", ".", ".", ".", ".", "."});
  mp[make_pair(8, 2)] = make_pair(
      0, vector<string>{"..", "..", "..", "..", "..", "..", "..", ".."});
  mp[make_pair(8, 3)] = make_pair(
      3,
      vector<string>{"AAA", ".A.", "BA.", "BBB", "B..", "CCC", ".C.", ".C."});
  mp[make_pair(8, 4)] =
      make_pair(4, vector<string>{"AAA.", ".A..", "BA..", "BBB.", "BCCC",
                                  ".DC.", ".DC.", "DDD."});
  mp[make_pair(8, 5)] =
      make_pair(6, vector<string>{"AAA..", ".ABBB", "CA.B.", "CCCBD", "C.DDD",
                                  "EEEFD", ".E.F.", ".EFFF"});
  mp[make_pair(8, 6)] =
      make_pair(7, vector<string>{"AAABBB", ".A..B.", "CA.DB.", "CCCDDD",
                                  "C.ED..", ".GEEEF", ".GEFFF", "GGG..F"});
  mp[make_pair(8, 7)] =
      make_pair(9, vector<string>{"AAA.BBB", ".ACCCB.", "DA.CEB.", "DDDCEEE",
                                  "DFFFE.G", ".IFHGGG", ".IFHHHG", "IIIH..."});
  mp[make_pair(8, 8)] = make_pair(
      10, vector<string>{"AAABBB..", ".A..BCCC", "DA..B.C.", "DDDEEECG",
                         "DFFFEGGG", ".IFHE.JG", ".IFHHHJ.", "IIIH.JJJ"});
  mp[make_pair(8, 9)] = make_pair(
      12, vector<string>{"AAA.BBB.D", ".ACCCBDDD", "EA.CFB.GD", "EEECFFFG.",
                         "E..HFIGGG", "JHHHLIIIK", "JJJHLIKKK", "J..LLL..K"});
  mp[make_pair(9, 1)] =
      make_pair(0, vector<string>{".", ".", ".", ".", ".", ".", ".", ".", "."});
  mp[make_pair(9, 2)] = make_pair(
      0, vector<string>{"..", "..", "..", "..", "..", "..", "..", "..", ".."});
  mp[make_pair(9, 3)] =
      make_pair(4, vector<string>{"AAA", ".A.", "BA.", "BBB", "B.C", "CCC",
                                  "D.C", "DDD", "D.."});
  mp[make_pair(9, 4)] =
      make_pair(5, vector<string>{"AAA.", ".A..", "BA..", "BBBC", "BCCC",
                                  "DDDC", ".DE.", ".DE.", ".EEE"});
  mp[make_pair(9, 5)] =
      make_pair(7, vector<string>{"AAA..", ".ABBB", "CA.B.", "CCCBD", "CEDDD",
                                  ".EEED", "GEFFF", "GGGF.", "G..F."});
  mp[make_pair(9, 6)] = make_pair(
      8, vector<string>{"AAABBB", ".A..B.", "CA.DB.", "CCCDDD", "C.ED..",
                        "EEEFFF", "G.EHF.", "GGGHF.", "G.HHH."});
  mp[make_pair(9, 7)] = make_pair(
      10, vector<string>{"AAABBB.", ".A..BD.", "CA.EBD.", "CCCEDDD", "CFEEE.G",
                         ".FFFGGG", "IFHHHJG", "IIIH.J.", "I..HJJJ"});
  mp[make_pair(9, 8)] =
      make_pair(12, vector<string>{"AAABBB.C", ".AD.BCCC", ".AD.B.EC",
                                   "FDDDEEE.", "FFFGGGEI", "FHHHGIII",
                                   ".KHJG.LI", ".KHJJJL.", "KKKJ.LLL"});
  mp[make_pair(9, 9)] =
      make_pair(13, vector<string>{"AAABBBCCC", ".AD.BE.C.", ".AD.BE.C.",
                                   "FDDDEEE.H", "FFFGGGHHH", "FIIIGJJJH",
                                   ".LIKG.JM.", ".LIKKKJM.", "LLLK..MMM"});
  int n, m;
  cin >> n >> m;
  pair<int, vector<string>> p = mp[make_pair(n, m)];
  cout << p.first << endl;
  for (int i = 0; i < n; i++) cout << p.second[i] << endl;
  return 0;
}