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;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
           ? EOF
           : *p1++);
  bool flg = false;
  for (; ch < '0' || '9' < ch;
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
const int MAXN = 10 + 10;
const int MAXSTATUS = (1 << 9) + 10;
int n, m, f[MAXN][MAXSTATUS][MAXSTATUS];
pair<vector<pair<int, int> >, pair<int, int> > pre[MAXN][MAXSTATUS][MAXSTATUS];
const int dx[4][5] = {{-1, -1, -1, 0, 1},
                      {-1, 0, 0, 0, 1},
                      {-1, 0, 1, 1, 1},
                      {-1, 0, 0, 0, 1}},
          dy[4][5] = {{-1, 0, 1, 0, 0},
                      {-1, -1, 0, 1, -1},
                      {0, 0, -1, 0, 1},
                      {1, -1, 0, 1, 1}};
vector<pair<int, int> > curTrans;
int preIdx, preVal, preS1, preS2;
char fans[MAXN][MAXN];
void dfs(int S1, int S2, int S3, int i) {
  if (i == m - 1) {
    if (f[preIdx + 1][S2][S3] < preVal + (int)curTrans.size()) {
      f[preIdx + 1][S2][S3] = preVal + (int)curTrans.size();
      pre[preIdx + 1][S2][S3].first = curTrans;
      pre[preIdx + 1][S2][S3].second.first = preS1,
                   pre[preIdx + 1][S2][S3].second.second = preS2;
    }
    return;
  }
  for (int way = (0), wayend = (4); way < wayend; ++way) {
    bool ok = true;
    for (int j = (0), jend = (5); j < jend; ++j) {
      if (dx[way][j] == -1) {
        if ((((S1) >> (i + dy[way][j])) & 1)) ok = false;
      } else if (dx[way][j] == 0) {
        if ((((S2) >> (i + dy[way][j])) & 1)) ok = false;
      } else if ((((S3) >> (i + dy[way][j])) & 1)) {
        ok = false;
      }
    }
    if (ok) {
      for (int j = (0), jend = (5); j < jend; ++j) {
        if (dx[way][j] == -1)
          S1 |= 1 << (i + dy[way][j]);
        else if (dx[way][j] == 0)
          S2 |= 1 << (i + dy[way][j]);
        else
          S3 |= 1 << (i + dy[way][j]);
      }
      curTrans.push_back(make_pair(i, way));
      dfs(S1, S2, S3, i + 1);
      curTrans.pop_back();
      for (int j = (0), jend = (5); j < jend; ++j) {
        if (dx[way][j] == -1)
          S1 ^= 1 << (i + dy[way][j]);
        else if (dx[way][j] == 0)
          S2 ^= 1 << (i + dy[way][j]);
        else
          S3 ^= 1 << (i + dy[way][j]);
      }
    }
  }
  dfs(S1, S2, S3, i + 1);
}
int main() {
  IO::read(n), IO::read(m);
  if (min(n, m) <= 2) {
    puts("0");
    for (int i = (0), iend = (n); i < iend; ++i) {
      for (int j = (0), jend = (m); j < jend; ++j) putchar('.');
      puts("");
    }
    return 0;
  }
  memset(f, -1, sizeof f);
  f[0][0][0] = 0;
  for (int i = (0), iend = (n - 2); i < iend; ++i) {
    for (int S1 = (0), S1end = (1 << m); S1 < S1end; ++S1)
      for (int S2 = (0), S2end = (1 << m); S2 < S2end; ++S2)
        if (f[i][S1][S2] != -1) {
          preIdx = i, curTrans.clear(), preVal = f[i][S1][S2], preS1 = S1,
          preS2 = S2;
          dfs(S1, S2, 0, 1);
        }
  }
  int ans = -1, aS1, aS2;
  for (int S1 = (0), S1end = (1 << m); S1 < S1end; ++S1)
    for (int S2 = (0), S2end = (1 << m); S2 < S2end; ++S2) {
      if (ans < f[n - 2][S1][S2]) ans = f[n - 2][S1][S2], aS1 = S1, aS2 = S2;
    }
  IO::write(ans, '\n');
  int cnt = 0;
  int ci = n - 2;
  for (int i = (0), iend = (n); i < iend; ++i)
    for (int j = (0), jend = (m); j < jend; ++j) fans[i][j] = '.';
  while (ci >= 1) {
    for (pair<int, int> cur : pre[ci][aS1][aS2].first) {
      int x = ci, y = cur.first;
      for (int jj = (0), jjend = (5); jj < jjend; ++jj)
        fans[x + dx[cur.second][jj]][y + dy[cur.second][jj]] = 'A' + cnt;
      cnt++;
    }
    auto tmp = pre[ci][aS1][aS2].second;
    aS1 = tmp.first, aS2 = tmp.second;
    ci--;
  }
  for (int i = (0), iend = (n); i < iend; ++i) puts(fans[i]);
  return 0;
}