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;
struct state {
  int mask, mask1, mask2, mask3, calc;
};
int n, m;
char ress[15][15];
int dp[10][(1 << 9) + 10][(1 << 9) + 10];
int way[10][(1 << 9) + 10][(1 << 9) + 10];
vector<state> a;
int r(int p, int mask1, int mask2) {
  if (p == n) return 0;
  if (dp[p][mask1][mask2] != -1) return dp[p][mask1][mask2];
  int res = -1;
  for (int i = (0); i < (a.size()); ++i) {
    int m1 = a[i].mask1;
    int m2 = a[i].mask2;
    if (m1 & mask1) continue;
    if (m2 & mask2) continue;
    int res1 = a[i].calc + r(p + 1, mask2 | m2, a[i].mask3);
    if (res1 > res) {
      res = res1;
      way[p][mask1][mask2] = i;
    }
  }
  return dp[p][mask1][mask2] = res;
}
int main() {
  cin >> n >> m;
  if ((n < 3) || (m < 3)) {
    cout << 0 << endl;
    for (int i = (0); i < (n); ++i) {
      for (int j = (0); j < (m); ++j) printf(".");
      printf("\n");
    }
    return 0;
  }
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) ress[i][j] = '.';
  int v = 1;
  for (int i = (0); i < (m); ++i) v *= 5;
  for (int i = (0); i < (v); ++i) {
    int mask1 = 0, mask2 = 0, mask3 = 0;
    bool f = true;
    int cur = i;
    int cnt = 0;
    for (int j = (0); j < (m); ++j) {
      int c = cur % 5;
      cur /= 5;
      if (c == 0) continue;
      if (c == 1) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> j) & 1) {
          f = false;
          break;
        }
        if ((j < 1) || (j > m - 2)) {
          f = false;
          break;
        }
        if ((mask1 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j - 1)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j - 1));
        mask1 |= (1 << j);
        mask1 |= (1 << (j + 1));
        mask2 |= (1 << j);
        mask3 |= (1 << j);
      }
      if (c == 2) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> j) & 1) {
          f = false;
          break;
        }
        if (j < 2) {
          f = false;
          break;
        }
        if ((mask2 >> (j - 1)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j - 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j));
        mask2 |= (1 << j);
        mask2 |= (1 << (j - 1));
        mask2 |= (1 << (j - 2));
        mask3 |= (1 << j);
      }
      if (c == 3) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if (j > m - 3) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask3 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask3 >> (j + 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j + 1));
        mask2 |= (1 << (j + 1));
        mask3 |= (1 << (j + 2));
        mask3 |= (1 << (j + 1));
        mask3 |= (1 << j);
      }
      if (c == 4) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if (j > m - 3) {
          f = false;
          break;
        }
        if ((mask2 >> (j)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j));
        mask2 |= (1 << (j));
        mask2 |= (1 << (j + 1));
        mask2 |= (1 << (j + 2));
        mask3 |= (1 << j);
      }
    }
    if (f) {
      state v = {i, mask1, mask2, mask3, cnt};
      a.push_back(v);
    }
  }
  memset(dp, -1, sizeof(dp));
  int res = r(2, 0, 0);
  cout << res << endl;
  int p = 2, mask1 = 0, mask2 = 0;
  int cur = 0;
  while (p < n) {
    int i = way[p][mask1][mask2];
    int mask = a[i].mask;
    for (int j = (0); j < (m); ++j) {
      int k = mask % 5;
      mask /= 5;
      if (k == 0) continue;
      if (k == 1) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 2][j - 1] =
            ress[p - 2][j + 1] = 'A' + cur;
        cur++;
      }
      if (k == 2) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 1][j - 1] =
            ress[p - 1][j - 2] = 'A' + cur;
        cur++;
      }
      if (k == 3) {
        ress[p][j] = ress[p][j + 1] = ress[p][j + 2] = ress[p - 1][j + 1] =
            ress[p - 2][j + 1] = 'A' + cur;
        cur++;
      }
      if (k == 4) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 1][j + 2] =
            ress[p - 1][j + 1] = 'A' + cur;
        cur++;
      }
    }
    p++;
    mask1 = mask2 | a[i].mask2;
    mask2 = a[i].mask3;
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) printf("%c", ress[i][j]);
    printf("\n");
  }
  return 0;
}