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

public class TestGen {

    static int done = 0;

    static final Random rand = new Random(556668949239L);

    static final int MAXN = 100;
    static final int MAXK = 100;

    static final String[] command = { "shoot", "save", "load", "ammo" };

    static List<String> data = new ArrayList<String>();

    static void print(int k) throws IOException {
	done++;
	System.err.println(done);
	PrintWriter out;
	if (done < 10)
	    out = new PrintWriter("../tests/0" + String.valueOf(done));
	else
	    out = new PrintWriter("../tests/" + String.valueOf(done));
	out.println(data.size() + " " + k);
	for (int i = 0; i < data.size(); i++) {
	    out.println(data.get(i));
	}
	data = new ArrayList<>();
	out.close();
    }

    static int randFromTo(int from, int to) {
	return rand.nextInt(to - from + 1) + from;
    }

    static void genSimple() throws IOException {
	PrintWriter out;
	out = new PrintWriter("../preliminary/01");
	data = Arrays.asList("ammo", "save", "shoot", "ammo", "load", "shoot",
		"load");
	out.println(data.size() + " " + 3);
	for (int i = 0; i < data.size(); i++) {
	    out.println(data.get(i));
	}
	data = new ArrayList<>();
	out.close();
    }

    public static void main(String[] args) throws IOException {
	boolean f = (new File("../preliminary")).mkdir();
	f = new File("../tests").mkdir();

	genSimple();

	done = 0;

	// Not Save and Load

	for (int i = 0; i < 11; i++) {
	    data.add(command[3]);
	}
	print(3);

	for (int i = 0; i < 22; i++) {
	    data.add(command[3]);
	    data.add(command[0]);
	}
	print(1);

	for (int i = 0; i < 99; i++) {
	    data.add(command[3]);
	}
	print(100);

	data.add(command[3]);
	for (int i = 0; i < 99; i++) {
	    data.add(command[0]);
	}
	print(99);

	for (int i = 0; i < 11; i++) {
	    data.add(command[3]);
	    for (int j = 0; j < 8; j++) {
		data.add(command[0]);
	    }
	}
	print(9);

	for (int i = 0; i < 11; i++) {
	    data.add(command[3]);
	    for (int j = 0; j < 8; j++) {
		data.add(command[0]);
	    }
	}
	print(8);

	for (int i = 0; i < 4; i++) {
	    data.add(command[3]);
	    int t = randFromTo(MAXN / 2, MAXN - 1);
	    for (int j = 0; j < t; j++) {
		if (rand.nextBoolean()) {
		    data.add(command[0]);
		} else {
		    data.add(command[3]);
		}
	    }
	    print(randFromTo(4, MAXK));
	}

	// Save and Load
	data.add(command[3]);
	data.add(command[1]);
	for (int i = 0; i < 42; i++) {
	    int t = rand.nextInt(15);
	    if (t == 0) {
		data.add(command[0]);
	    }
	    if (t % 2 == 0) {
		data.add(command[1]);
	    } else

	    {
		data.add(command[2]);
	    }
	}
	print(3);

	data.add(command[3]);
	data.add(command[1]);
	for (int i = 0; i < 77; i++) {
	    int t = rand.nextInt(6);
	    if (t == 0) {
		data.add(command[0]);
	    }
	    if (t % 2 == 0) {
		data.add(command[1]);
	    } else

	    {
		data.add(command[2]);
	    }
	}
	print(15);

	for (int i = 0; i < 10; i++) {
	    data.add(command[2 + rand.nextInt(2)]);
	}
	print(4);

	data.add(command[3]);
	if (rand.nextBoolean())
	    data.add(command[0]);
	data.add(command[1]);
	int t = randFromTo(MAXN / 2, MAXN - 3);
	for (int j = 0; j < t; j++) {
	    int tt = rand.nextInt(3);
	    if (tt == 0)
		data.add(command[0]);
	    if (tt == 1)
		data.add(command[2]);
	    if (tt == 2)
		data.add(command[3]);
	}
	print(randFromTo(7, MAXK));

	for (int i = 0; i < 3; i++) {
	    data.add(command[3]);
	    if (rand.nextBoolean())
		data.add(command[0]);
	    data.add(command[1]);
	    t = randFromTo(MAXN / 2, MAXN - 3);
	    for (int j = 0; j < t; j++) {
		data.add(command[rand.nextInt(4)]);
	    }
	    print(randFromTo(7, MAXK));
	}
	for (int i = 0; i < 2; i++) {
	    data.add(command[3]);
	    if (rand.nextBoolean())
		data.add(command[0]);
	    data.add(command[1]);
	    t = randFromTo(MAXN / 2, MAXN - 3);
	    for (int j = 0; j < t; j++) {
		int ver = rand.nextInt(1000);
		if (ver < 50)
		    data.add(command[1]);
		if (ver >= 50 && ver < 150)
		    data.add(command[2]);
		if (ver >= 150 && ver < 250)
		    data.add(command[3]);
		if (ver >= 250)
		    data.add(command[0]);
	    }
	    print(randFromTo(10, 17));
	}
	data.add(command[3]);
	if (rand.nextBoolean())
	    data.add(command[0]);
	data.add(command[1]);
	t = randFromTo(MAXN / 2, MAXN - 3);
	for (int j = 0; j < t; j++) {
	    int ver = rand.nextInt(1000);
	    if (ver < 25)
		data.add(command[1]);
	    if (ver >= 25 && ver < 100)
		data.add(command[2]);
	    if (ver >= 100 && ver < 150)
		data.add(command[3]);
	    if (ver >= 150)
		data.add(command[0]);
	}
	print(42);
	return;
    }
}
