#include <iostream>
#include <cstring>
using namespace std;
int find(const char* str, char c) {
for(int i = 0; str[i] != '\0'; i++) {
if(str[i] == c) {
return i;
}
}
return -1;
}
int main() {
int n = 27, k = 20000;
const char *a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char b[k];
char c[n];
cin.getline(b, k);
cin.getline(c, n);
for(int i = 0; b[i] != '\0'; i++) {
int index = find(a, b[i]);
if(index != -1) {
cout << c[index];
} else {
cout << b[i];
}
}
return 0;
}
ICAgICNpbmNsdWRlIDxpb3N0cmVhbT4KICAgICNpbmNsdWRlIDxjc3RyaW5nPgogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKICAgICAKICAgIGludCBmaW5kKGNvbnN0IGNoYXIqIHN0ciwgY2hhciBjKSB7CiAgICAJZm9yKGludCBpID0gMDsgc3RyW2ldICE9ICdcMCc7IGkrKykgewogICAgCQlpZihzdHJbaV0gPT0gYykgewogICAgCQkJcmV0dXJuIGk7CiAgICAJCX0KICAgIAl9CiAgICAJcmV0dXJuIC0xOwogICAgfQogICAgIAogICAgaW50IG1haW4oKSB7CiAgICAJaW50IG4gPSAyNywgayA9IDIwMDAwOwogICAgCWNvbnN0IGNoYXIgKmEgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoiOwogICAgCWNoYXIgYltrXTsKICAgIAljaGFyIGNbbl07CiAgICAJY2luLmdldGxpbmUoYiwgayk7CiAgICAJY2luLmdldGxpbmUoYywgbik7CiAgICAJZm9yKGludCBpID0gMDsgYltpXSAhPSAnXDAnOyBpKyspIHsKICAgIAkJaW50IGluZGV4ID0gZmluZChhLCBiW2ldKTsKICAgIAkJaWYoaW5kZXggIT0gLTEpIHsKICAgIAkJCWNvdXQgPDwgY1tpbmRleF07CiAgICAJCX0gZWxzZSB7CiAgICAJCQljb3V0IDw8IGJbaV07CiAgICAJCX0KICAgIAl9CiAgICAJcmV0dXJuIDA7CiAgICB9