import random

letters = "abcdefghijklmnopqrstuvwxyz"

def generateName():
	s = random.randint(6, 10)
	return ''.join([random.choice(letters) for i in xrange(s)])

names = [generateName() for i in xrange(300000)]

T = 10
print T
for i in xrange(T):
	print
	N, M = random.randint(1, 100000), random.randint(1, 100000)
	print N, M
	print ' '.join(random.choice(names) for i in xrange(N))
	print ' '.join(random.choice(names) for i in xrange(M))
