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;
template <class T>
T sqr(T x) {
  return x * x;
}
inline int getBit(long long x, int pos) { return ((x >> pos) & 1); }
const double eps = 1e-9;
const double pi = acos(-1.0);
bool update(int &x, int y) {
  if (x < y) {
    x = y;
    return true;
  } else
    return false;
}
int n, m;
int dp[10][(1 << 19)];
char ans[10][10];
char curC;
int cm1, cm2;
void go(int i, int j, int mask1, int mask2, int mask3, int cnt) {
  if (j >= m - 2) {
    update(dp[i + 1][(mask2 << m) | mask3], cnt);
    return;
  }
  go(i, j + 1, mask1, mask2, mask3, cnt);
  if (((mask1 >> j) & 7) == 0 && getBit(mask2, j + 1) == 0 &&
      getBit(mask3, j + 1) == 0) {
    go(i, j + 2, mask1 | (7 << j), mask2 | (1 << (j + 1)),
       mask3 | (1 << (j + 1)), cnt + 1);
  }
  if (getBit(mask1, j + 2) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j + 2) == 0) {
    go(i, j + 3, mask1 | (1 << (j + 2)), mask2 | (7 << j),
       mask3 | (1 << (j + 2)), cnt + 1);
  }
  if (getBit(mask1, j + 1) == 0 && getBit(mask2, j + 1) == 0 &&
      ((mask3 >> j) & 7) == 0) {
    go(i, j + 2, mask1 | (1 << (j + 1)), mask2 | (1 << (j + 1)),
       mask3 | (7 << j), cnt + 1);
  }
  if (getBit(mask1, j) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j) == 0) {
    go(i, j + 2, mask1 | (1 << j), mask2 | (7 << j), mask3 | (1 << j), cnt + 1);
  }
}
bool go2(int i, int j, int mask1, int mask2, int mask3, int cnt) {
  if (j >= m - 2) {
    if (mask2 == cm1 && mask3 == cm2 && cnt == dp[i + 1][(cm1 << m) | cm2]) {
      return true;
    }
    return false;
  }
  if (go2(i, j + 1, mask1, mask2, mask3, cnt)) {
    return true;
  }
  if (((mask1 >> j) & 7) == 0 && getBit(mask2, j + 1) == 0 &&
      getBit(mask3, j + 1) == 0 &&
      go2(i, j + 2, mask1 | (7 << j), mask2 | (1 << (j + 1)),
          mask3 | (1 << (j + 1)), cnt + 1)) {
    ans[i][j] = ans[i][j + 1] = ans[i][j + 2] = ans[i + 1][j + 1] =
        ans[i + 2][j + 1] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j + 2) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j + 2) == 0 &&
      go2(i, j + 3, mask1 | (1 << (j + 2)), mask2 | (7 << j),
          mask3 | (1 << (j + 2)), cnt + 1)) {
    ans[i][j + 2] = ans[i + 1][j] = ans[i + 1][j + 1] = ans[i + 1][j + 2] =
        ans[i + 2][j + 2] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j + 1) == 0 && getBit(mask2, j + 1) == 0 &&
      ((mask3 >> j) & 7) == 0 &&
      go2(i, j + 2, mask1 | (1 << (j + 1)), mask2 | (1 << (j + 1)),
          mask3 | (7 << j), cnt + 1)) {
    ans[i][j + 1] = ans[i + 1][j + 1] = ans[i + 2][j] = ans[i + 2][j + 1] =
        ans[i + 2][j + 2] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j) == 0 &&
      go2(i, j + 2, mask1 | (1 << j), mask2 | (7 << j), mask3 | (1 << j),
          cnt + 1)) {
    ans[i][j] = ans[i + 1][j] = ans[i + 1][j + 1] = ans[i + 1][j + 2] =
        ans[i + 2][j] = curC;
    curC++;
    return true;
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  if (n < 3 || m < 3) {
    puts("0");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        putchar('.');
      }
      puts("");
    }
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << (m * 2)); j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int mask1 = 0; mask1 < (1 << m); mask1++) {
      for (int mask2 = 0; mask2 < (1 << m); mask2++) {
        cm1 = mask1;
        cm2 = mask2;
        if (dp[i][(mask1 << m) | mask2] != -1)
          go(i, 0, mask1, mask2, 0, dp[i][(mask1 << m) | mask2]);
      }
    }
  }
  cout << dp[n][0] << endl;
  curC = 'A';
  cm1 = cm2 = 0;
  for (int i = n - 1; i >= 0; i--) {
    bool found = false;
    for (int mask1 = 0; mask1 < (1 << m) && !found; mask1++) {
      for (int mask2 = 0; mask2 < (1 << m) && !found; mask2++) {
        if (dp[i][(mask1 << m) | mask2] != -1) {
          if (go2(i, 0, mask1, mask2, 0, dp[i][(mask1 << m) | mask2])) {
            cm1 = mask1;
            cm2 = mask2;
            found = true;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ('A' <= ans[i][j] && ans[i][j] <= 'Z') continue;
      ans[i][j] = '.';
    }
    ans[i][m] = '\0';
  }
  for (int i = 0; i < n; i++) {
    puts(ans[i]);
  }
  return 0;
}