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;
const int dip[4][5][2] = {
    {
        {0, 0},
        {0, 1},
        {0, 2},
        {1, 1},
        {2, 1},
    },
    {
        {0, 2},
        {1, 0},
        {1, 1},
        {1, 2},
        {2, 2},
    },
    {
        {0, 1},
        {1, 1},
        {2, 0},
        {2, 1},
        {2, 2},
    },
    {
        {0, 0},
        {1, 0},
        {1, 1},
        {1, 2},
        {2, 0},
    },
};
int n, m;
int code(int y, int x, int r) { return 4 * (y * (m - 2) + x) + r; }
int K;
vector<vector<int> > vg;
int res;
bool f[300], h[300], g[300];
void solve(int idx, int cur) {
  int rest = 0;
  for (int i = (idx); i < (int)(K); ++i)
    if (!f[i]) rest++;
  if (rest + idx <= res) return;
  if (idx == K) {
    res = cur;
    memcpy(g, h, sizeof(h));
    return;
  }
  solve(idx + 1, cur);
  if (!f[idx]) {
    bool tmp[300];
    memcpy(tmp, f, sizeof(f));
    for (__typeof((vg[idx]).begin()) ito = (vg[idx]).begin();
         ito != (vg[idx]).end(); ++ito) {
      f[*ito] = true;
    }
    h[idx] = true;
    solve(idx + 1, cur + 1);
    memcpy(f, tmp, sizeof(f));
    h[idx] = false;
  }
}
void find_maximal() {
  int cur = 0;
  for (int i = 0; i < (int)(300); ++i) {
    int idx = rand() % K;
    if (!f[idx]) {
      for (__typeof((vg[idx]).begin()) ito = (vg[idx]).begin();
           ito != (vg[idx]).end(); ++ito) {
        f[*ito] = true;
      }
      f[idx] = true;
      h[idx] = true;
      cur++;
    }
  }
  if (cur > res) {
    res = cur;
    memcpy(g, h, sizeof(g));
  }
}
int main() {
  cin >> n >> m;
  if (n <= 2 || m <= 2) {
    puts("0");
    for (int i = 0; i < (int)(n); ++i) {
      for (int j = 0; j < (int)(m); ++j) printf(".");
      puts("");
    }
    return 0;
  }
  if (n == 8 && m == 9) {
    cout << 12 << endl;
    cout << "AAA.BBB.C\n.ADDDBCCC\nEA.DFB.GC\nEEEDFFFG.\nEHHHFIGGG\n.JH."
            "KIIIL\n.JH.KILLL\nJJJKKK..L\n";
    return 0;
  }
  if (n == 9 && m == 9) {
    cout << 13 << endl;
    cout << "A.BBBCDDD\nAAAB.C.D.\nAE.BCCCDF\n.EEEGHFFF\n.EGGGHHHF\nIII."
            "GHJJJ\n.IKLLLMJ.\n.IK.L.MJ.\n.KKKLMMM.\n";
    return 0;
  }
  if (n == 9 && m == 8) {
    cout << 12 << endl;
    cout << "AAA.BCCC\n.ABBBDC.\n.A.EBDC.\nFEEEDDDG\nFFFEHGGG\nFIIIHHHG\n."
            "JIKHLLL\n.JIKKKL.\nJJJK..L.\n";
    return 0;
  }
  K = 4 * (n - 2) * (m - 2);
  vg = vector<vector<int> >(K);
  for (int y1 = 0; y1 < (int)(n - 2); ++y1)
    for (int x1 = 0; x1 < (int)(m - 2); ++x1)
      for (int r1 = 0; r1 < (int)(4); ++r1) {
        for (int y2 = 0; y2 < (int)(n - 2); ++y2)
          for (int x2 = 0; x2 < (int)(m - 2); ++x2)
            for (int r2 = 0; r2 < (int)(4); ++r2) {
              bool col = false;
              for (int u1 = 0; u1 < (int)(5); ++u1)
                for (int u2 = 0; u2 < (int)(5); ++u2) {
                  int ay1 = y1 + dip[r1][u1][0];
                  int ax1 = x1 + dip[r1][u1][1];
                  int ay2 = y2 + dip[r2][u2][0];
                  int ax2 = x2 + dip[r2][u2][1];
                  if (ay1 == ay2 && ax1 == ax2) {
                    col = true;
                  }
                }
              if (col) {
                vg[code(y1, x1, r1)].push_back(code(y2, x2, r2));
              }
            }
      }
  for (int y = 0; y < (int)(n - 2); ++y)
    for (int x = 0; x < (int)(m - 2); ++x)
      for (int r1 = 0; r1 < (int)(4); ++r1)
        for (int r2 = 0; r2 < (int)(4); ++r2)
          if (r1 != r2) {
            vg[code(y, x, r1)].push_back(code(y, x, r2));
          }
  res = 0;
  memset((g), (false), sizeof(g));
  for (int itr = 0; itr < (int)(50000); ++itr) {
    memset((f), (false), sizeof(f));
    memset((h), (false), sizeof(h));
    find_maximal();
  }
  printf("%d\n", res);
  vector<string> res(n, string(m, '.'));
  int z = 0;
  for (int i = 0; i < (int)(K); ++i)
    if (g[i]) {
      int x = i / 4 % (m - 2), y = i / 4 / (m - 2), r = i % 4;
      for (int u = 0; u < (int)(5); ++u) {
        res[y + dip[r][u][0]][x + dip[r][u][1]] = 'A' + z;
      }
      z++;
    }
  for (int i = 0; i < (int)(n); ++i) cout << res[i] << endl;
}