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 int N = 9, M = 9, MASKS = 1 << (M << 1), EMPTY = -1;
int n, m, masks, border;
int dp[N + 1][MASKS], dpJ[N + 1][MASKS], dpB[N + 1][MASKS];
int tCombinations[600], tAmounts[600], tCombinationsAmount = 0;
int field[3][M], tFields[600][3][M], fullField[N][M];
bool placeT(int i, int direction, bool justTry, int value) {
  if (i < 1 || i > m - 2 || justTry && field[1][i] != 0) return false;
  switch (direction) {
    case 0:
      if (justTry && (field[0][i - 1] != 0 || field[0][i] != 0 ||
                      field[0][i + 1] != 0 || field[2][i] != 0))
        return false;
      if (!justTry)
        field[0][i - 1] = field[0][i] = field[0][i + 1] = field[2][i] = value;
      break;
    case 1:
      if (justTry && (field[1][i - 1] != 0 || field[0][i + 1] != 0 ||
                      field[1][i + 1] != 0 || field[2][i + 1] != 0))
        return false;
      if (!justTry)
        field[1][i - 1] = field[0][i + 1] = field[1][i + 1] = field[2][i + 1] =
            value;
      break;
    case 2:
      if (justTry && (field[0][i] != 0 || field[2][i - 1] != 0 ||
                      field[2][i] != 0 || field[2][i + 1] != 0))
        return false;
      if (!justTry)
        field[0][i] = field[2][i - 1] = field[2][i] = field[2][i + 1] = value;
      break;
    case 3:
      if (justTry && (field[0][i - 1] != 0 || field[1][i - 1] != 0 ||
                      field[2][i - 1] != 0 || field[1][i + 1] != 0))
        return false;
      if (!justTry)
        field[0][i - 1] = field[1][i - 1] = field[2][i - 1] = field[1][i + 1] =
            value;
      break;
  }
  if (!justTry) field[1][i] = value;
  return true;
}
void findTCombination(int i, int amount) {
  if (i >= m) {
    int bm = 0;
    for (i = 0; i < 3; ++i) {
      for (int j = 0; j < m; ++j) {
        bm = bm << 1;
        bm |= !(!(field[i][j]));
      }
    }
    if (0) {
      cout << amount << '\n';
      for (i = 0; i < 3; ++i) {
        for (int j = 0; j < m; ++j) {
          cout << field[i][j] << ' ';
        }
        cout << '\n';
      }
      cout << bm << '\n' << endl;
    }
    memcpy(tFields[tCombinationsAmount], field, sizeof field);
    tCombinations[tCombinationsAmount] = bm;
    tAmounts[tCombinationsAmount] = amount;
    ++tCombinationsAmount;
    return;
  }
  findTCombination(i + 1, amount);
  for (int d = 0; d < 4; ++d) {
    if (placeT(i, d, true, amount + 1)) {
      placeT(i, d, false, amount + 1);
      findTCombination(i + 1, amount + 1);
      placeT(i, d, false, 0);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  masks = 1 << (m << 1);
  border = masks - 1;
  findTCombination(1, 0);
  memset(dp, EMPTY, sizeof dp);
  dp[1][0] = 0;
  for (int i = 1, ni; i <= n - 2; i = ni) {
    ni = i + 1;
    for (int bm = 0; bm < masks; ++bm) {
      if (dp[i][bm] == EMPTY) continue;
      int b = bm << m;
      for (int j = 0; j < tCombinationsAmount; ++j) {
        if (b & tCombinations[j]) continue;
        int nb = (b | tCombinations[j]) & border;
        int na = dp[i][bm] + tAmounts[j];
        if (dp[ni][nb] == EMPTY) {
          dp[ni][nb] = na;
        } else {
          dp[ni][nb] = max(dp[ni][nb], na);
        }
        if (dp[ni][nb] == na) {
          dpJ[ni][nb] = j;
          dpB[ni][nb] = bm;
        }
      }
    }
  }
  int result = 0, bm0;
  for (int bm = 0; bm < masks; ++bm) {
    result = max(result, dp[n - 1][bm]);
    if (result == dp[n - 1][bm]) bm0 = bm;
  }
  cout << result << '\n';
  if (result) {
    int drawn = 0;
    for (int i = n - 1; i > 1; --i) {
      int j = dpJ[i][bm0];
      for (int fi = 0; fi < 3; ++fi) {
        for (int fj = 0; fj < m; ++fj) {
          if (tFields[j][fi][fj])
            fullField[i + fi - 2][fj] = tFields[j][fi][fj] + drawn;
        }
      }
      drawn += tAmounts[j];
      bm0 = dpB[i][bm0];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (fullField[i][j]) {
        cout << (char)('A' + fullField[i][j] - 1);
      } else {
        cout << '.';
      }
    }
    cout << '\n';
  }
  return 0;
}