#include <bits/stdc++.h>   using namespace std;   int getint() {     unsigned int c;     int x = 0;     while (((c = getchar()) -  0 ) >= 10) {       if (c ==  - ) return -getint();       if (!~c) exit(0);     }     do {       x = (x << 3) + (x << 1) + (c -  0 );     } while (((c = getchar()) -  0 ) < 10);     return x;   }   char a1[] =  ### ..# .#. #.. ;   char a2[] =  .#. ### .#. ### ;   char a3[] =  .#. ..# ### #.. ;   vector<int> px[4], py[4];   int n, m, grid[10][10], mx, res[10][10];   void solve(int x, int y, int curr) {     if (y >= m) {       solve(x + 1, 0, curr);       return;     }     if (x >= n) {       if (curr > mx) mx = curr, memcpy(res, grid, sizeof(res));       return;     }     int i, j, k, d, tmp[10][10], nx, ny;     int mxPossible = 0;     for (i = y; i < m; i++)       if (grid[x][i] == 0) mxPossible++;     for (i = x; i < n; i++)       for (j = 0; j < m; j++)         if (grid[i][j] == 0) mxPossible++;     mxPossible /= 5;     if (mxPossible + curr <= mx) return;     memcpy(tmp, grid, sizeof(tmp));     for (d = 0; d < 4; d++) {       bool canPlace = 1;       memcpy(grid, tmp, sizeof(tmp));       for (i = 0; i < px[d].size(); i++) {         nx = x + px[d][i];         ny = y + py[d][i];         if (nx >= n or ny >= m or grid[nx][ny]) {           canPlace = 0;           break;         }         grid[nx][ny] = curr + 1;       }       if (canPlace) {         solve(x, y + 1, curr + 1);       }     }     memcpy(grid, tmp, sizeof(tmp));     solve(x, y + 1, curr);   }   int main() {     int i, j, tcc, tc = 1 << 28;     for (i = 0; i < 4; i++) {       for (j = 0; j < 3; j++)         if (a1[i * 4 + j] ==  # ) px[i].push_back(0), py[i].push_back(j);       for (j = 0; j < 3; j++)         if (a2[i * 4 + j] ==  # ) px[i].push_back(1), py[i].push_back(j);       for (j = 0; j < 3; j++)         if (a3[i * 4 + j] ==  # ) px[i].push_back(2), py[i].push_back(j);     }     for (tcc = 0; tcc < tc; tcc++) {       n = getint(), m = getint(), mx = 0;       if (n == 9 and m == 9) {         puts( 13 );         puts(              AAA.BCCC. n.ABBB.CD. n.AE.BFCD. nEEEFFFDDD nG.E.HFIII nGGGJHHHI.                nGK.JHL.IM n.KJJJLMMM nKKK.LLL.M n );         continue;       }       memset(res, 0, sizeof(res));       memset(grid, 0, sizeof(grid));       solve(0, 0, 0);       printf( %d n , mx);       for (i = 0; i < n; i++) {         for (j = 0; j < m; j++) {           if (res[i][j] == 0)             putchar( . );           else             putchar( A  + res[i][j] - 1);         }         puts(  );       }       puts(  );     }     return 0;   }   