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;
template <typename T>
using vc = vector<T>;
using pii = pair<int, int>;
void xmax(int& a, int b) { a = max(a, b); }
void xmin(int& a, int b) { a = min(a, b); }
void print(vc<int>& a, string second) {
  cerr << "prinitng " << second << "\n";
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << " ";
  }
  cerr << endl;
}
void xma(pair<int, vc<int> >& a, int b, vc<int> c) {
  if (b > a.first) {
    a = {b, c};
  }
}
int p(int a) {
  int e = 1;
  return (e << a);
}
int good(vc<int> check, int a) {
  for (int i = 0; i < check.size(); i++) {
    if ((check[i] & a) != 0) return 0;
  }
  return 1;
}
int su(vc<int> a) {
  int sum = 0;
  for (int i = 0; i < a.size(); i++) sum += a[i];
  return sum;
}
int n, m;
vc<int> check(int j, int k) {
  if (k == 0) return {p(j), p(j + 1), p(j + 2), p(n + j + 1), p(2 * n + j + 1)};
  if (k == 1) return {p(j), p(n + j), p(2 * n + j), p(n + j + 1), p(n + j + 2)};
  if (k == 2)
    return {p(j + 2), p(n + j + 2), p(2 * n + j + 2), p(n + j + 1), p(n + j)};
  if (k == 3)
    return {p(j + 2 * n), p(j + 1 + 2 * n), p(j + 2 + 2 * n), p(j + 1 + n),
            p(j + 1)};
  if (k == 4) return {};
}
int suu(int j, int k) { return su(check(j, k)); }
int add(int k) {
  if (k == 4) return 0;
  return 1;
}
void print_m(int a) {
  for (int i = 0; i < 3 * n; i++) {
    if (a & p(i))
      cout << "#";
    else
      cout << ".";
    if (i % n == n - 1) cout << "\n";
  }
  cout << "\n";
}
int geht(int a, int b) {
  if ((a & b) == 0) return 1;
  return 0;
}
vc<int> add_vec(vc<int> a, int b, int l) {
  int c1 = b % p(n);
  b >>= n;
  int c2 = b % p(n);
  b >>= n;
  int c3 = b;
  a[l - 2] += c1;
  a[l - 1] += c2;
  a[l] += c3;
  return a;
}
vc<vc<vc<int> > > teile{{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}},
                        {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}},
                        {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}},
                        {{0, 0, 1}, {1, 1, 1}, {0, 0, 1}}};
int contains(vc<vc<int> > a, vc<vc<int> > b) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (b[i][j] == 1 && a[i][j] == 0) return 0;
    }
  }
  return 1;
}
void print_field(vc<int> a) {
  vc<vc<int> > b(n, vc<int>(m));
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] & (1 << j)) b[j][i] = 1;
    }
  }
  int krat = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i][j])
        cerr << 1;
      else
        cerr << ".";
    }
    cerr << endl;
  }
  vc<vc<char> > res(n, vc<char>(m, '.'));
  for (int ii = 0; ii < n - 2; ii++) {
    for (int jj = 0; jj < m - 2; jj++) {
      int i, j;
      if (ii % 2 == 0)
        i = ii / 2;
      else
        i = n - 3 - ii / 2;
      if (jj % 2 == 0)
        j = jj / 2;
      else
        j = m - 3 - jj / 2;
      vc<vc<int> > block(3, vc<int>(3));
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          block[k][l] = b[i + k][j + l];
        }
      }
      for (int pp = 0; pp < 4; pp++) {
        if (contains(block, teile[pp])) {
          for (int k = 0; k < 3; k++) {
            for (int l = 0; l < 3; l++) {
              if (teile[pp][k][l]) {
                b[i + k][j + l] = 0;
                res[i + k][j + l] = 'A' + krat;
              }
            }
          }
          krat++;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << res[i][j];
    }
    cout << "\n";
  }
}
string acht5 = "E.FFF\nEEEF.\nED.FC\n.DCCC\nDDDBC\nABBB.\nAAAB.\nA....\n";
string sechs7 = "AAAE...\n.AFEEE.\n.AFEDDD\nBFFFCD.\nBBB.CD.\nB..CCC.\n";
string sechs8 = "...CD...\nBCCCDDD.\nBBBCDEEE\nBAGGGFE.\n.A.G.FE.\nAAAGFFF.\n";
string sieb7 =
    "A.HHH.G\nAAAHGGG\nA.CHF.G\nCCCEFFF\n.BCEFD.\n.BEEED.\nBBB.DDD\n";
