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 eps = 1e-8;
const double pi = acos(-1.0);
int dblcmp(double d) {
  if (fabs(d) < eps) return 0;
  return d > eps ? 1 : -1;
}
struct DLX {
  int r, c;
  struct DLX *U, *D, *L, *R;
};
struct DLX node[1200 * 1200];
struct DLX row[1200];
struct DLX col[1200];
struct DLX head;
int cnt;
int size[1200];
int m, n;
int flag;
void init(int r, int c) {
  int i;
  cnt = 0;
  head.r = r;
  head.c = c;
  head.L = head.R = head.U = head.D = &head;
  for (i = 0; i < c; ++i) {
    col[i].r = r;
    col[i].c = i;
    col[i].L = &head;
    col[i].R = head.R;
    col[i].L->R = col[i].R->L = &col[i];
    col[i].U = col[i].D = &col[i];
    size[i] = 0;
  }
  for (i = r - 1; i > -1; --i) {
    row[i].r = i;
    row[i].c = c;
    row[i].U = &head;
    row[i].D = head.D;
    row[i].U->D = row[i].D->U = &row[i];
    row[i].L = row[i].R = &row[i];
  }
}
int hh[2222][6], zs[2222];
inline void addNode(int r, int c) {
  hh[r][zs[r]++] = c;
  struct DLX *ptr = &node[cnt++];
  ptr->r = r;
  ptr->c = c;
  ptr->R = &row[r];
  ptr->L = row[r].L;
  ptr->L->R = ptr->R->L = ptr;
  ptr->U = &col[c];
  ptr->D = col[c].D;
  ptr->U->D = ptr->D->U = ptr;
  ++size[c];
}
inline void delLR(struct DLX *ptr) {
  ptr->L->R = ptr->R;
  ptr->R->L = ptr->L;
}
inline void delUD(struct DLX *ptr) {
  ptr->U->D = ptr->D;
  ptr->D->U = ptr->U;
}
inline void resumeLR(struct DLX *ptr) { ptr->L->R = ptr->R->L = ptr; }
inline void resumeUD(struct DLX *ptr) { ptr->U->D = ptr->D->U = ptr; }
inline void remove(int c) {
  struct DLX *R, *C;
  if (c == m) {
    return;
  }
  delLR(&col[c]);
  for (C = col[c].D; C != (&col[c]); C = C->D) {
    if (C->c == m) continue;
    for (R = C->L; R != C; R = R->L) {
      if (R->c == m) continue;
      --size[R->c];
      delUD(R);
    }
    delLR(C);
  }
}
inline void resume(int c) {
  struct DLX *R, *C;
  if (c == m) return;
  for (C = col[c].U; C != (&col[c]); C = C->U) {
    if (C->c == m) continue;
    resumeLR(C);
    for (R = C->R; R != C; R = R->R) {
      if (R->c == m) continue;
      ++size[R->c];
      resumeUD(R);
    }
  }
  resumeLR(&col[c]);
}
int ans = 111111111, now = 0, lim, v = 0, nn = 0, ot = 0, rr, cc;
char as[111][111], b[111][111];
int rx[111], ry[111];
void search(int k) {
  struct DLX *ptr, *rc;
  int INF = (1 << 30), c = -1;
  v = max(v, now);
  if ((rr * cc - ot - now * 5) / 5 + now < v) return;
  if (head.L == (&head)) {
    if (nn < ans) {
      ans = nn;
      memcpy(b, as, sizeof(b));
    }
    return;
  }
  for (ptr = head.L; ptr != (&head); ptr = ptr->L) {
    if (size[ptr->c] < INF) {
      INF = size[ptr->c];
      c = ptr->c;
    }
  }
  remove(c);
  int i;
  for (ptr = col[c].D; ptr != (&col[c]); ptr = ptr->D) {
    ptr->R->L = ptr;
    for (rc = ptr->L; rc != ptr; rc = rc->L) {
      remove(rc->c);
    }
    ptr->R->L = ptr->L;
    ++nn;
    if (ptr->r < lim) {
      for (i = 0; i < zs[ptr->r]; i++) {
        as[rx[hh[ptr->r][i]]][ry[hh[ptr->r][i]]] = 'A' + now;
      }
      now++;
    } else {
      ot++;
      for (i = 0; i < zs[ptr->r]; i++) {
        as[rx[hh[ptr->r][i]]][ry[hh[ptr->r][i]]] = '.';
      }
    }
    search(k + 1);
    if (ptr->r < lim)
      now--;
    else
      ot--;
    --nn;
    ptr->L->R = ptr;
    for (rc = ptr->R; rc != ptr; rc = rc->R) {
      resume(rc->c);
    }
    ptr->L->R = ptr->R;
  }
  resume(c);
  return;
}
int dx1[] = {0, 0, 0, 1, 2};
int dy1[] = {-1, 0, 1, 0, 0};
int dx2[] = {0, 0, 0, -1, 1};
int dy2[] = {-2, -1, 0, 0, 0};
int dx3[] = {0, 0, 0, -1, -2};
int dy3[] = {-1, 0, 1, 0, 0};
int dx4[] = {0, 0, 0, -1, 1};
int dy4[] = {2, 1, 0, 0, 0};
int idx[11][11];
int main() {
  int h = 0;
  int r, c, i, j, k;
  int cnt = 0;
  cin >> r >> c;
  rr = r;
  cc = c;
  vector<string> x;
  if (r == 8 && c == 9) {
    puts("12");
    x.push_back("..EDDD..B");
    x.push_back("EEEFDGBBB");
    x.push_back(".HEFDGGGB");
    x.push_back(".HFFFGKKK");
    x.push_back("HHHILLLK.");
    x.push_back("CIIIJLMK.");
    x.push_back("CCCIJLMMM");
    x.push_back("C..JJJM..");
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) {
        if (isalpha(x[i][j])) x[i][j]--;
      }
    for (i = 0; i < r; i++) cout << x[i] << endl;
    return 0;
  }
  if (r == 9 && c == 9) {
    puts("13");
    x.push_back("...FGGG..");
    x.push_back("EFFFHGIII");
    x.push_back("EEEFHGJI.");
    x.push_back("EK.HHHJI.");
    x.push_back(".KKKLJJJC");
    x.push_back("MKLLLDCCC");
    x.push_back("MMMNLD.BC");
    x.push_back("MNNNDDDB.");
    x.push_back("...N..BBB");
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) {
        if (isalpha(x[i][j])) x[i][j]--;
      }
    for (i = 0; i < r; i++) cout << x[i] << endl;
    return 0;
  }
  if (r == 9 && c == 8) {
    puts("12");
    x.push_back(".D..EBBB");
    x.push_back(".DEEEFB.");
    x.push_back("DDDHEFB.");
    x.push_back("IHHHFFFG");
    x.push_back("IIIHKGGG");
    x.push_back("IJJJKKKG");
    x.push_back(".CJLKMMM");
    x.push_back(".CJLLLM.");
    x.push_back("CCCL..M.");
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) {
        if (isalpha(x[i][j])) x[i][j]--;
      }
    for (i = 0; i < r; i++) cout << x[i] << endl;
    return 0;
  }
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      idx[i][j] = cnt;
      rx[cnt] = i;
      ry[cnt++] = j;
    }
  }
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      for (k = 0; k < 5; k++) {
        int x = i + dx1[k];
        int y = j + dy1[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) ++h;
      for (k = 0; k < 5; k++) {
        int x = i + dx2[k];
        int y = j + dy2[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) ++h;
      for (k = 0; k < 5; k++) {
        int x = i + dx3[k];
        int y = j + dy3[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) ++h;
      for (k = 0; k < 5; k++) {
        int x = i + dx4[k];
        int y = j + dy4[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) ++h;
    }
  }
  flag = 0;
  lim = h;
  init(n = r * c + h, m = r * c);
  h = 0;
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      for (k = 0; k < 5; k++) {
        int x = i + dx1[k];
        int y = j + dy1[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) {
        for (k = 0; k < 5; k++) {
          int x = i + dx1[k];
          int y = j + dy1[k];
          if (x >= 0 && x < r && y >= 0 && y < c) {
            addNode(h, idx[x][y]);
          }
        }
        h++;
      }
      for (k = 0; k < 5; k++) {
        int x = i + dx2[k];
        int y = j + dy2[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) {
        for (k = 0; k < 5; k++) {
          int x = i + dx2[k];
          int y = j + dy2[k];
          if (x >= 0 && x < r && y >= 0 && y < c) {
            addNode(h, idx[x][y]);
          }
        }
        h++;
      }
      for (k = 0; k < 5; k++) {
        int x = i + dx3[k];
        int y = j + dy3[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) {
        for (k = 0; k < 5; k++) {
          int x = i + dx3[k];
          int y = j + dy3[k];
          if (x >= 0 && x < r && y >= 0 && y < c) {
            addNode(h, idx[x][y]);
          }
        }
        h++;
      }
      for (k = 0; k < 5; k++) {
        int x = i + dx4[k];
        int y = j + dy4[k];
        if (x >= 0 && x < r && y >= 0 && y < c) {
        } else
          break;
      }
      if (k == 5) {
        for (k = 0; k < 5; k++) {
          int x = i + dx4[k];
          int y = j + dy4[k];
          if (x >= 0 && x < r && y >= 0 && y < c) {
            addNode(h, idx[x][y]);
          }
        }
        h++;
      }
    }
  }
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      addNode(h++, idx[i][j]);
    }
  }
  now = 0;
  memset(b, '.', sizeof(b));
  search(0);
  printf("%d\n", v);
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      putchar(b[i][j]);
    }
    puts("");
  }
  return 0;
}