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

public class TestsGen implements Runnable {
	public static void main(String[] args) {
		new TestsGen().run();
	}

	public int done = 0;
	ArrayList<String> data = new ArrayList<String>();

	final int MAXLEN = 3000;
	final int MAXNUM = 3000;

	final String terminator = "qwyzx";

	public void print() throws IOException {
		done++;
		System.err.println(done);
		PrintWriter out;
		if (done < 10)
			out = new PrintWriter("0" + String.valueOf(done));
		else
			out = new PrintWriter(String.valueOf(done));

		for (int i = 0; i < data.size(); i++) {
			out.print(data.get(i));
			if (i < data.size() - 1) {
				out.println();
			}
		}
		data.clear();
		out.println();
		out.close();
	}

	public void genSample1() throws IOException {
		data.add("3 2");
		data.add("a");
		data.add("a");
		data.add("LR");
		print();
	}

	public void genSample2() throws IOException {
		data.add("7 1");
		data.add("abc");
		data.add("L");
		print();
	}

	public int nextInt(int low, int high) {
		int base = high - low + 1;
		int val = rnd.nextInt();
		val %= base;
		while (val < 0)
			val += base;
		val += low;
		return val;
	}

	public void genEndGood() throws IOException {
		data.add("3 4");
		data.add("b");
		data.add("a");
		data.add("a");
		data.add(terminator);
		data.add("RRLR");
		print();
	}

	public void genSmall() throws IOException {
		data.add("3 3");
		data.add("ba");
		data.add("ab");
		data.add(terminator);
		data.add("RLR");
		print();
	}

	public void genSmallFail() throws IOException {
		data.add("3 2");
		data.add("ba");
		data.add("ab");
		data.add("RL");
		print();
	}

	public void genMaxUniqueA(int pieceLength) throws IOException {
		char c = (char) nextInt('a', 'z');
		int m = (MAXNUM - terminator.length()) / pieceLength;
		data.add(MAXLEN + " " + (m + 1));
		String piece = "";
		for (int i = 0; i < pieceLength; i++) {
			piece += c;
		}
		for (int i = 0; i < m; i++) {
			data.add(piece);
		}
		data.add(terminator);
		String w = "";
		for (int i = 0; i < m + 1; i++) {
			if (rnd.nextBoolean()) {
				w += 'L';
			} else {
				w += 'R';
			}
		}
		data.add(w);
		print();
	}

	public void genMaxUniqueAFail(int pieceLength) throws IOException {
		char c = (char) nextInt('a', 'z');
		data.add(MAXLEN + " " + MAXNUM / pieceLength);
		String piece = "";
		for (int i = 0; i < pieceLength; i++) {
			piece += c;
		}
		for (int i = 0; i < MAXNUM / pieceLength; i++) {
			data.add(piece);
		}
		String w = "";
		for (int i = 0; i < MAXNUM / pieceLength; i++) {
			if (rnd.nextBoolean()) {
				w += 'L';
			} else {
				w += 'R';
			}
		}
		data.add(w);
		print();
	}

	Random rnd;
	String[] gray;

	public void makeGray() {
		gray = new String[20];
		gray[0] = "a";
		int pos = 0;
		char c = 'a';
		while (gray[pos].length() < MAXNUM) {
			c++;
			pos++;
			gray[pos] = gray[pos - 1] + c + gray[pos - 1];
		}
	}

	public void genFailGray() throws IOException {
		int n = gray[0].length();
		int m = 0;
		String w = "";
		int sum = n;
		for (int i = 1; gray[i] != null; i++) {
			sum += gray[i - 1].length() + 1;
			if (sum > MAXNUM) {
				break;
			}
			m++;
			if (rnd.nextBoolean()) {
				w += 'L';
				data.add(gray[i - 1] + (char) ('a' + i));
			} else {
				w += 'R';
				data.add((char) ('a' + i) + gray[i - 1]);
			}
		}
		data.add("abbba");
		data.add(terminator);
		w += 'L';
		w += 'L';
		m += 2;
		data.add(w);
		data.add(0, n + " " + m);
		print();
	}

	public void genUniqueGray(int num) throws IOException {
		int n = gray[num].length();
		int m = 0;
		String w = "";
		int sum = n;
		for (int i = num + 1; gray[i] != null; i++) {
			sum += gray[i - 1].length() + 1;
			if (sum > MAXNUM) {
				break;
			}
			m++;
			if (rnd.nextBoolean()) {
				w += 'L';
				data.add(gray[i - 1] + (char) ('a' + i));
			} else {
				w += 'R';
				data.add((char) ('a' + i) + gray[i - 1]);
			}
		}
		data.add(terminator);
		w += 'L';
		m++;
		data.add(w);
		data.add(0, n + " " + m);
		print();
	}

	public String getRandomString(int len) {
		String res = "";
		for (int i = 0; i < len; i++) {
			res += (char) (nextInt('a', 'z'));
		}
		return res;
	}

	public void genMaxRandom() throws IOException {
		int n = MAXLEN;
		int m = nextInt(1, MAXNUM);
		data.add(n + " " + m);
		int left = MAXNUM;
		String w = "";
		for (int i = 0; i < m; i++) {
			int newLen = nextInt(1, left - (m - i));
			left -= newLen;
			data.add(getRandomString(newLen));
			if (rnd.nextBoolean()) {
				w += 'L';
			} else {
				w += 'R';
			}
		}
		data.add(w);
		print();
	}

	public void genBigAmb() throws IOException {
		data.add(MAXLEN + " " + 1);
		String w = "";
		for (int i = 0; i < MAXNUM; i++) {
			w += 'a';
		}
		data.add(w);
		data.add("R");
		print();
	}

	public void run() {
		try {
			rnd = new Random(346);
			genSample1();
			genSample2();

			genEndGood();
			genSmall();
			genSmallFail();

			genMaxUniqueA(1);
			genMaxUniqueA(10);
			genMaxUniqueA(100);
			genMaxUniqueA(990);

			genMaxUniqueAFail(10);
			genMaxUniqueAFail(1000);

			genBigAmb();

			makeGray();
			for (int i = 0; gray[i].length() < MAXLEN / 2; i++) {
				genUniqueGray(i);
			}
			genFailGray();
			for (int i = 0; i < 5; i++) {
				genMaxRandom();
			}

		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
