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.io.*;
    import java.math.*;
    import java.util.*;
    import java.awt.geom.*;

    import static java.lang.Math.*;

    public class Solution implements Runnable {
           
            final String fname = "";
           
            char cur [][];
            char ans [][];
            int anscount = 0;
            int N,M;
           
            HashSet<Integer> cache [][][];
           
            void drawFigure (char cur [][], int no, char z, int r, int c) {
                    if (no == 1) {
                            cur [r][c] = z;
                            cur [r][c+1] = z;
                            cur [r][c+2] = z;
                            cur [r+1][c+1] = z;
                            cur [r+2][c+1] = z;
                    }
                    if (no == 2) {
                            cur [r][c+2] = z;
                            cur [r+1][c] = z;
                            cur [r+1][c+1] = z;
                            cur [r+1][c+2] = z;
                            cur [r+2][c+2] = z;
                    }
                    if (no == 3) {
                            cur [r][c+1] = z;
                            cur [r+1][c+1] = z;
                            cur [r+2][c] = z;
                            cur [r+2][c+1] = z;
                            cur [r+2][c+2] = z;
                    }
                    if (no == 4) {
                            cur [r][c] = z;
                            cur [r+1][c] = z;
                            cur [r+2][c] = z;
                            cur [r+1][c+1] = z;
                            cur [r+1][c+2] = z;
                    }
            }
           
            int getMask1 (int no, int r, int c, int mask) {
                    if (no == 1) {
                            mask |= (1<<c);
                            mask |= (1<<(c+1));
                            mask |= (1<<(c+2));
                    }
                    if (no == 2) {
                            mask |= (1<<(c+2));
                    }
                    if (no == 3) {
                            mask |= (1<<(c+1));
                    }
                    if (no == 4) {
                            mask |= (1<<c);
                    }
                    return mask;
            }
           
            int getMask2 (int no, int r, int c, int mask) {
                    if (no == 1) {
                            mask |= (1<<(c+1));
                    }
                    if (no == 2) {
                            mask |= (1<<c);
                            mask |= (1<<(c+1));
                            mask |= (1<<(c+2));
                    }
                    if (no == 3) {
                            mask |= (1<<(c+1));
                    }
                    if (no == 4) {
                            mask |= (1<<c);
                            mask |= (1<<(c+1));
                            mask |= (1<<(c+2));
                    }
                    return mask;
            }
           
            int getMask3 (int no, int r, int c, int mask) {
                    if (no == 1) {
                            mask |= (1<<(c+1));
                    }
                    if (no == 2) {
                            mask |= (1<<(c+2));
                    }
                    if (no == 3) {
                            mask |= (1<<c);
                            mask |= (1<<(c+1));
                            mask |= (1<<(c+2));
                    }
                    if (no == 4) {
                            mask |= (1<<c);
                            mask |= (1<<(c+1));
                            mask |= (1<<(c+2));
                    }
                    return mask;
            }

           
            void rec (int r, int c, int count, int mask1, int mask2, int mask3) {
                   
                    if (cache[r][c][count].contains((mask1 << (2*M)) | (mask2 << M) | mask3)) {
                            return;
                    }
                    cache[r][c][count].add((mask1 << (2*M)) | (mask2 << M) | mask3);
                   
                    if (c == M - 2) {
                            rec (r + 1, 0, count, mask2, mask3, 0);
                            return;
                    }

                    if (r == N - 2) {
                            if (count > anscount) {
                                    anscount = count;
                                    for (int i = 0; i < N; i++)
                                            for (int j = 0; j < M; j++)
                                                    ans [i][j] = cur [i][j];
                            }
                            return;
                    }

                    //first
                    if (cur [r][c] == '.' && cur [r][c+1] == '.' && cur [r][c+2] == '.' && cur [r+1][c+1] == '.' && cur [r+2][c+1] == '.') {
                            drawFigure (cur, 1, (char)(count + 'A'), r, c);
                            rec (r, c + 1, count + 1, getMask1 (1, r, c, mask1), getMask2 (1, r, c, mask2), getMask3 (1, r, c, mask3));
                            drawFigure (cur, 1, '.', r, c);
                    }
                    //second
                    if (cur [r][c+2]== '.' && cur [r+1][c] == '.' && cur[r+1][c+1] == '.' && cur [r+1][c+2] == '.' && cur [r+2][c+2] == '.') {
                            drawFigure (cur, 2, (char)(count + 'A'), r, c);
                            rec (r, c + 1, count + 1, getMask1 (2, r, c, mask1), getMask2 (2, r, c, mask2), getMask3 (2, r, c, mask3));
                            drawFigure (cur, 2, '.', r, c);
                    }
                    //third
                    if (cur [r][c+1] == '.' && cur [r+1][c+1] == '.' && cur [r+2][c] == '.' && cur [r+2][c+1] == '.' && cur[r+2][c+2] == '.') {
                            drawFigure (cur, 3, (char)(count + 'A'), r, c);
                            rec (r, c + 1, count + 1, getMask1 (3, r, c, mask1), getMask2 (3, r, c, mask2), getMask3 (3, r, c, mask3));
                            drawFigure (cur, 3, '.', r, c);
                    }
                    //fourth
                    if (cur [r][c] == '.' && cur [r+1][c] == '.' && cur [r+2][c] == '.' && cur[r+1][c+1] == '.' && cur[r+1][c+2] == '.') {
                            drawFigure (cur, 4, (char)(count + 'A'), r, c);
                            rec (r, c + 1, count + 1, getMask1 (4, r, c, mask1), getMask2 (4, r, c, mask2), getMask3 (4, r, c, mask3));
                            drawFigure (cur, 4, '.', r, c);
                    }
                    rec (r, c + 1, count, mask1 , mask2, mask3);
            }
           
            public void solveTest(int n, int m) throws Exception {
                    cur = new char [n + 10][m + 10];
                    ans = new char [n][m];
                    N = n;
                    M = m;
                    for (int i = 0; i < n ; i++)
                            for (int j = 0; j < m; j++) {
                                    cur [i][j] = '.';
                                    ans [i][j] = '.';
                            }
                    anscount = 0;
                    if (n < 3 || m < 3) {
                            out.println(0);
                            for (int i = 0; i < n; i++) {
                                    for (int j = 0; j < m; j++)
                                            out.print('.');
                                    out.println();
                            }
                            return;
                    }
                   
                    cache = new HashSet[n][m][15];
                    for (int i = 0; i < n; i++)
                            for (int j = 0; j < m; j++)
                                    for (int k = 0; k < 15; k++)
                                            cache[i][j][k] = new HashSet<Integer>();
                   
                    rec (0, 0, 0, 0, 0, 0);
                    out.println(anscount);
                    for (int i = 0; i < n; i++) {
                            for (int j = 0; j < m; j++)
                                    out.print(ans[i][j]);
                            out.println();
                    }
            }
           
            public void solve() throws Exception {
                    int n = nextInt();
                    int m = nextInt();
                    solveTest (n, m);
            }
           
                   
            /********************************************************************************************/
            /* THERE IS INPUT */

            BufferedReader in;
            PrintWriter out;
            StringTokenizer st;

            long stime=0;
           
            private String next() throws Exception {
                    while (st == null || !st.hasMoreElements())
                            st = new StringTokenizer(in.readLine());
                    return st.nextToken();
            }

            private int nextInt() throws Exception {
                    return Integer.parseInt(next());
            }

            private long nextLong() throws Exception {
                    return Long.parseLong(next());
            }

            private double nextDouble() throws Exception {
                    return Double.parseDouble(next());
            }
           
            public void run() {
                    try {
                            //Locale.setDefault(Locale.US);
                            in = new BufferedReader(new InputStreamReader(System.in));
                            out = new PrintWriter(new OutputStreamWriter(System.out));
                            //in = new BufferedReader(new FileReader(fname+".in"));
                            //out = new PrintWriter(new FileWriter(fname+".out"));
                            solve();
                    } catch (Exception ex) {
                            throw new RuntimeException(ex);
                    } finally {
                            out.close();
                    }
            }
           
            public static void main(String[] args) throws Exception {
                    new Thread(null, new Solution(), "", 1 << 26).start();
            }

           
    }