import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
Scanner scanner
= new Scanner
(System.
in); message = scanner.nextLine();
cipher = scanner.nextLine();
char[] decoded = new char [message.length()];
for (int i = 0; i < message.length(); i++) {
if (message.charAt(i) == ' ') {
decoded[i] = ' ';
} else {
decoded[i] = cipher.charAt(findIndex(message.charAt(i)));
}
}
}
static int findIndex(char c) {
String alphabet
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < alphabet.length(); i++) {
if (c == alphabet.charAt(i))
return i;
}
return -1;
}
}
CmltcG9ydCBqYXZhLnV0aWwuKjsKaW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbiB7CgkJU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlTdHJpbmcgbWVzc2FnZSwgY2lwaGVyOwoJCW1lc3NhZ2UgPSBzY2FubmVyLm5leHRMaW5lKCk7CgkJY2lwaGVyID0gc2Nhbm5lci5uZXh0TGluZSgpOwoJCWNoYXJbXSBkZWNvZGVkID0gbmV3IGNoYXIgW21lc3NhZ2UubGVuZ3RoKCldOwogCgkJZm9yIChpbnQgaSA9IDA7IGkgPCBtZXNzYWdlLmxlbmd0aCgpOyBpKyspIHsKCQkJaWYgKG1lc3NhZ2UuY2hhckF0KGkpID09ICcgJykgewoJCQkJZGVjb2RlZFtpXSA9ICcgJzsKCQkJfSBlbHNlIHsKCQkJCWRlY29kZWRbaV0gPSBjaXBoZXIuY2hhckF0KGZpbmRJbmRleChtZXNzYWdlLmNoYXJBdChpKSkpOwoJCQl9CQkJCgkJfQoJCVN5c3RlbS5vdXQucHJpbnRsbihkZWNvZGVkKTsKCX0KCQoJc3RhdGljIGludCBmaW5kSW5kZXgoY2h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