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;
const double PI = acos(-1.0);
int p3[22], M;
int f[10][300000], tu[10][300000], td[10][300000];
char board[20][20], cur = 'A';
int getBit(int x, int k) { return (x % p3[k + 1]) / p3[k]; }
int setBit(int x, int k, int b) { return x - getBit(x, k) * p3[k] + b * p3[k]; }
int getprev(int state, int n) {
  int res = 0;
  for (int b = 0, _a = (n); b < _a; b++) {
    int cur = getBit(state, b);
    cur--;
    if (cur < 0) cur = 0;
    res = setBit(res, b, cur);
  }
  return res;
}
int apply(int m, int c, int d, int state) {
  if (d == 1) {
    if (getBit(state, c) == 0 && getBit(state, c + 1) == 0 &&
        getBit(state, c + 2) == 0) {
      state = setBit(state, c, 1);
      state = setBit(state, c + 1, 3);
      state = setBit(state, c + 2, 1);
      return state;
    } else
      return -1;
  }
  if (d == 2) {
    if (getBit(state, c) <= 1 && getBit(state, c + 1) <= 1 &&
        getBit(state, c + 2) == 0) {
      state = setBit(state, c, 2);
      state = setBit(state, c + 1, 2);
      state = setBit(state, c + 2, 3);
      return state;
    } else
      return -1;
  }
  if (d == 3) {
    if (getBit(state, c) <= 2 && getBit(state, c + 1) == 0 &&
        getBit(state, c + 2) <= 2) {
      state = setBit(state, c, 3);
      state = setBit(state, c + 1, 3);
      state = setBit(state, c + 2, 3);
      return state;
    } else
      return -1;
  }
  if (d == 4) {
    if (getBit(state, c) == 0 && getBit(state, c + 1) <= 1 &&
        getBit(state, c + 2) <= 1) {
      state = setBit(state, c, 3);
      state = setBit(state, c + 1, 2);
      state = setBit(state, c + 2, 2);
      return state;
    } else
      return -1;
  }
}
int get(int m, int n, int state) {
  if (f[m][state] >= 0) return f[m][state];
  if (m >= M) return 0;
  int res = get(m + 1, n, getprev(state, n));
  for (int c = 0, _a = (n - 2); c < _a; c++)
    for (int d = (1), _b = (4); d <= _b; d++) {
      int news;
      news = apply(m, c, d, state);
      if (news != -1) {
        int cur = get(m, n, news) + 1;
        if (cur > res) {
          res = cur;
          tu[m][state] = c;
          td[m][state] = d;
        }
      }
    }
  return f[m][state] = res;
}
void trace(int m, int n, int state) {
  if (m >= M) return;
  int c = tu[m][state];
  int d = td[m][state];
  if (d == 0) {
    trace(m + 1, n, getprev(state, n));
    return;
  }
  int news = apply(m, c, d, state);
  if (d == 1) {
    board[m - 2][c] = board[m - 2][c + 1] = board[m - 2][c + 2] =
        board[m - 1][c + 1] = board[m][c + 1] = cur;
  }
  if (d == 2) {
    board[m - 2][c + 2] = board[m - 1][c] = board[m - 1][c + 1] =
        board[m - 1][c + 2] = board[m][c + 2] = cur;
  }
  if (d == 3) {
    board[m - 2][c + 1] = board[m - 1][c + 1] = board[m][c] = board[m][c + 1] =
        board[m][c + 2] = cur;
  }
  if (d == 4) {
    board[m - 2][c] = board[m - 1][c] = board[m - 1][c + 1] =
        board[m - 1][c + 2] = board[m][c] = cur;
  }
  cur++;
  trace(m, n, news);
}
int main() {
  p3[0] = 1;
  for (int i = (1), _b = (10); i <= _b; i++) p3[i] = p3[i - 1] * 4;
  int m, n;
  scanf("%d%d", &m, &n);
  {
    cur = 'A';
    M = m;
    memset(f, -1, sizeof f);
    memset(td, 0, sizeof td);
    printf("%d\n", get(2, n, 0));
    memset(board, '.', sizeof board);
    trace(2, n, 0);
    for (int i = 0, _a = (m); i < _a; i++) {
      for (int j = 0, _a = (n); j < _a; j++) cout << board[i][j];
      puts("");
    }
  }
  return 0;
}