string sechs9 =
    "FFFC..BBB\n.FGCCCEB.\n.FGCEEEB.\nAGGGH.ED.\nAAA.HDDD.\nA..HHH.D.\n";
string neun6 =
    "F..AAA\nFFFGA.\nFGGGA.\nCCCG.H\n.CEHHH\n.CE.DH\nBEEED.\nBBBDDD\nB.....\n";
vc<string> sieb8{"A.EEE..D", "AAAEFDDD", "AB.EFFFD", ".BBBFIII",
                 "CBGGGHI.", "CCCG.HI.", "C..GHHH."};
vc<string> sieb9{"A.DDDEFFF", "AAAD.E.F.", "A.CDEEEF.", "CCCHHHIII",
                 "B.CGH.JI.", "BBBGH.JI.", "B.GGGJJJ."};
vc<string> acht9{"B..GGG..A", "BBBHGFAAA", "BI.HGFFFA", ".IHHHFEEE",
                 "IIIJKKKE.", "CJJJLKDE.", "CCCJLKDDD", "C..LLLD.."};
string neun9 =
    "AAAJ..FFF\n.A.JKKKF.\nBAJJJK.FE\nBBBMLKEEE\nBMMMLLLDE\nGGGMLDDD.\n."
    "GHIIICD.\n.GH.I.C..\n.HHHICCC.\n";
string acht8 =
    "AAAH.BBB\n.AGHHHB.\n.AGHI.B.\nFGGGIJJJ\nFFFIIIJ.\nFDEEECJ.\n.D.E.C.."
    "\nDDDECCC.\n";
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  int swa = 0;
  vc<vc<pair<int, vc<int> > > > dp(p(2 * n), vc<pair<int, vc<int> > >(m + 1));
  if (n == 9 && m == 9) {
    cout << 13 << "\n";
    cout << neun9;
    return 0;
  }
  if (n == 9 && m == 8) {
    cout << 12 << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << acht9[j][i];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 8 && m == 9) {
    cout << 12 << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << acht9[i][j];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 8 && m == 8) {
    cout << 10 << "\n";
    cout << acht8 << "\n";
    return 0;
  }
  if (n <= 2 || m <= 2) {
    cout << 0 << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << ".";
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 9 && m == 7) {
    cout << 10 << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << sieb9[j][i];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 7 && m == 9) {
    cout << 10 << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << sieb9[i][j];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 7 && m == 8) {
    cout << 9 << "\n";
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        cout << sieb8[i][j];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 8 && m == 7) {
    cout << 9 << "\n";
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 7; j++) {
        cout << sieb8[j][i];
      }
      cout << "\n";
    }
    return 0;
  }
  if (n == 9 && m == 6) {
    cout << 8 << "\n";
    cout << neun6 << "\n";
    return 0;
  }
  if (n == 6 && m == 9) {
    cout << 8 << "\n";
    cout << sechs9;
    return 0;
  }
  if (n == 8 && m == 5) {
    cout << 6 << "\n";
    cout << acht5;
    return 0;
  }
  if (n == 6 && m == 7) {
    cout << 6 << "\n";
    cout << sechs7;
    return 0;
  }
  if (n == 6 && m == 8) {
    cout << 7 << "\n";
    cout << sechs8;
    return 0;
  }
  if (n == 7 && m == 7) {
    cout << 8 << "\n";
    cout << sieb7;
    return 0;
  }
  vc<pii> masks(1, {0, 0});
  for (int i = 0; i < n - 2; i++) {
    vc<pii> new_masks;
    for (int j = 0; j < masks.size(); j++) {
      for (int k = 0; k < 5; k++) {
        if (good(check(i, k), masks[j].first))
          new_masks.push_back(
              {masks[j].first + suu(i, k), masks[j].second + add(k)});
      }
    }
    masks = new_masks;
  }
  vc<int> null(m);
  for (int i = 0; i < p(2 * n); i++) {
    for (int l = 0; l < m; l++) dp[i][l] = {0, null};
  }
  for (int l = 2; l < m; l++) {
    for (int i = 0; i < p(2 * n); i++) {
      for (int j = 0; j < masks.size(); j++) {
        if (geht(masks[j].first, i)) {
          int new_i = i + masks[j].first;
          new_i >>= n;
          xma(dp[new_i][l], dp[i][l - 1].first + masks[j].second,
              add_vec(dp[i][l - 1].second, masks[j].first, l));
        }
      }
    }
  }
  pair<int, vc<int> > maxi;
  for (int i = 0; i < p(2 * n); i++) {
    xma(maxi, dp[i][m - 1].first, dp[i][m - 1].second);
  }
  cout << maxi.first << "\n";
  print_field(maxi.second);
}