#!/usr/bin/env python3
from random import randint, seed

seed(13423546161)

def solve(x, y):
  x = ''.join(sorted(x))
  y = ''.join(sorted(y))
  res = y.split()
  i = 0
  for c in x:
    while i < len(y) and y[i] < c:
      i += 1
    if i < len(y) and y[i] == c:
      i += 1
    else:
      res += [c]
  return ''.join(sorted(res))

def gen(l):
  return ''.join(map(lambda x: chr(ord('a') + randint(0, 25)), range(l)))

def create_case(tcn, an, bn):
  print('Generate {:02d}...'.format(tcn))
  a = gen(an)
  b = gen(bn)
  c = solve(a,b)
  assert(len(c) > 0)
  with open("data/secret/{:02d}.in".format(tcn), "w") as f:
    print(a, file=f)
    print(b, file=f)
  with open("data/secret/{:02d}.ans".format(tcn), "w") as f:
    print(c, file=f)

if __name__ == '__main__':
  create_case(5, 4, 10**5)
  create_case(6, 10**5, 4)
  create_case(7, 10**6, 10**6)
