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 n, m, M, N, ms, q;
int i, j, k, l;
char d[9][9][1 << 20];
char w[9][9][1 << 20];
int ms1, ms2, ms3, ms4;
int ai, aj, am, ans;
char s[11][11];
int main() {
  cin >> n >> m;
  N = 1 << (n * 2 + 2);
  ms1 = 1 | (1 << n) | (1 << (n + 1)) | (1 << (n + 2)) | (1 << (n + n));
  ms2 = 1 | 2 | 4 | (1 << (n + 1)) | (1 << (n + n + 1));
  ms3 = 1 | (1 << n) | (1 << (n + n - 1)) | (1 << (n + n)) | (1 << (n + n + 1));
  ms4 = 1 | (1 << (n - 2)) | (1 << (n - 1)) | (1 << n) | (1 << (n + n));
  memset(d, -111, sizeof(d));
  ;
  d[0][0][0] = 0;
  ans = 0;
  for (i = 0; i + 2 < m; ++i) {
    for (j = 0; j < n; ++j) {
      for (ms = 0; ms < N; ++ms)
        if (d[i][j][ms] >= 0) {
          {
            q = ms >> 1;
            k = (j + 1 < n ? i : i + 1);
            l = (j + 1 < n ? j + 1 : 0);
            if (d[k][l][q] < d[i][j][ms]) {
              d[k][l][q] = d[i][j][ms];
              w[k][l][q] = (ms & 1) + 'a';
            }
          }
          if (j + 2 < n && !(ms & ms1)) {
            q = (ms | ms1) >> 1;
            k = (j + 1 < n ? i : i + 1);
            l = (j + 1 < n ? j + 1 : 0);
            if (d[k][l][q] < d[i][j][ms] + 1) {
              d[k][l][q] = d[i][j][ms] + 1;
              w[k][l][q] = '1';
            }
          }
          if (j + 2 < n && !(ms & ms2)) {
            q = (ms | ms2) >> 3;
            k = (j + 3 < n ? i : i + 1);
            l = (j + 3 < n ? j + 3 : 0);
            if (d[k][l][q] < d[i][j][ms] + 1) {
              d[k][l][q] = d[i][j][ms] + 1;
              w[k][l][q] = '2';
            }
          }
          if (j + 1 < n && j > 0 && !(ms & ms3)) {
            q = (ms | ms3) >> 1;
            k = (j + 1 < n ? i : i + 1);
            l = (j + 1 < n ? j + 1 : 0);
            if (d[k][l][q] < d[i][j][ms] + 1) {
              d[k][l][q] = d[i][j][ms] + 1;
              w[k][l][q] = '3';
            }
          }
          if (j > 1 && !(ms & ms4)) {
            q = (ms | ms4) >> 1;
            k = (j + 1 < n ? i : i + 1);
            l = (j + 1 < n ? j + 1 : 0);
            if (d[k][l][q] < d[i][j][ms] + 1) {
              d[k][l][q] = d[i][j][ms] + 1;
              w[k][l][q] = '4';
            }
          }
        }
    }
  }
  for (i = 0; i < m; ++i)
    for (j = 0; j < n; ++j)
      for (ms = 0; ms < N; ++ms)
        if (ans < d[i][j][ms]) {
          ans = d[i][j][ms];
          ai = i;
          aj = j;
          am = ms;
        }
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) s[i][j] = '.';
  cout << ans << endl;
  i = ai;
  j = aj;
  ms = am;
  while (ans) {
    --ans;
    if (w[i][j][ms] == 'a' || w[i][j][ms] == 'b') {
      ms = (ms << 1) + (w[i][j][ms] - 'a');
      --j;
      if (j < 0) {
        j = n - 1;
        --i;
      }
      ++ans;
    } else if (w[i][j][ms] == '1') {
      ms = (ms << 1) + 1 - ms1;
      --j;
      if (j < 0) {
        j = n - 1;
        --i;
      }
      s[j][i] = s[j][i + 1] = s[j][i + 2] = s[j + 1][i + 1] = s[j + 2][i + 1] =
          ans + 'A';
    } else if (w[i][j][ms] == '2') {
      ms = (ms << 3) + 7 - ms2;
      j -= 3;
      if (j < 0) {
        j = n - 3;
        --i;
      }
      s[j][i] = s[j + 1][i] = s[j + 2][i] = s[j + 1][i + 1] = s[j + 1][i + 2] =
          ans + 'A';
    } else if (w[i][j][ms] == '3') {
      ms = (ms << 1) + 1 - ms3;
      j--;
      if (j < 0) {
        j = n - 1;
        --i;
      }
      s[j][i] = s[j][i + 1] = s[j - 1][i + 2] = s[j][i + 2] = s[j + 1][i + 2] =
          ans + 'A';
    } else if (w[i][j][ms] == '4') {
      ms = (ms << 1) + 1 - ms4;
      j--;
      if (j < 0) {
        j = n - 1;
        --i;
      }
      s[j][i] = s[j][i + 1] = s[j][i + 2] = s[j - 1][i + 1] = s[j - 2][i + 1] =
          ans + 'A';
    }
  }
  for (i = 0; i < n; ++i) cout << s[i] << endl;
  return 0;
}