import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Random;

public class gen_tests {
	public static void main(String[] args) throws IOException {
		digits = "";
		for (int i = 0; i < 10; i++) {
			digits += i;
		}
		for (char c = 'A'; c <= 'Z'; c++) {
			digits += c;
		}
		Random rand = new Random(2345342);
		for (int test = 1; test <= 50; test++) {
			PrintWriter out = new PrintWriter((test < 10 ? "0" : "") + test);
			switch (test) {
			case 1:
				out.println("10 2");
				out.println("23");
				break;
			case 2:
				out.println("16 2");
				out.println("FF");
				break;
			case 3:
				out.println("26 2");
				out.println("HP");
				break;
			case 4:
				String s = minPrev("AKHIANTON");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 5:
				s = minPrev("ANTONAKHI");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 6:
				s = minPrev("AAA");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 7:
				s = minPrev("NRUIOTSPBSUITMO2ZUSTARLAB");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 8:
				s = minPrev("NEERC");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 9:
				s = minPrev("IMPOSSIBLE");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 10:
				out.println("36 9");
				out.println("ANTONAKHI");
				break;
			case 11:
				s = minPrev("THISISAVERYLONGTESTBECAUSETHERESHOULDBEATLEASTONEINTERESTINGTESTWITHTHELENGTHOFTHEINPUTSTRINGMORETHAN100SYMBOLSBUTITISVERYHARDTOWRITEASTRINGWITHTHELENGTH100000");
				out.println(s.substring(0, s.indexOf('\n')));
				out.println(s.substring(s.indexOf('\n') + 1));
				break;
			case 12:
				out.println("23 100000");
				for (int i = 0; i < 100000 - 1; i++) {
					out.print("0");
				}
				out.println("1");
				break;
			case 13:
				out.println("2 100000");
				for (int i = 0; i < 100000; i++) {
					out.print("0");
				}
				out.println();
				break;
			case 14:
				out.println("2 100000");
				for (int i = 0; i < 100000; i++) {
					out.print("1");
				}
				out.println();
				break;
			case 15:
				out.println("11 1");
				out.println("A");
				break;
			case 16:
				out.println("36 1");
				out.println("Z");
				break;
			case 17:
				out.println("10 1");
				out.println("2");
				break;
			case 18:
				out.println("36 100000");
				for (int i = 0; i < 100000; i++) {
					out.print("Z");
				}
				out.println();
				break;
			default:
				int k = 2 + rand.nextInt(35);
				int n = test > 40 ? 100000 : 1 + rand.nextInt(k);
				int m = rand.nextInt(100001 - n);
				out.println(k + " " + (n + m));
				while (m-- > 0) {
					out.print("0");
				}
				for (int i = 0; i < n; i++) {
					out.print(digits.charAt(rand.nextInt(k)));
				}
				out.println();
				break;
			}
			out.close();
		}
	}

	static String digits;

	static String prev(String str, int k) {
		char[] s = str.toCharArray();
		int[] a = new int[s.length];
		for (int i = 0; i < a.length; i++) {
			a[i] = digits.indexOf(s[i]);
		}
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			sum += a[i];
		}
		int q = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = a.length - 1; i >= 0; i--) {
			if (a[i] - 1 >= 0 && 0 <= q - 1
					&& q + 1 <= (a.length - i - 1) * (k - 1)) {
				a[i]--;
				q++;
				int j = i + 1;
				while (j < a.length) {
					a[j] = Math.min(k - 1, q);
					q -= a[j++];
				}
				for (int w = 0; w < a.length; w++) {
					if (w > 0 || a[w] > 0) {
						sb.append(digits.charAt(a[w]));
					}
				}
				break;
			}
			q += a[i];
		}
		return sb.toString();
	}

	static String minPrev(String s) {
		int k = 0;
		for (char c : s.toCharArray()) {
			k = Math.max(k, digits.indexOf(c));
		}
		String ss = prev(s, k + 1);
		while (ss.length() == 0) {
			k++;
			ss = prev(s, k + 1);
		}
		return (k + 1) + " " + ss.length() + "\n" + ss;
	}
}
