#include <iostream>
#include <map>

using namespace std;

string ch = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string key,str;
    while (cin>>key>>str) {
        map<char,bool> mp;
        string newkey;
        for (int i = 0; i < ch.size(); ++i) {
            mp[ch[i]] = false;
        }
        for (int i = 0; i < key.size(); ++i) {
            if (!mp[key[i]]){
                newkey += key[i];
                mp[key[i]] = true;
            }
        }
        for(auto it : mp){
            if (!it.second) {
                newkey += it.first;
            }
        }
        for (int i = 0; i < str.size(); ++i) {
            str[i] = newkey[str[i]-'a'];
        }
        cout<<str<<endl;
    }
    return 0;
}