from string import ascii_lowercase used = set() while True: typ = input() if len(typ) == 1: reply = typ + typ print(reply) used.add(letter) else: r, w = typ.split() if r == '!': exit() else: a, b = list(w) used.add(a) used.add(b) flag = False for c in ascii_lowercase: if c not in used: reply = b + c print(reply) used.add(c) Flag = True break if not(flag): print(b + 'a')