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;
unsigned char G[11][11];
bool Cen[11][11];
int total_best;
unsigned char A[11][11];
int R, C;
int dx[5][5][2] = {{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
                   {{0, 0}, {-1, -1}, {-1, 0}, {-1, 1}, {1, 0}},
                   {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {0, 1}},
                   {{0, 0}, {1, -1}, {1, 0}, {1, 1}, {-1, 0}},
                   {{0, 0}, {-1, 1}, {0, 1}, {1, 1}, {0, -1}}};
int dc[5] = {1, 2, 2, 2, 3};
void solve(int r, int c, int p) {
  if (R < 3 || C < 3) {
    return;
  }
  if (c >= (C - 1)) return solve(r + 1, 1, p);
  if (r == (R - 1)) {
    if ((p > total_best)) {
      total_best = p;
      int a;
      int b;
      for (a = 0; a < R; a++) {
        for (b = 0; b < C; b++) {
          A[a][b] = G[a][b];
        }
      }
    }
    return;
  }
  bool try_interest = true;
  if (G[r][c] != 0) try_interest = false;
  if (Cen[r - 1][c]) try_interest = false;
  if (Cen[r][c - 1]) try_interest = false;
  if (try_interest)
    for (int t = 1; t < 5; ++t) {
      bool can_place = true;
      int k;
      for (k = 0; k < 5; ++k) {
        int nr = r + dx[t][k][0];
        int nc = c + dx[t][k][1];
        if (G[nr][nc] != 0) {
          can_place = false;
          break;
        }
      }
      if (can_place) {
        for (k = 0; k < 5; ++k) {
          int nr = r + dx[t][k][0];
          int nc = c + dx[t][k][1];
          G[nr][nc] = p + 1;
        }
        Cen[r][c] = true;
        int ncc = c + dc[t];
        if (ncc >= C - 1) {
          solve(r + 1, 1, p + 1);
        } else {
          solve(r, ncc, p + 1);
        }
        Cen[r][c] = false;
        for (k = 0; k < 5; ++k) {
          int nr = r + dx[t][k][0];
          int nc = c + dx[t][k][1];
          G[nr][nc] = 0;
        }
      }
    }
  solve(r, c + 1, p);
}
bool valid[3000000];
bool good(unsigned long long i) {
  unsigned long long orig_i = i;
  bool full[3][11];
  memset(full, false, sizeof(full[0][0]) * 3 * 11);
  memset(G, false, sizeof(G[0][0]) * 3 * 11);
  int r = 1;
  int c = 1;
  int p = 0;
  while (i > 0) {
    if (c >= C - 1) break;
    int t = i % 5;
    i /= 5;
    if (t == 0) continue;
    for (int k = 0; k < 5; ++k) {
      int nr = r + dx[t][k][0];
      int nc = c + dx[t][k][1];
      if (full[nr][nc]) return false;
      full[nr][nc] = true;
      G[nr][nc] = p + 1;
    }
    p++;
    c++;
  }
  if (false) cout << orig_i << " is good: " << endl;
  for (int r = 0; r < 3; r++) {
    for (int c = 0; c < C; c++) {
      if (full[r][c])
        cout << (char)((G[r][c] - 1) + 'A');
      else
        cout << ".";
    }
    cout << endl;
  }
  return true;
}
int make_valid_rows() {
  int ans = 0;
  for (unsigned long long i = 0; i <= (pow(5., C - 2) + 1); i++) {
    if (good(i)) valid[i] = true;
    ans++;
  }
  return ans;
}
int main() {
  cin >> R >> C;
  for (int r = 0; r < R; r++) {
    for (int c = 0; c < C; c++) {
      G[r][c] = 0;
      Cen[r][c] = false;
    }
  }
  total_best = 0;
  bool done = false;
  if (R == 7 && C == 9) {
    cout << 10 << endl;
    cout << "..AAA.BBB" << endl;
    cout << "CCCADDDB." << endl;
    cout << ".CEA.D.BF" << endl;
    cout << ".CEEEDFFF" << endl;
    cout << "G.EHIIIJF" << endl;
    cout << "GGGH.I.J." << endl;
    cout << "G.HHHIJJJ" << endl;
    done = true;
  }
  if (R == 9 && C == 7) {
    cout << 10 << endl;
    cout << "..AAA.B" << endl;
    cout << "CCCABBB" << endl;
    cout << ".C.AD.B" << endl;
    cout << ".C.EDDD" << endl;
    cout << "FEEED.G" << endl;
    cout << "FFFEGGG" << endl;
    cout << "FHIIIJG" << endl;
    cout << ".H.I.J." << endl;
    cout << "HHHIJJJ" << endl;
    done = true;
  }
  if (R == 8 && C == 8) {
    cout << 10 << endl;
    cout << "...AAA.B" << endl;
    cout << ".CCCABBB" << endl;
    cout << ".DCEA.FB" << endl;
    cout << ".DCEEEF." << endl;
    cout << "DDDEGFFF" << endl;
    cout << "HHHIGGGJ" << endl;
    cout << ".H.IGJJJ" << endl;
    cout << ".HIII..J" << endl;
    done = true;
  }
  if (R == 8 && C == 9) {
    cout << 12 << endl;
    cout << "AAABBB..C" << endl;
    cout << ".AD.BECCC" << endl;
    cout << ".AD.BEEEC" << endl;
    cout << "FDDDGEHHH" << endl;
    cout << "FFFIGGGH." << endl;
    cout << "FJ.IGK.HL" << endl;
    cout << ".JIIIKLLL" << endl;
    cout << "JJJ.KKK.L" << endl;
    done = true;
  }
  if (R == 9 && C == 8) {
    cout << 12 << endl;
    cout << "AAABCCC." << endl;
    cout << ".A.B.CD." << endl;
    cout << "EABBBCD." << endl;
    cout << "EEEFGDDD" << endl;
    cout << "EFFFGGGH" << endl;
    cout << "IIIFGHHH" << endl;
    cout << ".IJKKKLH" << endl;
    cout << ".IJ.K.L." << endl;
    cout << ".JJJKLLL" << endl;
    done = true;
  }
  if (R == 9 && C == 9) {
    cout << 13 << endl;
    cout << "AAABCCCD." << endl;
    cout << ".A.B.C.D." << endl;
    cout << "EABBBCDDD" << endl;
    cout << "EEE.FG..." << endl;
    cout << "EHFFFGGGI" << endl;
    cout << ".HHHFGIII" << endl;
    cout << "JH.KLLLMI" << endl;
    cout << "JJJK.L.M." << endl;
    cout << "J.KKKLMMM" << endl;
    done = true;
  }
  if (!done) {
    solve(1, 1, 0);
    cout << total_best << endl;
    for (int r = 0; r < R; r++) {
      for (int c = 0; c < C; c++) {
        if (A[r][c] == 0)
          cout << '.';
        else
          cout << (char)((A[r][c] - 1) + 'A');
      }
      cout << endl;
    }
  }
}