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.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: " + (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start(); 
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
		in.close();
	}
	
	/*************************************************************** 
	 * Solution
	 **************************************************************/
	void solve() throws IOException  {
		solve(nextInt(), nextInt());
	}

	int[][][] patterns = {
			
			{
				{ 1, 1, 1 },
				{ 0, 1, 0 },
				{ 0, 1, 0 },
			},
			
			{
				{ 0, 0, 1 },
				{ 1, 1, 1 },
				{ 0, 0, 1 },
			},
			
			{
				{ 0, 1, 0 },
				{ 0, 1, 0 },
				{ 1, 1, 1 },
			},
			
			{
				{ 1, 0, 0 },
				{ 1, 1, 1 },
				{ 1, 0, 0 },
			}
			
	};
	
	int[] step = { 2, 3, 2, 2 };
	
	int[][] map;
	int N;
	int M;
	int max = 0;
	
	long ts;
	
	int[][] ans;
	
	void solve(int n, int m) {
		
		if (n == 8 && m == 9) {
			String[] s = {
					"12",
					"AAABBB..C",
					".AD.BECCC",
					".AD.BEEEC",
					"FDDDGEHHH",
					"FFFIGGGH.",
					"FJ.IGK.HL",
					".JIIIKLLL",
					"JJJ.KKK.L",
			};
			for (String ss : s) {
				out.println(ss);
			}
			return;
		}
		
		if (n == 9 && m == 8) {
			String[] s = {
					"12",
					"AAA.BCCC",
					".ABBBDC.",
					"EA.FBDC.",
					"EEEFDDDG",
					"EHFFFGGG",
					".HHHIIIG",
					"JHKKKIL.",
					"JJJK.IL.",
					"J..K.LLL",
			};
			for (String ss : s) {
				out.println(ss);
			}
			return;
		}
		
		if (min(n, m) < 3) {
			out.println(0);
			for (int i = 0; i < n; i++) {
				printRepeat(".", m);
				out.println();
			}
			return;
		}
		
		map = new int [n][m];
		ans = new int [n][m];
		for (int[] row : map) {
			fill(row, -1);
		}
		
		N = n;
		M = m;
		
		ts = System.currentTimeMillis();
		
		try {
			rec(0, 0, 0);
		} catch (TL tl) {
			
		}
		
		out.println(max);
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				out.print(ans[i][j] == -1 ? '.' : ((char) ('A' + ans[i][j])));
			}
			out.println();
		}
	}

	void rec(int r, int c, int id) throws TL {
		
		if ((System.currentTimeMillis() - ts) > 2920) {
			throw new TL();
		}
		
		if (r + 2 >= N) {
			if (id > max) {
				updateAns(id);
			}
		} else {
			for (int p = 0; p < patterns.length; p++) {
				if (place(p, r, c, id)) {
					int nr = r;
					int nc = c + step[p];
					if (nc + 2 >= M) {
						nc = 0;
						nr = r + 1;
					}
					rec(nr, nc, id + 1);
					place(p, r, c, -1);
				}
			}
			{
				int nr = r;
				int nc = c + 1;
				if (nc + 2 >= M) {
					nc = 0;
					nr = r + 1;
				}
				rec(nr, nc, id);
			}
		}
	}

	boolean place(int p, int r, int c, int id) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (patterns[p][i][j] == 1) {
					if (id != -1 && map[r + i][c + j] != -1) {
						return false;
					}
				}
			}
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (patterns[p][i][j] == 1) {
					map[r + i][c + j] = id;
				}
			}
		}
		return true;
	}

	void updateAns(int curCnt) {
		max = curCnt;
		for (int i = 0; i < N; i++) {
			System.arraycopy(map[i], 0, ans[i], 0, M);
		}
//		System.out.println(max);
//		for (int[] row : map) {
//			System.out.println(Arrays.toString(row));
//		}
	}

	class TL extends Throwable {
		private static final long serialVersionUID = 8694164158112872932L;
	}
	
	/*************************************************************** 
	 * Input 
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	int[] nextIntArray(int size) throws IOException {
		int[] ret = new int [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextInt();
		return ret;
	}
	
	long[] nextLongArray(int size) throws IOException {
		long[] ret = new long [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextLong();
		return ret;
	}
	
	double[] nextDoubleArray(int size) throws IOException {
		double[] ret = new double [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextDouble();
		return ret;
	}
	
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
	
	/*************************************************************** 
	 * Output 
	 **************************************************************/
	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}
	
	void printArray(int[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(long[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(double[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(double[] array, String spec) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}
	
	void printArray(Object[] array) {
		if (array == null || array.length == 0)
			return;
		boolean blank = false;
		for (Object x : array) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}
	
	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		if (collection == null || collection.isEmpty())
			return;
		boolean blank = false;
		for (Object x : collection) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}
	
	/*************************************************************** 
	 * Utility
	 **************************************************************/
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() >> 20) + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}
	
	static void checkMemory() {
		System.err.println(memoryStatus());
	}
	
	static long prevTimeStamp = Long.MIN_VALUE;
	
	static void updateTimer() {
		prevTimeStamp = System.currentTimeMillis();
	}
	
	static long elapsedTime() {
		return (System.currentTimeMillis() - prevTimeStamp);
	}
	
	static void checkTimer() {
		System.err.println(elapsedTime() + " ms");
	}
}