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 JAVA):

Solution:
import java.util.Arrays;
import java.util.Scanner;

public class HelpTheCareTaker {
    static int[][][] dp;
    char[][] optimal;
    static int[][][] dec;
    static int a, b;

    public static String decToBin(int n) {
        String res = "";
        for (int i = 0; i < 30; i++, n >>= 1) {
            res = (n & 1) + res;
        }
        return res;
    }

    public static long dfs(int i, int r, int cr, int nr, int nnr, int steps) {
        if (i == b)
            return (((long) steps) << 32) | dp[r + 1][nr][nnr];
        long best = dfs(i + 1, r, cr, nr, nnr, steps);
        int max = (int) (best & Integer.MAX_VALUE);
        if (i <= b - 3) {
            if ((cr & (7 << i)) == 0 && (nr & (1 << (i + 1))) == 0
                    && (nnr & (1 << (i + 1))) == 0) {
                long l = 1 + dfs(i + 1, r, cr ^ (7 << i), nr ^ (1 << (i + 1)),
                        nnr ^ (1 << (i + 1)), steps ^ (1 << (i * 3)));
                if ((l & Integer.MAX_VALUE) > max) {
                    best = l;
                    max = (int) (l & Integer.MAX_VALUE);
                }
            }
            if ((nnr & (7 << i)) == 0 && (nr & (1 << (i + 1))) == 0
                    && (cr & (1 << (i + 1))) == 0) {
                long l = 1 + dfs(i + 1, r, cr ^ (1 << (i + 1)), nr
                        ^ (1 << (i + 1)), nnr ^ (7 << i), steps
                        ^ (2 << (i * 3)));
                if ((l & Integer.MAX_VALUE) > max) {
                    best = l;
                    max = (int) (l & Integer.MAX_VALUE);
                }
            }
            if ((nr & (7 << i)) == 0 && (cr & (1 << i)) == 0
                    && (nnr & (1 << i)) == 0) {
                long l = 1 + dfs(i + 1, r, cr ^ (1 << (i)), nr ^ (7 << i), nnr
                        ^ (1 << (i)), steps ^ (3 << (i * 3)));
                if ((l & Integer.MAX_VALUE) > max) {
                    best = l;
                    max = (int) l & (Integer.MAX_VALUE);
                }
            }
            if ((nr & (7 << i)) == 0 && (cr & (1 << (i + 2))) == 0
                    && (nnr & (1 << (i + 2))) == 0) {
                long l = 1 + dfs(i + 1, r, cr ^ (1 << (i + 2)), nr ^ (7 << i),
                        nnr ^ (1 << (i + 2)), steps ^ (4 << (i * 3)));
                if ((l & Integer.MAX_VALUE) > max) {
                    best = l;
                    max = (int) (l & Integer.MAX_VALUE);
                }
            }
        }
        return best;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        a = in.nextInt();
        b = in.nextInt();
        long x = System.nanoTime();
        dp = new int[a][1 << b][1 << b];
        dec = new int[a][1 << b][1 << b];
        for (int i = a - 3; i >= 0; i--) {
            for (int j = 0; j < dp[i].length; j++) {
                for (int k = 0; k < dp[i][j].length; k++) {
                    long res = dfs(0, i, j, k, 0, 0);
                    dp[i][j][k] = (int) (res & Integer.MAX_VALUE);
                    dec[i][j][k] = (int) (res >> 32);
                }
            }
        }
        char[][] res = new char[a][b];
        for (int i = 0; i < res.length; i++)
            Arrays.fill(res[i], '.');
        int r = 0;
        int rcr = 0;
        int rnr = 0;
        int rnnr = 0;
        int cr = 0;
        int nr = 0;
        int nnr = 0;
        char mark = 'A';
        while (r < a) {
            for (int i = 0; i < b; i++) {
                if ((dec[r][rcr][rnr] & (7 << (3 * i))) == (1 << (3 * i))) {
                    cr |= (7 << i);
                    nr |= (1 << (1 + i));
                    nnr |= (1 << (1 + i));
                    res[r][i] = mark;
                    res[r][i + 1] = mark;
                    res[r][i + 2] = mark;
                    res[r + 1][i + 1] = mark;
                    res[r + 2][i + 1] = mark;
                    mark++;
                }
                if ((dec[r][rcr][rnr] & (7 << (3 * i))) == (2 << (3 * i))) {
                    nnr |= (7 << i);
                    nr |= (1 << (1 + i));
                    cr |= (1 << (1 + i));
                    res[r][i + 1] = mark;
                    res[r + 1][i + 1] = mark;
                    res[r + 2][i] = mark;
                    res[r + 2][i + 1] = mark;
                    res[r + 2][i + 2] = mark;
                    mark++;
                }
                if ((dec[r][rcr][rnr] & (7 << (3 * i))) == (3 << (3 * i))) {
                    cr |= (1 << i);
                    nr |= (7 << i);
                    nnr |= (1 << i);
                    res[r][i] = mark;
                    res[r + 1][i] = res[r + 1][i + 1] = res[r + 1][i + 2] = mark;
                    res[r + 2][i] = mark;
                    mark++;
                }
                if ((dec[r][rcr][rnr] & (7 << (3 * i))) == (4 << (3 * i))) {
                    cr |= (1 << (i + 2));
                    nr |= (7 << i);
                    nnr |= (1 << (i + 2));
                    res[r][i + 2] = mark;
                    res[r + 1][i] = res[r + 1][i + 1] = res[r + 1][i + 2] = mark;
                    res[r + 2][i + 2] = mark;
                    mark++;
                }
            }
            rcr = nr;
            rnr = nnr;
            cr = nr;
            nr = nnr;
            nnr = 0;
            r++;
        }
        System.out.println(dp[0][0][0]);
        for (int i = 0; i < res.length; i++)
            System.out.println(new String(res[i]));
    }
}