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>
#pragma comment(linker, "/STACK:32000000")
using namespace std;
const long double PI = 3.141592653589793238462643l;
bool fig[5][3][3] = {{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
                     {{1, 1, 1}, {0, 1, 0}, {0, 1, 0}},
                     {{0, 0, 1}, {1, 1, 1}, {0, 0, 1}},
                     {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}},
                     {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}}};
map<pair<int, int>, pair<int, pair<int, vector<int> > > > ans;
int m;
pair<int, pair<int, vector<int> > > make(int n, int msk) {
  pair<int, int> pr = make_pair(n, msk);
  if (ans.count(pr)) {
    return ans[pr];
  }
  pair<int, pair<int, vector<int> > > res =
      make_pair(0, make_pair(0, vector<int>(0)));
  if (n == 0) {
    ans[pr] = res;
    return res;
  }
  vector<vector<vector<int> > > fil(m - 1);
  fil[0] = vector<vector<int> >(1);
  for (int i = 0; i < int(m - 2); i++) {
    for (int k = 0; k < int(fil[i].size()); k++) {
      for (int t = 0; t < int(5); t++) {
        bool ok = 1;
        for (int dx = 0; dx < int(2); dx++) {
          for (int dy = 0; dy < int(3); dy++) {
            if (fig[t][dx][dy] && (msk & (1 << (dx * m + i + dy)))) {
              ok = 0;
            }
          }
        }
        for (int s = 0; s < int(3); s++) {
          if (i > 0) {
            if (fig[t][s][0] && fig[fil[i][k][i - 1]][s][1]) {
              ok = 0;
            }
            if (fig[t][s][1] && fig[fil[i][k][i - 1]][s][2]) {
              ok = 0;
            }
          }
          if (i > 1) {
            if (fig[t][s][0] && fig[fil[i][k][i - 2]][s][2]) {
              ok = 0;
            }
          }
        }
        if (ok) {
          vector<int> newv = fil[i][k];
          newv.push_back(t);
          fil[i + 1].push_back(newv);
        }
      }
    }
  }
  for (int i = 0; i < int(fil[m - 2].size()); i++) {
    int msk1 = msk >> m;
    int c = 0;
    for (int j = 0; j < int(m - 2); j++) {
      if (fil[m - 2][i][j]) {
        c++;
      }
      for (int x = 0; x < int(2); x++) {
        for (int y = 0; y < int(3); y++) {
          if (fig[fil[m - 2][i][j]][x + 1][y]) {
            msk1 += (1 << (x * m + j + y));
          }
        }
      }
    }
    pair<int, pair<int, vector<int> > > res1 =
        make_pair(c + make(n - 1, msk1).first, make_pair(msk1, fil[m - 2][i]));
    res = max(res, res1);
  }
  ans[pr] = res;
  return res;
}
int main() {
  int n;
  cin >> n >> m;
  if (n < 3 || m < 3) {
    cout << 0 << endl;
    for (int i = 0; i < int(n); i++) {
      for (int j = 0; j < int(m); j++) {
        cout << '.';
      }
      cout << endl;
    }
    return 0;
  }
  pair<int, pair<int, vector<int> > > res = make(n - 2, 0);
  int ret = res.first;
  vector<vector<char> > c(n, vector<char>(m, '.'));
  int k = 0;
  for (int i = 0; i < int(n - 2); i++) {
    for (int j = 0; j < int(m - 2); j++) {
      for (int x = 0; x < int(3); x++) {
        for (int y = 0; y < int(3); y++) {
          if (fig[res.second.second[j]][x][y]) {
            c[i + x][j + y] = 'A' + k;
          }
        }
      }
      if (res.second.second[j]) {
        k++;
      }
    }
    res = ans[make_pair(n - 3 - i, res.second.first)];
  }
  cout << ret << endl;
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(m); j++) {
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}