from os import *
from io import *
import random

MAXN = 100000


def genMaximal(testNo):
	print(str(testNo));

	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write(str(MAXN) + "\n");
	for j in range(MAXN // 2):
		tst.write("add " + str(j+1) + "\nmum!\n");
	tst.close()

def genSample(testNo):
	print(str(testNo));
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("8\nadd 1\nadd 2\nadd 4\nadd 3\nadd 5\nadd 8\ntake\nmum!\n");
	tst.close()

def genOne(testNo, i):
	print(str(testNo));
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("1\n" + s[i] + "\n");
	tst.close()

def genTest(testNo, i):
	print(str(testNo));
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write(str(n[i]) + "\n");
	for j in range(n[i]):
		tst.write(test[i][j]);
	tst.close()

def geneasyRandom(testNo):
	print(str(testNo));
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write(str(MAXN) + "\n");
	for j in range(MAXN):
		x = random.randint(0,2);
		tst.write(st[x]);
		if (x == 0):
			tst.write(str(j+1)+"\n");		
	tst.close()

def genhardRandom(testNo):
	print(str(testNo));
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write(str(MAXN) + "\n");
	for j in range(1000):
		tst.write(st[0] + str(1000-j) + "\n");

	for j in range(MAXN-1000):
		x = random.randint(0,2);
		tst.write(st[x]);
		if (x == 0):
			tst.write(str(j+1001)+"\n");		
	tst.close()




s = ["add 1", "take", "mum!"]
st = ["add ", "take\n", "mum!\n"]
n = [5, 13]
test = [["add 1\n", "add 3\n", "add 2\n", "mum!\n", "mum!\n"]];
test += [["add 3\n", "add 2\n", "add 4\n", "mum!\n", "take\n", "mum!\n", "add 1\n", "mum!\n", "take\n", "add 10\n", "mum!\n", "mum!\n", "mum!\n"]];
random.seed(313131031);
testNo = 0
testNo = testNo + 1
genSample(testNo);
testNo = testNo + 1
genMaximal(testNo);

for j in range(3):
	testNo = testNo + 1
	genOne(testNo, j);

for j in range(2):
	testNo = testNo + 1
	genTest(testNo, j);

for j in range(9):
	testNo = testNo + 1
	geneasyRandom(testNo);

for j in range(7):
	testNo = testNo + 1
	genhardRandom(testNo);



