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 long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T, typename second>
T expo(T b, second e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T, typename second>
T expo(T b, second e) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b), e >> 1) : (b * expo((b * b), e >> 1));
}
template <typename T, typename second>
T modinv(T a, second mod) {
  return expo(a, mod - 2, mod);
}
template <class T, class second>
std::ostream &operator<<(std::ostream &os, const std::pair<T, second> &t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &t) {
  os << "[";
  for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++) {
    if (it != t.begin()) os << ", ";
    os << *it;
  }
  os << "]";
  return os;
}
const int MAXN = 9;
int n, m;
int dp[MAXN + 1][1 << MAXN][1 << MAXN];
int res;
char grid[MAXN + 1][MAXN + 1];
int place[MAXN + 1][MAXN + 1];
pair<int, int> set_by[MAXN + 1][1 << MAXN][1 << MAXN];
pair<int, pair<int, int> > corr;
int get_bit(int num, int b) { return ((1 << b) & num) >> b; }
struct loc {
  int r, c;
  int o;
};
vector<loc> fack[MAXN + 1][1 << MAXN][1 << MAXN];
void setter(int r, int c, int orient) {
  static char cnt = 'A';
  if (orient == 0) {
    grid[r][c] = grid[r - 1][c] = grid[r - 1][c - 1] = grid[r - 1][c + 1] =
        grid[r + 1][c] = cnt;
  } else if (orient == 1) {
    grid[r][c] = grid[r][c - 1] = grid[r][c + 1] = grid[r - 1][c + 1] =
        grid[r + 1][c + 1] = cnt;
  } else if (orient == 2) {
    grid[r][c] = grid[r - 1][c] = grid[r + 1][c] = grid[r + 1][c - 1] =
        grid[r + 1][c + 1] = cnt;
  } else {
    grid[r][c] = grid[r][c + 1] = grid[r][c - 1] = grid[r - 1][c - 1] =
        grid[r + 1][c - 1] = cnt;
  }
  cnt++;
}
void go(int i, int layer, int p1, int p2, int q0, int q1, int q2,
        vector<loc> &V, int added) {
  if (i == m) {
    if (dp[layer + 1][q1][q2] < added) {
      dp[layer + 1][q1][q2] = added;
      set_by[layer + 1][q1][q2] = {p1, p2};
      fack[layer + 1][q1][q2] = V;
      if (res < dp[layer + 1][q1][q2]) {
        res = dp[layer + 1][q1][q2];
        corr = {layer + 1, {q1, q2}};
      }
    }
    return;
  }
  go(i + 1, layer, p1, p2, q0, q1, q2, V, added);
  if (layer + 2 >= n) {
    return;
  }
  if (i > 0 and i + 1 < m and !get_bit(q0, i) and !get_bit(q0, i - 1) and
      !get_bit(q0, i + 1) and !get_bit(q1, i) and !get_bit(q2, i)) {
    V.push_back({layer + 1, i, 0});
    go(i + 2, layer, p1, p2, q0 | (7 << (i - 1)), q1 | (1 << i), q2 | (1 << i),
       V, added + 1);
    V.pop_back();
  }
  if (i - 2 >= 0 and !get_bit(q0, i) and !get_bit(q1, i) and !get_bit(q2, i) and
      !get_bit(q1, i - 1) and !get_bit(q1, i - 2)) {
    V.push_back({layer + 1, i - 1, 1});
    go(i + 1, layer, p1, p2, q0 | (1 << i), q1 | 7 << (i - 2), q2 | (1 << i), V,
       added + 1);
    V.pop_back();
  }
  if (i > 0 and i + 1 < m and !get_bit(q2, i) and !get_bit(q2, i - 1) and
      !get_bit(q2, i + 1) and !get_bit(q1, i) and !get_bit(q0, i)) {
    V.push_back({layer + 1, i, 2});
    go(i + 1, layer, p1, p2, q0 | (1 << i), q1 | (1 << i),
       q2 | (1 << (i - 1)) | (1 << i) | (1 << (i + 1)), V, added + 1);
    V.pop_back();
  }
  if (i + 2 < m and !get_bit(q0, i) and !get_bit(q1, i) and !get_bit(q2, i) and
      !get_bit(q1, i + 1) and !get_bit(q1, i + 2)) {
    V.push_back({layer + 1, i + 1, 3});
    go(i + 1, layer, p1, p2, q0 | (1 << i), q1 | 7 << i, q2 | (1 << i), V,
       added + 1);
    V.pop_back();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      grid[i][j] = '.';
    }
  }
  for (int i = 0; i < n; i++) {
    for (int m1 = 0; m1 < 1 << m; m1++) {
      for (int m2 = 0; m2 < 1 << m; m2++) {
        vector<loc> V;
        go(0, i, m1, m2, m1, m2, 0, V, dp[i][m1][m2]);
      }
    }
  }
  cout << res << '\n';
  int a, b, c;
  while (res > 0) {
    a = corr.first, b = corr.second.first, c = corr.second.second;
    res -= fack[a][b][c].size();
    for (auto &elem : fack[a][b][c]) {
      setter(elem.r, elem.c, elem.o);
    }
    corr = {corr.first - 1, set_by[a][b][c]};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << grid[i][j];
    }
    cout << '\n';
  }
  return 0;
}