import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Random;

public class gen_halfcase {
	static Random rand = new Random(132123);

	public static void main(String[] args) throws IOException {
		for (int test = 1; test <= 50; test++) {
			PrintWriter out = new PrintWriter((test < 10 ? "0" : "") + test);
			switch (test) {
			case 1:
				out.println("2");
				out.println("Ok");
				out.println("ok");
				out.println("4");
				out.println("Ok");
				out.println("ok");
				out.println("OK");
				out.println("oK");
				break;
			case 2:
				out.println("2");
				out.println("no");
				out.println("no");
				out.println("2");
				out.println("NO");
				out.println("No");
				break;
			case 29:
				out.println("1");
				out.println("a");
				out.println("1");
				out.println("A");
				break;
			case 3:
				out.println("1");
				out.println("a");
				out.println("2");
				out.println("a");
				out.println("A");
				break;
			case 4:
				out.println("2");
				out.println("a");
				out.println("a");
				out.println("2");
				out.println("a");
				out.println("A");
				break;
			case 5:
				out.println("2");
				out.println("A");
				out.println("a");
				out.println("2");
				out.println("a");
				out.println("A");
				break;
			case 6:
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					for (int j = 0; j <= i % 20; j++) {
						out.print((char) ((i % 40 < 20 ? 'A' : 'a') + i / 40));
					}
					out.println();
				}
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					for (int j = 0; j <= i % 20; j++) {
						out.print((char) ((i % 40 < 20 ? 'A' : 'a') + i / 40));
					}
					out.println();
				}
				break;
			case 7:
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					for (int j = 0; j < 20; j++) {
						if ((i & (1 << j)) != 0) {
							out.print('A');
						} else {
							out.print('a');
						}
					}
					out.println();
				}
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					int x = rand.nextInt(1 << 20);
					for (int j = 0; j < 20; j++) {
						if ((x & (1 << j)) != 0) {
							out.print('A');
						} else {
							out.print('a');
						}
					}
					out.println();
				}
				break;
			case 8:
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					for (int j = 0; j < 20; j++) {
						if ((i & (1 << j)) != 0) {
							out.print('A');
						} else {
							out.print('a');
						}
					}
					out.println();
				}
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					int x = rand.nextInt(1 << 10);
					for (int j = 0; j < 20; j++) {
						if ((x & (1 << j)) != 0) {
							out.print('A');
						} else {
							out.print('a');
						}
					}
					out.println();
				}
				break;
			case 9:
			case 10:
			case 11:
			case 12:
			case 13:
			case 14:
			case 15:
			case 16:
			case 17:
			case 18:
			case 19:
			case 20:
			case 21:
			case 22:
			case 23:
			case 24:
			case 25:
			case 26:
			case 27:
			case 28:
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					out.println(genRandomString(test - 8));
				}
				out.println("1000");
				for (int i = 0; i < 1000; i++) {
					out.println(genRandomString(test - 8));
				}
				break;

			default:
				int n = test < 45 ? 1 + rand.nextInt(1000) : 1000;
				HashSet<String> hs = new HashSet<String>();
				while (hs.size() < n) {
					String s = genRandomString(test < 40 ? 1 + rand.nextInt(20)
							: 20);
					hs.add(s);
					if (hs.size() < n) {
						int diff = 1 + rand.nextInt(Math.min(n - hs.size(),
								1 << s.length()));
						while (diff < 0) {
							String ss = randomCase(s);
							hs.add(ss);
						}
					}
				}
				out.println(n);
				for (String s : hs) {
					out.println(s);
				}
				String[] a = new String[n];
				int top = 0;
				for (String s : hs) {
					a[top++] = s;
				}
				int m = test < 45 ? rand.nextInt(1001) : 1000;
				out.println(m);
				for (int i = 0; i < m; i++) {
					if (rand.nextInt(10) == 0) {
						out.println(genRandomString(test < 43 ? 1 + rand
								.nextInt(20) : 20));
					} else {
						int x = rand.nextInt(n);
						if (rand.nextBoolean()) {
							out.println(a[x]);
						} else {
							out.println(randomCase(a[x]));
						}
					}
				}
				break;
			}
			out.close();
		}
	}

	private static String randomCase(String s) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			sb.append(rand.nextBoolean() ? Character.toLowerCase(s.charAt(i))
					: Character.toUpperCase(s.charAt(i)));
		}
		return sb.toString();
	}

	private static String genRandomString(int len) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < len; i++) {
			sb.append((char) ((rand.nextBoolean() ? 'A' : 'a') + rand
					.nextInt(26)));
		}
		return sb.toString();
	}
}
