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;
int const N = 9;
int n, m;
char f[(N - 2) * N + 1][1 << (2 * N + 1)];
int p[(N - 2) * N + 1][1 << (2 * N + 1)];
int T[4][4];
char art[N][N + 1];
inline bool bit(int mask, int b) { return mask >> b & 1; }
inline int mask_setter(int mask, int b[]) {
  for (int i = 0; i < 4; ++i) mask ^= 1 << b[i];
  return mask;
}
inline bool all_free(int mask, int b[]) {
  for (int i = 0; i < 4; ++i)
    if (bit(mask, b[i])) return false;
  return true;
}
int putT(int x, int y, int mask, int t) {
  if (t == 0 && (y - 1 < 0 || y + 1 >= m)) return -1;
  if (t == 1 && y + 2 >= m) return -1;
  if (t == 2 && y - 2 < 0) return -1;
  if (t == 3 && y - 2 < 0) return -1;
  if (!all_free(mask, T[t])) return -1;
  mask = mask_setter(mask, T[t]);
  mask <<= 1;
  mask |= 1;
  mask &= ~(1 << (2 * m + 1));
  return mask;
}
void drawT(int i, int j, int t, char c) {
  art[i][j] = c;
  for (int k = 0; k < 4; ++k) {
    int x = i * m + j - T[t][k] - 1;
    art[x / m][x % m] = c;
  }
}
void init() {
  T[0][0] = m - 1, T[0][1] = 2 * m - 2, T[0][2] = 2 * m - 1, T[0][3] = 2 * m;
  T[1][0] = m - 1, T[1][1] = m - 2, T[1][2] = 2 * m - 1, T[1][3] = m - 3;
  T[2][0] = m - 1, T[2][1] = 2 * m - 1, T[2][2] = m, T[2][3] = m + 1;
  T[3][0] = 0, T[3][1] = 1, T[3][2] = m, T[3][3] = 2 * m;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(art, '.', sizeof(art));
  for (int i = 0; i < n; ++i) art[i][m] = '\0';
  if (n < 3 || m < 3) {
    puts("0");
    for (int i = 0; i < n; ++i) puts(art[i]);
    return 0;
  }
  init();
  int t = 2 * m + 1, mm = 1 << t;
  for (int i = 0; i + 2 < n; ++i)
    for (int j = 0; j < m; ++j) {
      for (int mask = 0, nm; mask < mm; ++mask) {
        int v = f[i * m + j][mask];
        int ni = j == m - 1 ? i + 1 : i, nj = j == m - 1 ? 0 : j + 1;
        int nn = ni * m + nj;
        for (int k = 0; k < 4; ++k) {
          if ((nm = putT(i, j, mask, k)) != -1)
            if (f[nn][nm] < v + 1) {
              f[nn][nm] = v + 1;
              p[nn][nm] = (mask << 2) | k;
            }
        }
        if (f[nn][(mask << 1) & ~(1 << t)] < v) {
          f[nn][(mask << 1) & ~(1 << t)] = v;
          p[nn][(mask << 1) & ~(1 << t)] = mask << 2;
        }
      }
    }
  int mask = 0;
  for (int i = 1; i < mm; ++i)
    if (f[(n - 2) * m][i] > f[(n - 2) * m][mask]) mask = i;
  printf("%d\n", f[(n - 2) * m][mask]);
  memset(art, '.', sizeof(art));
  for (int i = 0; i < n; ++i) art[i][m] = '\0';
  for (int i = n - 2, j = 0, pi, pj, pm, pt, c = 0; f[i * m + j][mask];
       i = pi, j = pj, mask = pm) {
    pm = p[i * m + j][mask] >> 2;
    pt = p[i * m + j][mask] & 3;
    pi = j == 0 ? i - 1 : i;
    pj = j == 0 ? m - 1 : j - 1;
    if (f[i * m + j][mask] > f[pi * m + pj][pm])
      drawT(pi + 2, pj, pt, (c++) + 'A');
  }
  for (int i = 0; i < n; ++i) puts(art[i]);
  return 0;
}