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;
char ans[10][10];
long long dp[10][513][513];
pair<pair<long long, long long>, long long> recur[10][513][513];
long long insert[10][513][513];
long long curr, nexty, n, m;
long long setBit(long long num, long long i) { return num | (1 << i); }
long long unsetBit(long long num, long long i) {
  num ^= 1 << i;
  return num;
}
bool checkBit(long long num, long long i) {
  if (num & 1 << i)
    return true;
  else
    return false;
}
string binary(long long num, long long m) {
  string ans;
  for (long long i = 0; i < m; i++) {
    if (checkBit(num, i))
      ans = "1" + ans;
    else
      ans = "0" + ans;
  }
  return ans;
}
void backtrack(long long j, long long mask1, long long mask2, long long mask3,
               long long newT, long long ogmask1, long long ogmask2,
               long long ts) {
  if (j == m) {
    if (dp[curr][ogmask1][ogmask2] + newT > dp[nexty][mask2][mask3]) {
      dp[nexty][mask2][mask3] = dp[curr][ogmask1][ogmask2] + newT;
      recur[nexty][mask2][mask3] = pair<pair<long long, long long>, long long>(
          pair<long long, long long>(ogmask1, ogmask2), mask1);
      insert[nexty][mask2][mask3] = ts;
    }
    return;
  }
  if (j > 1) {
    if (!checkBit(mask1, j) && !checkBit(mask1, j - 1) &&
        !checkBit(mask1, j - 2) && !checkBit(mask2, j - 1) &&
        !checkBit(mask3, j - 1)) {
      long long tempmask1 = setBit(mask1, j);
      tempmask1 = setBit(tempmask1, j - 1);
      tempmask1 = setBit(tempmask1, j - 2);
      backtrack(j + 1, tempmask1, setBit(mask2, j - 1), setBit(mask3, j - 1),
                newT + 1, ogmask1, ogmask2, ts);
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j - 1) && !checkBit(mask2, j - 1) &&
        !checkBit(mask3, j - 1) && !checkBit(mask3, j) &&
        !checkBit(mask3, j - 2)) {
      long long newmask = setBit(mask3, j - 1);
      newmask = setBit(newmask, j);
      newmask = setBit(newmask, j - 2);
      backtrack(j + 1, setBit(mask1, j - 1), setBit(mask2, j - 1), newmask,
                newT + 1, ogmask1, ogmask2, setBit(ts, 2 * (j - 1) + 1));
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j - 2) && !checkBit(mask3, j - 2) &&
        !checkBit(mask2, j) && !checkBit(mask2, j - 1) &&
        !checkBit(mask2, j - 2)) {
      long long newmask = setBit(mask2, j);
      newmask = setBit(newmask, j - 1);
      newmask = setBit(newmask, j - 2);
      backtrack(j + 1, setBit(mask1, j - 2), newmask, setBit(mask3, j - 2),
                newT + 1, ogmask1, ogmask2, setBit(ts, 2 * (j - 2)));
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j) && !checkBit(mask3, j) && !checkBit(mask2, j) &&
        !checkBit(mask2, j - 1) && !checkBit(mask2, j - 2)) {
      long long newmask = setBit(mask2, j);
      newmask = setBit(newmask, j - 1);
      newmask = setBit(newmask, j - 2);
      ts = setBit(ts, 2 * j);
      ts = setBit(ts, 2 * j + 1);
      backtrack(j + 1, setBit(mask1, j), newmask, setBit(mask3, j), newT + 1,
                ogmask1, ogmask2, ts);
      ts = unsetBit(ts, 2 * j);
      ts = unsetBit(ts, 2 * j + 1);
    }
  }
  backtrack(j + 1, mask1, mask2, mask3, newT, ogmask1, ogmask2, ts);
}
char currchar = 'A';
void recursion(long long i, long long mask1, long long mask2) {
  if (i == 0) return;
  recursion(i - 1, recur[i][mask1][mask2].first.first,
            recur[i][mask1][mask2].first.second);
  long long mask = insert[i][mask1][mask2];
  for (long long j = 0; j < m; j++) {
    if (!checkBit(recur[i][mask1][mask2].second, j)) {
      ans[i][j] = '.';
      continue;
    }
    if (checkBit(mask, j * 2) && checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j] = ans[i + 2][j] = ans[i + 1][j - 1] =
          ans[i + 1][j - 2] = currchar;
      currchar++;
    } else if (checkBit(mask, j * 2) && !checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j + 2] = ans[i + 2][j] = ans[i + 1][j + 1] =
          ans[i + 1][j] = currchar;
      currchar++;
    } else if (!checkBit(mask, j * 2) && checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j] = ans[i + 2][j + 1] = ans[i + 2][j - 1] =
          ans[i + 2][j] = currchar;
      currchar++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  memset(dp, -1, sizeof(dp));
  memset(ans, 0, sizeof(ans));
  dp[0][0][0] = 0;
  for (long long i = 0; i < n; i++) {
    curr = i;
    nexty = i + 1;
    for (long long mask1 = 0; mask1 < (1 << m); mask1++) {
      for (long long mask2 = 0; mask2 < (1 << m); mask2++) {
        if (dp[curr][mask1][mask2] != -1) {
          backtrack(0, mask1, mask2, 0, 0, mask1, mask2, 0);
        }
      }
    }
  }
  cout << dp[n][0][0] << "\n";
  recursion(n, 0, 0);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < m; j++) {
      if (ans[i][j] == 0 && ans[i][j - 1] == 0 && ans[i][j + 1] == 0 &&
          ans[i + 1][j] == 0 && ans[i + 2][j] == 0) {
        ans[i][j] = ans[i][j - 1] = ans[i][j + 1] = ans[i + 1][j] =
            ans[i + 2][j] = currchar;
        currchar++;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < m; j++) cout << ans[i][j];
    cout << "\n";
  }
}