#t183. 潜伏者

潜伏者

The Spy

Problem Description

Countries RR and SS are at war, each sending spies into the other's territory to act when the chance arises.

After much hardship, spy Little CC of country RR, lurking inside country SS, has finally figured out the encoding rules of SS's military cipher:

  1. The original message that SS's military wants to send, and the encrypted message sent over the network, both consist solely of uppercase letters A–Z (no spaces or other characters).
  2. For each letter, SS defines a corresponding "cipher letter". Encryption replaces every letter in the original message with its corresponding cipher letter.
  3. Each letter corresponds to exactly one unique cipher letter, and different letters correspond to different cipher letters. A cipher letter may be the same as the original letter.

For example, if A's cipher letter is A and B's cipher letter is C (other letters and their ciphers omitted), then the original message ABA is encrypted as ACA.

Now Little CC has, through inside information, obtained one encrypted message from SS together with its corresponding original message. Little CC hopes to use this message to crack SS's military cipher. His cracking process is as follows: scan the original message; for a letter xx in the original message (representing any uppercase letter), find its corresponding uppercase letter yy in the encrypted message, and conclude that in the cipher yy is the cipher letter of xx. Continue this until the process stops in one of the following states:

  1. Scanning is complete, and at least 2525 of the letters A–Z have appeared in the original message and obtained their corresponding cipher letters, with no contradiction or error.
  2. Scanning is complete, but it is found that at least 22 letters never appeared in the original message.
  3. During scanning, an obvious contradiction or error is found in the information obtained (violating SS's cipher encoding rules). For example, if some message XYZ is translated as ABA, that violates the rule "different letters map to different cipher letters".

While Little CC is busy and dizzy, country RR's command sends another telegram asking him to translate an additional encrypted message just intercepted from SS. Now please help Little CC: use the information from the inside channel to try to crack the cipher, then use the cracked cipher to translate the encrypted message in the telegram.

Input Format

Three lines in total, each a string of length between 11 and 100100.

The first line is an encrypted message that Little CC has obtained.

The second line is the original message corresponding to the encrypted message in the first line.

The third line is the encrypted message that country RR's command asks Little CC to translate.

The input is guaranteed to consist only of uppercase letters A–Z, and the first line has the same length as the second line.

Output Format

One line in total.

If the cipher cracking stops in case 2 or case 3 above, output Failed (note the capital first letter, the rest lowercase).

Otherwise output the original message obtained by translating the encrypted message in the telegram using the cipher.

Sample Input 1

AA
AB
EOWIE

Sample Output 1

Failed

Sample Input 2

QWERTYUIOPLKJHGFDSAZXCVBN
ABCDEFGHIJKLMNOPQRSTUVWXY
DSLIEWO

Sample Output 2

Failed

Sample Input 3

MSRTZCJKPFLQYVAWBINXUEDGHOOILSMIJFRCOPPQCEUNYDUMPP
YIZSDWAHLNOVFUCERKJXQMGTBPPKOIYKANZWPLLVWMQJFGQYLL
FLSO

Sample Output 3

NOIP

Hint

Sample 1 explanation: the letters A and B in the original message correspond to the same cipher letter, so output Failed.

Sample 2 explanation: only the letter Z never appeared in the original message, so output Failed.

Constraints

Each input string has length between 11 and 100100, and consists only of uppercase letters A–Z.