from os import *
from io import *
import random

def translit(test, kol):
	ans = ""
	for i in range(kol):
		if (test[i] == 1):
			ans += 'a'
		if (test[i] == 2):
			ans += 'b'
		if (test[i] == 3):
			ans += 'v'
		if (test[i] == 4):
			ans += 'g'
		if (test[i] == 5):
			ans += 'd'

		if (test[i] == 6):
			ans += 'e'
		if (test[i] == 7):
			ans += 'yo'
		if (test[i] == 8):
			ans += 'zh'
		if (test[i] == 9):
			ans += 'z'
		if (test[i] == 10):
			ans += 'i'

		if (test[i] == 11):
			ans += 'j'
		if (test[i] == 12):
			ans += 'k'
		if (test[i] == 13):
			ans += 'l'
		if (test[i] == 14):
			ans += 'm'
		if (test[i] == 15):
			ans += 'n'

		if (test[i] == 16):
			ans += 'o'
		if (test[i] == 17):
			ans += 'p'
		if (test[i] == 18):
			ans += 'r'
		if (test[i] == 19):
			ans += 's'
		if (test[i] == 20):
			ans += 't'

		if (test[i] == 21):
			ans += 'u'
		if (test[i] == 22):
			ans += 'f'
		if (test[i] == 23):
			ans += 'kh'
		if (test[i] == 24):
			ans += 'tc'
		if (test[i] == 25):
			ans += 'tch'

		if (test[i] == 26):
			ans += 'sch'
		if (test[i] == 27):
			ans += 'scsh'
		if (test[i] == 28):
			ans += 'yy'
		if (test[i] == 29):
			ans += 'ye'
		if (test[i] == 30):
			ans += 'yu'

		if (test[i] == 31):
			ans += 'ya'
	return ans
		

def printTest(testNo, test):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write(str(m) + " " + str(n) + "\n");
	tst.close()

#sample
def printSample(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("6\n")
	tst.write("yolka\n")
	tst.write("jeti\n")
	tst.write("yabloko\n")
	tst.write("segodnya\n")
	tst.write("schtab\n")
	tst.write("kaktus\n")
	tst.close()

def test2(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("31\n");
	for i in range(31):
		tst.write(translit([31 - i], 1) + "\n")
	tst.close()

def test3(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("2\n");
	test = []
	for i in range(31):
		test += [i + 1]
	tst.write(translit(test, 31) + "\n");
	tst.write(translit([29], 1) + "\n");
	tst.close();

def test4(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("2\n");
	test = []
	for i in range(31):
		test += [31 - i]
	tst.write(translit(test, 31) + "\n");
	tst.write(translit([31, 9], 2) + "\n");
	tst.close();

def test5(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("2\n");
	tst.write(translit([31], 1) + "\n");
	tst.write(translit([30], 1) + "\n");
	tst.close();

def test6(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("31\n");
	for i in range(31):
		test = []
		for j in range(31 - i):
			test += [j + i + 1]
		for j in range(i):
			test += [j + 1]
		tst.write(translit(test, 31) + "\n");
	tst.close();

def test7(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("31\n");
	for i in range(31):
		test = []
		for j in range(31 - i):
			test += [31 - (j + i)]
		for j in range(i):
			test += [31 - j]
		tst.write(translit(test, 31) + "\n");
	tst.close();

def test8(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("961\n");
	for i in range(31):
		for j in range(31):
			tst.write(translit([i + 1, j + 1], 2) + "\n");
	tst.close();

def test9(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("961\n");
	for i in range(31):
		for j in range(31):
			tst.write(translit([31 - i, 31 - j], 2) + "\n");
	tst.close();


def testrand(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("1000\n");
	for i in range(1000):
		test = [];
		for j in range(12):
			test += [random.randint(1, 31)]
		tst.write(translit(test, 12) + "\n");
	tst.close();
                                                       
def testrandhard1(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("1000\n");
	for i in range(1000):
		test = [];
		for j in range(25):
			test += [random.choice([23, 8, 9, 12])]
		tst.write(translit(test, 12) + "\n");
	tst.close();

def testrandhard2(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("1000\n");
	for i in range(1000):
		test = [];
		for j in range(25):
			test += [random.choice([7, 31, 30, 29, 28, 1, 21, 6, 16])]
		tst.write(translit(test, 12) + "\n");
	tst.close();

def testrandhard3(testNo):
	if not (path.exists("../tests")):
		mkdir("../tests")
	tst = open("../tests/%d%d" % divmod(testNo, 10), "w")
	tst.write("1000\n");
	for i in range(1000):
		test = [];
		for j in range(12):
			test += [random.choice([27, 26, 25, 24, 20, 19])]
		tst.write(translit(test, 12) + "\n");
	tst.close();


testNo = 1

printSample(testNo);

testNo += 1
test2(testNo)
testNo += 1
test3(testNo)
testNo += 1
test4(testNo)
testNo += 1
test5(testNo)
testNo += 1
test6(testNo)
testNo += 1
test7(testNo)
testNo += 1
test8(testNo)
testNo += 1
test9(testNo)
random.seed(313110);#313110
for i in range(21):
	testNo += 1
	testrand(testNo)
for i in range(10):
	testNo += 1
	testrandhard1(testNo)
for i in range(10):
	testNo += 1
	testrandhard2(testNo)
for i in range(10):
	testNo += 1
	testrandhard3(testNo)

