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.util.*;

public class C {

    int n, m, c;
    int bc0, bc1, ii;
    char ch;

    int[][][] d, t1, t2;
    int[][][][] p;
    int[] a = new int[10];

    char[][] o;

    void go(int i, int j, int c0, int c1, int c2, int l, int q) {
        if (j == m) {
            for (int p2 = 0; p2 < c; ++p2) {
                if ((p2 & c2) == 0) {
                    for (int p1 = 0; p1 < c; ++p1) {
                        if ((p1 & c1) == 0) {
                            int pc = p1 | c1;
                            if (d[i - 1][p1][p2] + q > d[i][c0][pc]) {
                                d[i][c0][pc] = d[i - 1][p1][p2] + q;
                                t1[i][c0][pc] = p1;
                                t2[i][c0][pc] = p2;
                                p[i][c0][pc] = Arrays.copyOf(a, l);
                                if (bc0 == -1 || (d[i][c0][pc] > d[ii][bc0][bc1])) {
                                    ii = i;
                                    bc0 = c0;
                                    bc1 = pc;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            //1
            int x0 = c0;
            int x1 = c1;
            int x2 = c2;
            if (j + 2 < m) {
                x0 = s(x0, j);
                x0 = s(x0, j + 1);
                x0 = s(x0, j + 2);
                if (f(x1, j + 1) && f(x2, j + 1)) {
                    x1 = s(x1, j + 1);
                    x2 = s(x2, j + 1);
                    a[l] = 1;
                    go(i, j + 3, x0, x1, x2, l + 1, q + 1);
                }
            }
            //2
            x0 = c0;
            x1 = c1;
            x2 = c2;
            if (j > 0 && j + 1 < m) {
                x0 = s(x0, j);
                if (f(x1, j) && f(x2, j - 1) && f(x2, j) && f(x2, j + 1)) {
                    x1 = s(x1, j);
                    x2 = s(x2, j - 1);
                    x2 = s(x2, j);
                    x2 = s(x2, j + 1);
                    a[l] = 2;
                    go(i, j + 1, x0, x1, x2, l + 1, q + 1);
                }
            }
            //3
            x0 = c0;
            x1 = c1;
            x2 = c2;
            if (j + 2 < m) {
                x0 = s(x0, j);
                if (f(x1, j) && f(x1, j + 1) && f(x1, j + 2) && f(x2, j)) {
                    x1 = s(x1, j);
                    x1 = s(x1, j + 1);
                    x1 = s(x1, j + 2);
                    x2 = s(x2, j);
                    a[l] = 3;
                    go(i, j + 1, x0, x1, x2, l + 1, q + 1);
                }
            }
            //4
            x0 = c0;
            x1 = c1;
            x2 = c2;
            if (j > 1) {
                x0 = s(x0, j);
                if (f(x1, j - 2) && f(x1, j - 1) && f(x1, j) && f(x2, j)) {
                    x1 = s(x1, j - 2);
                    x1 = s(x1, j - 1);
                    x1 = s(x1, j);
                    x2 = s(x2, j);
                    a[l] = 4;
                    go(i, j + 1, x0, x1, x2, l + 1, q + 1);
                }
            }
            //5
            a[l] = 5;
            go(i, j + 1, c0, c1, c2, l + 1, q);
        }
    }

    boolean f(int c, int j) {
        return (c & (1 << j)) == 0;
    }

    int s(int c, int j) {
        return c | (1 << j);
    }

    void draw(int i, int c0, int c1) {
        if (i < 2) return;
        int[] v = p[i][c0][c1];
        if (v == null) return;
        int pos = 0;
        for (int j = 0; j < v.length; ++j) {
            switch (v[j]) {
                case 1:
                    o[i][pos] = ch;
                    o[i][pos + 1] = ch;
                    o[i][pos + 2] = ch;
                    o[i - 1][pos + 1] = ch;
                    o[i - 2][pos + 1] = ch;
                    pos += 3;
                    ++ch;
                    break;
                case 2:
                    o[i][pos] = ch;
                    o[i - 1][pos] = ch;
                    o[i - 2][pos] = ch;
                    o[i - 2][pos - 1] = ch;
                    o[i - 2][pos + 1] = ch;
                    ++pos;
                    ++ch;
                    break;
                case 3:
                    o[i][pos] = ch;
                    o[i - 1][pos] = ch;
                    o[i - 1][pos + 1] = ch;
                    o[i - 1][pos + 2] = ch;
                    o[i - 2][pos] = ch;
                    ++pos;
                    ++ch;
                    break;
                case 4:
                    o[i][pos] = ch;
                    o[i - 1][pos] = ch;
                    o[i - 1][pos - 1] = ch;
                    o[i - 1][pos - 2] = ch;
                    o[i - 2][pos] = ch;
                    ++pos;
                    ++ch;
                    break;
                case 5:
                    ++pos;
            }
        }
        draw(i - 1, t1[i][c0][c1], t2[i][c0][c1]);
    }

    void solve() throws IOException {
        in("__std"); out("__std");


//        for (int nn = 1; nn <= 9; ++nn) {
//            for (int mm = 1; mm <= 9; ++mm) {

        n = readInt();
        m = readInt();
        //        n = nn;
        //        m = mm;

        //long tt = System.currentTimeMillis();

        c = 1 << m;

        bc0 = -1;
        ch = 'A';

        d = new int[n][c][c];
        t1 = new int[n][c][c];
        t2 = new int[n][c][c];
        p = new int[n][c][c][];

        for (int i = 2; i < n; ++i) {
            go(i, 0, 0, 0, 0, 0, 0);
        }

        o = new char[n][m];
        for (int i = 0; i < n; ++i) {
            Arrays.fill(o[i], '.');
        }

        if (bc0 != -1) {
            println(d[ii][bc0][bc1]);
            draw(ii, bc0, bc1);
        } else {
            println(0);
        }

        for (int i = 0; i < n; ++i) {
            println(new String(o[i]));
        }
            //}
        //}

        //System.out.println(System.currentTimeMillis() - tt);

        exit();
    }

    void in(String name) throws IOException {
        if (name.equals("__std")) {
            in = new BufferedReader(new InputStreamReader(System.in));
        } else {
            in = new BufferedReader(new FileReader(name));
        }
    }

    void out(String name) throws IOException {
        if (name.equals("__std")) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(name);
        }
    }

    void exit() {
        out.close();
        System.exit(0);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readToken());
    }

    long readLong() throws IOException {
        return Long.parseLong(readToken());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readToken());
    }

    String readLine() throws IOException {
        st = null;
        return in.readLine();
    }

    String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    boolean eof() throws IOException {
        return !in.ready();
    }

    void print(String format, Object ... args) {
        out.println(new Formatter(Locale.US).format(format, args));
    }

    void println(String format, Object ... args) {
        out.println(new Formatter(Locale.US).format(format, args));
    }

    void print(Object value) {
        out.print(value);
    }

    void println(Object value) {
        out.println(value);
    }

    void println() {
        out.println();
    }

    StringTokenizer st;

    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new C().solve();
    }
}