import java.io.*;
import java.util.*;

public class TestsGen implements Runnable {
	public static void main(String[] args) {
		if (args.length < 1) {
			for (testNum = 1; (new File(getName(testNum) + ".t")).exists(); testNum++);
		} else {
			testNum = Integer.parseInt(args[0]);
		}
		new Thread(new TestsGen()).start();
	}

	PrintWriter out;

	Random rand = new Random(6439586L);

	static int testNum;

	static String getName(int i) {
		return i / 10 + "" + i % 10;
	}

	void open() {
		try {
			System.out.println("Generating test " + testNum);
			out = new PrintWriter(getName(testNum));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	void close() {
		out.close();
		testNum++;
	}
	
	final String alpha = "abcdefghijklmnopqrstuvwxyz";
	final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	final String digits = "0123456789";

	String randString(int len, String s) {
		StringBuilder ans = new StringBuilder();
		int k = s.length();
		for (int i = 0; i < len; i++) {
			ans.append(s.charAt(rand.nextInt(k)));
		}
		return ans.toString();
	}


	long rand(long l, long r) {
		return l + (rand.nextLong() >>> 1) % (r - l + 1);
	}

	int rand(int l, int r) {
		return l + rand.nextInt(r - l + 1);
	}
	
	final int MAXN = (int) 1e2;

	void genRandTest() {
		open();
		out.println(randString(rand(1, MAXN), alpha + ALPHA));
		int n = rand(1, MAXN);
		out.println(n);
		for (int i = 0; i < n; ++i) {
			out.println(randString(rand(1, 2), alpha + ALPHA));
		}
		close();
	}

	void genYesTest(int n, int len) {
		String[] names = new String[n];
		for (int i = 0; i < n; ++i) {
			names[i] = randString(rand(1, 2), alpha + ALPHA);
		}
		StringBuilder s = new StringBuilder("");
		for (int i = 0; i < 2 * len; ++i) {
			s.append(names[rand(0, n - 1)]);
		}
		while (s.length() > len) {
			s.deleteCharAt(rand(0, s.length() - 1));
		}
		open();
		out.println(s.toString());
		out.println(n);
		for (int i = 0; i < n; ++i) {
			out.println(names[i]);
		}
		close();
	}

	void genYesTest() {
		genYesTest(rand(1, MAXN), rand(1, MAXN));
	}
	
	public void solve() {
		for (int i = 0; i < 15; ++i) {
			genYesTest();
		}
		for (int i = 0; i < 15; ++i) {
			genRandTest();
		}
		for (int i = 0; i < 5; ++i) {
			genYesTest(MAXN, MAXN);
		}
	}

	void myAssert(boolean e, String msg) {
		if (!e) {
			throw new Error(msg);
		}
	}

	public void run() {
		try {
			solve();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}
}
