# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # N I H A O B C D E F G J K L M P Q R S T U V W X Y Z import sys while True: try: key = input() s = input() n_key = '' #先过滤掉重复字符 for c in key: if c not in n_key: n_key += c #建立原始字母表对新字母的字典,比如A对应N dic = {} alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" alpha_f = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in range(len(n_key)): u = n_key[i].upper() dic[alpha[i]] = u alpha_f = alpha_f.replace(u,'') #其他用字母表中剩余的字母填充完整 key_len = len(n_key) for i in range(key_len, len(alpha)): dic[alpha[i]] = alpha_f[i - key_len] #判断大小写输出 res = '' for c in s: if c.isupper(): res += dic[c] else: res += dic[c.upper()].lower() print(res) except: # print(sys.exc_info()) break