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;
int n, m;
vector<string> res;
int result;
char s[10][10];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
bool inside(int a, int b) { return (0 <= a && a < m && 0 <= b && b < n); }
bool can_put(int a, int b, int dir) {
  if (!inside(a, b) || s[a][b] != '.') return false;
  int dl = (dir + 3) % 4, dr = (dir + 1) % 4;
  int al = a + dy[dl], bl = b + dx[dl];
  int ar = a + dy[dr], br = b + dx[dr];
  if (!inside(al, bl) || s[al][bl] != '.') return false;
  if (!inside(ar, br) || s[ar][br] != '.') return false;
  int am = a, bm = b;
  for (int i = 0; i < (2); i++) {
    am += dy[dir], bm += dx[dir];
    if (!inside(am, bm) || s[am][bm] != '.') return false;
  }
  return true;
}
void put_char(int a, int b, int dir, char ch) {
  s[a][b] = ch;
  int dl = (dir + 3) % 4, dr = (dir + 1) % 4;
  int al = a + dy[dl], bl = b + dx[dl];
  int ar = a + dy[dr], br = b + dx[dr];
  s[al][bl] = ch;
  s[ar][br] = ch;
  int am = a, bm = b;
  for (int i = 0; i < (2); i++) {
    am += dy[dir], bm += dx[dir];
    s[am][bm] = ch;
  }
}
void backtrack(int a, int b, int cc) {
  if (cc > result) {
    res.clear();
    result = cc;
    for (int i = 0; i < (m); i++) {
      string tmp = "";
      for (int j = 0; j < (n); j++) tmp += s[i][j];
      res.push_back(tmp);
    }
  }
  while (a < m) {
    while (b < n) {
      for (int dir = 0; dir < (4); dir++)
        if (can_put(a, b, dir)) {
          put_char(a, b, dir, 'A' + cc);
          backtrack(a, b, cc + 1);
          put_char(a, b, dir, '.');
        }
      ++b;
    }
    if (b == n) b = 0;
    ++a;
  }
}
int main() {
  scanf("%d%d", &m, &n);
  if (m == 6 && n == 9) {
    puts("8");
    puts("AAABBBCCC");
    puts(".AD.B..C.");
    puts(".AD.BE.C.");
    puts("FDDDHEEEG");
    puts("FFF.HEGGG");
    puts("F..HHH..G");
    return 0;
  } else if (m == 9 && n == 6) {
    puts("8");
    puts("AAABBB");
    puts(".A..B.");
    puts("CA.DB.");
    puts("CCCDDD");
    puts("C.ED..");
    puts("EEEFFF");
    puts("G.EHF.");
    puts("GGGHF.");
    puts("G.HHH.");
    return 0;
  } else if (m == 7 && n == 8) {
    puts("9");
    puts("AAA.BBB.");
    puts(".ACCCBE.");
    puts(".ADC.BE.");
    puts("DDDCFEEE");
    puts("G.DIFFFH");
    puts("GGGIFHHH");
    puts("G.III..H");
    return 0;
  } else if (m == 7 && n == 9) {
    puts("10");
    puts("AAA.BBB..");
    puts(".ACCCBDDD");
    puts("EA.C.BFD.");
    puts("EEECFFFD.");
    puts("EIGGGJF.H");
    puts(".I.G.JHHH");
    puts("IIIGJJJ.H");
    return 0;
  } else if (m == 8 && n == 7) {
    puts("9");
    puts("AAA.BBB");
    puts(".ACCCB.");
    puts("DA.CEB.");
    puts("DDDCEEE");
    puts("DFFFE.G");
    puts(".IFHGGG");
    puts(".IFHHHG");
    puts("IIIH...");
    return 0;
  } else if (m == 8 && n == 8) {
    puts("10");
    puts("AAABBB..");
    puts(".A..BCCC");
    puts("DA..B.C.");
    puts("DDDEEECG");
    puts("DFFFEGGG");
    puts(".IFHE.JG");
    puts(".IFHHHJ.");
    puts("IIIH.JJJ");
    return 0;
  } else if (m == 8 && n == 9) {
    puts("12");
    puts("AAABBB..C");
    puts(".AE.BDCCC");
    puts(".AE.BDDDC");
    puts("GEEEHDFFF");
    puts("GGGIHHHF.");
    puts("GK.IHL.FJ");
    puts(".KIIILJJJ");
    puts("KKK.LLL.J");
    return 0;
  } else if (m == 9 && n == 6) {
    puts("8");
    puts("AAABBB");
    puts(".A..B.");
    puts("CA.DB.");
    puts("CCCDDD");
    puts("C.ED..");
    puts("EEEFFF");
    puts("G.EHF.");
    puts("GGGHF.");
    puts("G.HHH.");
    return 0;
  } else if (m == 9 && n == 7) {
    puts("10");
    puts("AAABBB.");
    puts(".A..BD.");
    puts("CA.EBD.");
    puts("CCCEDDD");
    puts("CFEEE.G");
    puts(".FFFGGG");
    puts("IFHHHJG");
    puts("IIIH.J.");
    puts("I..HJJJ");
    return 0;
  } else if (m == 9 && n == 8) {
    puts("12");
    puts("AAABBB.C");
    puts(".AD.BCCC");
    puts(".AD.B.EC");
    puts("FDDDEEE.");
    puts("FFFGGGEI");
    puts("FHHHGIII");
    puts(".KHJG.LI");
    puts(".KHJJJL.");
    puts("KKKJ.LLL");
    return 0;
  } else if (m == 9 && n == 9) {
    puts("13");
    puts("AAABBBCCC");
    puts(".AD.BE.C.");
    puts(".AD.BE.C.");
    puts("FDDDEEE.H");
    puts("FFFGGGHHH");
    puts("FIIIGJJJH");
    puts(".LIKG.JM.");
    puts(".LIKKKJM.");
    puts("LLLK..MMM");
    return 0;
  }
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (n); j++) s[i][j] = '.';
  result = 0;
  for (int i = 0; i < (m); i++) {
    string tmp = "";
    for (int j = 0; j < (n); j++) tmp += '.';
    res.push_back(tmp);
  }
  backtrack(0, 0, 0);
  printf("%d\n", result);
  for (int i = 0; i < (m); i++) printf("%s\n", res[i].c_str());
  return 0;
}