#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
vector<tuple<int, int, int> > *moves;
vector<tuple<int, int, int> > g[1 << 9][1 << 9];
vector<vector<pair<string, int> > > *makes;
vector<vector<pair<string, int> > > f[1 << 9][1 << 9];
int n, m;
vector<string> pattern;
bool pos(const int a[3], int i, string s) {
  for (int j = 0; j < 3; j++) {
    for (int k = 0; k < 3; k++)
      if (s[j * 3 + k] == '#' and (bool(a[j] & (1 << (i + k))))) return 0;
  }
  return 1;
}
void change(int a[3], int i, string s) {
  for (int j = 0; j < 3; j++) {
    for (int k = 0; k < 3; k++) {
      if (s[j * 3 + k] == '#') {
        a[j] ^= (1 << (i + k));
        assert((bool(a[j] & (1 << (i + k)))));
      }
    }
  }
}
void gen(int a[3], int i, int tot, vector<pair<string, int> > vs) {
  if (m - i <= 2) {
    moves->push_back(make_tuple(a[1], a[2], tot));
    makes->push_back(vs);
  } else {
    for (string &s : pattern)
      if (pos(a, i, s)) {
        int b[3];
        for (int x = 0; x < 3; x++) b[x] = a[x];
        change(b, i, s);
        vs.push_back({s, i});
        gen(b, i + 1, tot + 1, vs);
        vs.pop_back();
      }
    gen(a, i + 1, tot, vs);
  }
}
bool gens[1 << 9][1 << 9];
int save[9][1 << 9][1 << 9];
void genss(int mask1, int mask2) {
  if (gens[mask1][mask2]) return;
  gens[mask1][mask2] = 1;
  moves = &g[mask1][mask2];
  makes = &f[mask1][mask2];
  int a[3] = {mask1, mask2, 0};
  gen(a, 0, 0, vector<pair<string, int> >());
}
int dp(int i, int mask1, int mask2) {
  if (i <= 1) return 0;
  if (save[i][mask1][mask2] != -1) return save[i][mask1][mask2];
  int &ret = save[i][mask1][mask2] = 0;
  genss(mask1, mask2);
  for (auto x : g[mask1][mask2]) {
    ret = max(ret, (get<2>(x)) + dp(i - 1, (get<0>(x)), (get<1>(x))));
  }
  return ret;
}
char ans[9][9];
int tot = 0;
void assign_num(string s, int row, int column, int id) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (s[i * 3 + j] == '#') {
        assert(ans[row - i][column + j] == 0);
        ans[row - i][column + j] = id;
      }
    }
  }
}
void assign_nums(vector<pair<string, int> > vs, int row) {
  for (auto v : vs) {
    assign_num(v.first, row, v.second, ++tot);
  }
}
void sol(int i, int mask1, int mask2) {
  if (i <= 1) return;
  int ret = dp(i, mask1, mask2);
  assert(g[mask1][mask2].size() == f[mask1][mask2].size());
  for (int j = 0; j < g[mask1][mask2].size(); j++) {
    auto x = g[mask1][mask2][j];
    auto vs = f[mask1][mask2][j];
    if (ret == (get<2>(x)) + dp(i - 1, (get<0>(x)), (get<1>(x)))) {
      assign_nums(vs, i);
      return sol(i - 1, (get<0>(x)), (get<1>(x)));
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pattern.push_back("###.#..#.");
  pattern.push_back("..####..#");
  pattern.push_back(".#..#.###");
  pattern.push_back("#..####..");
  cin >> n >> m;
  memset(save, -1, sizeof save);
  cout << dp(n - 1, 0, 0) << "\n";
  sol(n - 1, 0, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ans[i][j] == 0)
        ans[i][j] = '.';
      else
        ans[i][j] = 'A' + ans[i][j] - 1;
      cout << ans[i][j];
    }
    cout << "\n";
  }
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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
..
..

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
vector<tuple<int, int, int> > *moves;
vector<tuple<int, int, int> > g[1 << 9][1 << 9];
vector<vector<pair<string, int> > > *makes;
vector<vector<pair<string, int> > > f[1 << 9][1 << 9];
int n, m;
vector<string> pattern;
bool pos(const int a[3], int i, string s) {
  for (int j = 0; j < 3; j++) {
    for (int k = 0; k < 3; k++)
      if (s[j * 3 + k] == '#' and (bool(a[j] & (1 << (i + k))))) return 0;
  }
  return 1;
}
void change(int a[3], int i, string s) {
  for (int j = 0; j < 3; j++) {
    for (int k = 0; k < 3; k++) {
      if (s[j * 3 + k] == '#') {
        a[j] ^= (1 << (i + k));
        assert((bool(a[j] & (1 << (i + k)))));
      }
    }
  }
}
void gen(int a[3], int i, int tot, vector<pair<string, int> > vs) {
  if (m - i <= 2) {
    moves->push_back(make_tuple(a[1], a[2], tot));
    makes->push_back(vs);
  } else {
    for (string &s : pattern)
      if (pos(a, i, s)) {
        int b[3];
        for (int x = 0; x < 3; x++) b[x] = a[x];
        change(b, i, s);
        vs.push_back({s, i});
        gen(b, i + 1, tot + 1, vs);
        vs.pop_back();
      }
    gen(a, i + 1, tot, vs);
  }
}
bool gens[1 << 9][1 << 9];
int save[9][1 << 9][1 << 9];
void genss(int mask1, int mask2) {
  if (gens[mask1][mask2]) return;
  gens[mask1][mask2] = 1;
  moves = &g[mask1][mask2];
  makes = &f[mask1][mask2];
  int a[3] = {mask1, mask2, 0};
  gen(a, 0, 0, vector<pair<string, int> >());
}
int dp(int i, int mask1, int mask2) {
  if (i <= 1) return 0;
  if (save[i][mask1][mask2] != -1) return save[i][mask1][mask2];
  int &ret = save[i][mask1][mask2] = 0;
  genss(mask1, mask2);
  for (auto x : g[mask1][mask2]) {
    ret = max(ret, (get<2>(x)) + dp(i - 1, (get<0>(x)), (get<1>(x))));
  }
  return ret;
}
char ans[9][9];
int tot = 0;
void assign_num(string s, int row, int column, int id) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (s[i * 3 + j] == '#') {
        assert(ans[row - i][column + j] == 0);
        ans[row - i][column + j] = id;
      }
    }
  }
}
void assign_nums(vector<pair<string, int> > vs, int row) {
  for (auto v : vs) {
    assign_num(v.first, row, v.second, ++tot);
  }
}
void sol(int i, int mask1, int mask2) {
  if (i <= 1) return;
  int ret = dp(i, mask1, mask2);
  assert(g[mask1][mask2].size() == f[mask1][mask2].size());
  for (int j = 0; j < g[mask1][mask2].size(); j++) {
    auto x = g[mask1][mask2][j];
    auto vs = f[mask1][mask2][j];
    if (ret == (get<2>(x)) + dp(i - 1, (get<0>(x)), (get<1>(x)))) {
      assign_nums(vs, i);
      return sol(i - 1, (get<0>(x)), (get<1>(x)));
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pattern.push_back("###.#..#.");
  pattern.push_back("..####..#");
  pattern.push_back(".#..#.###");
  pattern.push_back("#..####..");
  cin >> n >> m;
  memset(save, -1, sizeof save);
  cout << dp(n - 1, 0, 0) << "\n";
  sol(n - 1, 0, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ans[i][j] == 0)
        ans[i][j] = '.';
      else
        ans[i][j] = 'A' + ans[i][j] - 1;
      cout << ans[i][j];
    }
    cout << "\n";
  }
}

```