#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define debug(x) cout<< #x << " --> " << x << "\n";
#define NL printf("\n");
#define case(x) printf("Case %lld: ",x);
#define readI(x) scanf("%d",&x);
#define readL(X) scanf("%lld",&x);
#define writeI(x) printf("%d",x);
#define writeL(X) printf("%lld",x);
#define all(v) v.begin(),v.end()

#define ll long long
#define ld long double
#define pb push_back
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector< int >
#define vll vector< ll >
#define vss vector< string >
#define vdd vector< double >
#define vpi vector< pii >
#define vpl vector< pll >
#define vvi vector< vii >
#define vvl vector< vll >
#define PQ priority_queue
#define ff first
#define ss second
#define MX 2000005
#define mod 1000000007
#define INF 10000000000000000
#define EPS 1e-12

/* Special functions:
		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
ll,					// type long long
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

struct compare
{
    bool operator() (ll a, ll b)
    {
        return a>b;
    }
};

const ll p1=131,p2=137;
const ll mod1=1000000009;
const ll mod2=1000000007;

bool marked[MX];
vll primes;

ll bigMod(ll x, ll n)
{
    if(!n)
        return 1LL;
    ll temp=bigMod(x,n/2);
    temp=(temp*temp)%mod;
    if(n%2)
        temp=(temp*x)%mod;
    return temp;
}

void sieve()
{
    marked[0]=marked[1]=true;
    for(ll i=2; i*i<MX; i++)
    {
        if(marked[i]==false)
        {
            for(ll j=i*i; j<MX; j+=i)
            {
                marked[j]=true;
            }
        }
    }

    for(ll i=2; i<MX; i++)
        if(!marked[i])
        {
            primes.push_back(i);
        }
}

vpl primeFactors(ll N)
{
    vpl factors;
    ll pf_id=0,pf=primes[pf_id];
    while(pf*pf<=N)
    {
        ll cnt=0;
        while(N%pf==0) N/=pf,cnt++;
        if(cnt) factors.push_back({pf,cnt});

        pf=primes[++pf_id];
    }

    if(N!=1) factors.push_back({N,1});
    return factors;
}

/**---------End of Template---------**/

int main()
{

    FIO;
//    IN;
//    OUT;

    sieve();

    ll x=0,y=0;
    ll n;
    cin>> n;
    for(ll i=0; i<n; i++)
    {
        ll a;
        cin>> a;
        if(a==1) x++;
        else y++;
    }

    vll res1,res2;
    ll cnt1=0,cnt2=0;
    ll tempx=x,tempy=y;

    ll cur=0;
    for(auto it:primes)
    {
        if(!x and !y)
            break;
        ll a=it-cur;
        if(a/2<=y)
        {
            for(ll i=0; i<a/2; i++)
                res1.push_back(2),cur+=2;
            y-=a/2;
            a-=(a/2)*2;
        }
        for(ll i=0; i<min(a,x); i++)
            res1.push_back(1),cur++;
        x-=min(a,x);
        if(cur==it)
            cnt1++;
    }

    x=tempx,y=tempy;
    if(x)
    {
        x--,cur=1;
        res2.push_back(1);
        for(auto it:primes)
        {
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=2)
    {
        x-=2,cur=2;
        cnt2=1;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    x=tempx,y=tempy;
    if(x>=3)
    {
        x-=3,cur=3;
        cnt2=2;
        res2.clear();
        res2.push_back(1);
        res2.push_back(1);
        res2.push_back(1);
        for(auto it:primes)
        {
            if(it==2 or it==3)
                continue;
            if(!x and !y)
                break;
            ll a=it-cur;
            if(a/2<=y)
            {
                for(ll i=0; i<a/2; i++)
                    res2.push_back(2),cur+=2;
                y-=a/2;
                a-=(a/2)*2;
            }
            for(ll i=0; i<min(a,x); i++)
                res2.push_back(1),cur++;
            x-=min(a,x);
            if(cur==it)
                cnt2++;
        }
    }

    if(cnt1<=cnt2)
        res1=res2,cnt1=cnt2;

    for(auto p:res1) cout<< p << " ";
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int t[3];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int k;
		scanf("%d", &k);
		++t[k];
	}
	if (t[1] > 0 && t[2] > 0)
	{
		cout << 2;
		cout << " " << 1;
		for (int i = 1; i < t[2]; ++i)
		{
			cout << " " << 2;
		}
		for (int i = 1; i < t[1]; ++i)
		{
			cout << " " << 1;
		}
		cout << endl;
	}
	else if (t[1] == 0)
	{
		cout << 2;
		for (int i = 1; i < t[2]; ++i)
		{
			cout << " " << 2;
		}
		cout << endl;
	}
	else if (t[2] == 0)
	{
		cout << 1;
		for (int i = 1; i < t[1]; ++i)
		{
			cout << " " << 1;
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<500000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 500000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 500000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 500000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else{
                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<500000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 500000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 500000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 500000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2<=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else{
                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<500000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 500000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 500000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }
    primes.push_back(1);
    primes.push_back(2);
    for (int i = 3; i < 500000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else if(x>=one){
                        sum+=x, one-=x;
                        for0(i,x) cout<<"1 ";
                    }
                    else{

                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        int n; cin>>n;
        int one=0, two=0;
        for0(i,n) {
            int x; cin>>x;
            x==2 ? two++: one++;
        }
        if(one and two) one--, two--, cout<<"2 1 ";
        for0(i,two) cout<<"2 ";
        for0(i,one) cout<<"1 ";
    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<500000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 500000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 500000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 500000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else if(x>=one){
                        sum+=x, one-=x;
                        for0(i,x) cout<<"1 ";
                    }
                    else{

                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<500000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 500000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 500000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 500000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else if(x>=one){
                        sum+=x, one-=x;
                        for0(i,x) cout<<"1 ";
                    }
                    else{
                        for0(i,one) cout<<"1 ";
                        for0(i,two) cout<<"2 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<400000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 400000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 400000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 400000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n; cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }
        int sum=0;
        for(auto t: primes){
            if(!one and !two) goto jump;
            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }
            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }
            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else if(t-sum==2 and one>=2) sum+=2, one-=2, cout<<"1 1 ";
            else{
                int x = t-sum;
                if(jor(x)){
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else if(x>=one){
                        sum+=x, one-=x;
                        for0(i,x) cout<<"1 ";
                    }
                    else{
                        for0(i,one) cout<<"1 ";
                        for0(i,two) cout<<"2 ";
                        goto jump;
                    }
                }
            }
        }
        jump:
        int sasfd=0;
    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<400000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 400000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 400000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 400000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) break;

            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }

            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }

            //if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            //else
            if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else{
                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

vector<int> primes;

void sieve() {
    bitset<400000> isPrime;
    isPrime.set();

    for (int i = 3; i * i <= 400000; i += 2) {
        if (isPrime[i]) {
            for (int j = i * i; j <= 400000; j += 2*i) {
                isPrime[j] = false;
            }
        }
    }

    primes.push_back(2);
    for (int i = 3; i < 400000; i += 2) {
        if (isPrime[i]) primes.push_back(i);
    }
}

int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        sieve();
        int n;
        cin>>n;
        int a[n];
        int one=0, two=0;
        for0(i,n) {
            cin>>a[i];
            a[i]==2 ? two++: one++;
        }

        int sum=0;
        for(auto t: primes){
            if(!one and !two) break;

            if(!one){
                for0(i,two) cout<<"2 ";
                break;
            }

            if(!two){
                for0(i,one) cout<<"1 ";
                break;
            }

            if(t-sum==1 and one) sum+=1,  one--, cout<<"1 ";
            else if(t-sum==2 and two) sum+=2, two--, cout<<"2 ";
            else{
                int x = t-sum;
                    //--------------------------------------
                    if(x/2>=two) {
                        sum+=x, two-=x/2;
                        for0(i,x/2) cout<<"2 ";
                    }
                    else{
                        for0(i,two) cout<<"2 ";
                        for0(i,one) cout<<"1 ";
                        goto jump;
                    }
                    //--------------------------------------
            }
        }
        jump:
        int sasfd=0;

    }
}


import java.util.*;

public class Code{
    public static void main(String args[]){
        Scanner r=new Scanner(System.in);
	String s1 = r.next();
        String s2 = r.next();
	String s = r.next();

	HashMap<Character,Character> t = new HashMap<Character,Character>();
	for(int i=0;i<26;i++)
		t.put(s1.charAt(i),s2.charAt(i));

	for(int i=0;i<s.length();i++){
		char c = s.charAt(i);
		if(c>='0'&&c<='9')
			System.out.print(c);
		else if(c>=65&&c<=90){
				c=Character.toLowerCase(c);
			System.out.print(Character.toUpperCase(t.get(c)));}
		else
			System.out.print(t.get(c));

		}
	}
}


import java.util.*;

public class Code{
    public static void main(String args[]){
        Scanner r=new Scanner(System.in);
	String s1 = r.next();
        String s2 = r.next();
	String s = r.next();

	HashMap<Character,Character> t = new HashMap<Character,Character>();
	for(int i=0;i<26;i++)
		t.put(s1.charAt(i),s2.charAt(i));

	for(int i=0;i<s.length();i++){
		if(s.charAt(i)>=97&&s.CharAt(i)<=122)
			System.out.println(t.get(s.charAt(i));
		else if(s.charAt(i)>=65&&s.CharAt(i)<=90)
			System.out.println(t.get(s.charAt(i)).toUpperCase());
		else
			System.out.println(s.charAt(i));

		}
	}
}


package problem831;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		/*
		*qwertyuiopasdfghjklzxcvbnm
		*veamhjsgqocnrbfxdtwkylupzi
		*TwccpQZAvb2017				//Size and symbols if not in keyb1
		*HelloVKCup2017
		 */
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String keybOne = in.nextLine();
		String keybTwo = in.nextLine();
		String textIn = in.nextLine();
		String textOut = "";

		//System.out.println("hello aaa".indexOf("a"));

		for (int i = 0; i < textIn.length(); i++) {
			int symbol =  keybOne.toLowerCase().indexOf(textIn.toLowerCase().charAt(i));
			if(symbol == -1) {
				textOut += textIn.charAt(i);
			} else {
				if(Character.isLowerCase(textIn.charAt(i))){
					textOut += keybTwo.toLowerCase().charAt(symbol);
				} else {
					textOut += keybTwo.toUpperCase().charAt(symbol);
				}
			}

		}

		System.out.println(textOut);

	}

}


//package problem831;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		String keybOne = in.nextLine();
		String keybTwo = in.nextLine();
		String textIn = in.nextLine();
		String textOut = "";

		for (int i = 0; i < textIn.length(); i++) {
			int symbol =  keybOne.toLowerCase().indexOf(textIn.toLowerCase().charAt(i));
			if(symbol == -1) {
				textOut += textIn.charAt(i);
			} else {
				if(Character.isLowerCase(textIn.charAt(i))){
					textOut += keybTwo.toLowerCase().charAt(symbol);
				} else {
					textOut += keybTwo.toUpperCase().charAt(symbol);
				}
			}

		}

		System.out.println(textOut);

	}

}


import java.io.*;
import java.util.*;
public class KEYBOARD {
	public static void main(String args[])
	throws IOException
	{
		Reader.init(System.in);
		HashMap <Character,Character> map= new HashMap<Character,Character>();
		String s1=Reader.next();
		String s2=Reader.next();
		for(int i=0;i<26;i++)
		{
			map.put(s1.charAt(i), s2.charAt(i));
		}
		String s=Reader.next();
		char ch[]=new char[s.length()];
		for(int i=0;i<s.length();i++)
		{
			if(Character.isDigit(s.charAt(i)))
				ch[i]=s.charAt(i);
			else if(Character.isUpperCase(s.charAt(i)))
				ch[i]=Character.toUpperCase(map.get(Character.toLowerCase(s.charAt(i))));
			else
				ch[i]=map.get(s.charAt(i));

		}
		for(int i=0;i<s.length();i++)
		{
			System.out.print(ch[i]);
		}
	}

}


import java.io.*;
import java.util.*;
public class KEYBOARD {
	public static void main(String args[])
	throws IOException
	{
		Reader.init(System.in);
		HashMap <Character,Character> map= new HashMap<Character,Character>();
		String s1=Reader.next();
		String s2=Reader.next();
		for(int i=0;i<26;i++)
		{
			map.put(s1.charAt(i), s2.charAt(i));
		}
		String s=Reader.next();
		char ch[]=new char[s.length()];
		for(int i=0;i<s.length();i++)
		{
			if(Character.isDigit(s.charAt(i)))
				ch[i]=s.charAt(i);
			else if(Character.isUpperCase(s.charAt(i)))
				ch[i]=Character.toUpperCase(map.get(Character.toLowerCase(s.charAt(i))));
			else
				ch[i]=map.get(s.charAt(i));

		}
		for(int i=0;i<s.length();i++)
		{
			System.out.print(ch[i]);
		}
	}

}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class _459B {

	private static Scanner s;

	public static void main(String[] args) {
		s = new Scanner(System.in);
		long n = s.nextLong() ;
		long pairs[] = new long[(int) n];
		for (int i = 0; i < n ; i++) {
			pairs[i] = s.nextLong();
		}
		Arrays.sort(pairs);
		if (pairs[0] == pairs[(int) (n - 1)]) {
			System.out.println(0 + " " + (n*(n-1)) / 2);
			System.exit(0);
		}
		long startCount = 1, endCount = 1;
		for (int i = 1; i < n; i++) {
			if (pairs[0] == pairs[i])
				startCount++;
		}
		for (int i = (int) (n - 2); i > -1; i--) {
			if (pairs[(int) (n - 1)] == pairs[i])
				endCount++;
		}
		System.out.println(pairs[(int) (n - 1)] - pairs[0] + " " + endCount * startCount);
	}
}


import java.util.HashMap;
import java.util.Scanner;

public class _831B {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		HashMap<Character, Character> compare = new HashMap<Character, Character>();
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		for (int i = 0; i < str1.length(); i++) {
			compare.put(str1.charAt(i), str2.charAt(i));
			compare.put((char)(str1.charAt(i) - 32), (char)(str2.charAt(i) - 32));
		}
		String str3 = s.nextLine();
		for(int i = 0; i < str3.length();i++) {
			if(Character.isDigit(str3.charAt(i)))
				System.out.print(str3.charAt(i));
			else
				System.out.print(compare.get(str3.charAt(i)));
		}

	}
}


import java.util.*;
public class pairs
{

    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        String a = s.next();
        String b = s.next();
        HashMap<Character,Character> map = new HashMap<>();
        for(int i=0;i<a.length();i++)
        {
            map.put(a.charAt(i),b.charAt(i));
            map.put(Character.toUpperCase(a.charAt(i)),Character.toUpperCase(b.charAt(i)));
        }

        char[] c = s.next().toCharArray();
        for(int i=0;i<c.length;i++)
        {
            if(c[i]>=65 &&c[i]<=90 || c[i]>=97 && c[i]<=122)
            {
                System.out.print(map.get(c[i]));
            }
           else System.out.print(c[i]);
        }

        System.out.println();

    }

}


import java.util.*;
public class pairs
{

    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        String a = s.next();
        String b = s.next();
        HashMap<Character,Character> map = new HashMap<>();
        for(int i=0;i<a.length();i++)
        {
            map.put(a.charAt(i),b.charAt(i));
            map.put(Character.toUpperCase(a.charAt(i)),Character.toUpperCase(b.charAt(i)));
        }

        char[] c = s.next().toCharArray();
        for(int i=0;i<c.length;i++)
        {
            if(c[i]>=65 &&c[i]<=90 || c[i]>=97 && c[i]<=122)
            {
                System.out.print(map.get(c[i]));
            }
        }

        System.out.println();

    }

}


import java.util.*;

public class Keyboardlayout {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		HashMap<Character,Character> map = new HashMap<Character,Character>();
		String s = input.next();
		String t = input.next();
		for(int i=0;i<s.length();i++){
			map.put(s.charAt(i),t.charAt(i));
		}
		String z = input.next();
		String p = "";
		for(int i=0;i<z.length();i++){
		  if(Character.isLetter(z.charAt(i))){
			  if(z.charAt(i)>='a' && z.charAt(i)<='z'){
				  p+=map.get(z.charAt(i));
			  }
			  else{
				  char temp = (char)(z.charAt(i)+32);
				  p+=(char)(map.get(temp)-32);

			  }
		  }
		  else
			  p+=z.charAt(i);
		}

		System.out.println(p);
	}

}


import java.io.*;
import java.util.*;

public class KeyboardLayouts
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

            String lo1, lo2, tinlo1, tinlo2; //layout1, layout2, text in layout1, text in layout2
            lo1 = st.nextToken();
            st = new StringTokenizer(br.readLine());
            lo2 = st.nextToken();
            st = new StringTokenizer(br.readLine());
            tinlo1 = st.nextToken();
            tinlo2 = "";
	      for(int i=0; i<tinlo1.length(); i++)
		{
                  if(lo1.indexOf(Character.toLowerCase(tinlo1.charAt(i))) != -1 && Character.isLowerCase(tinlo1.charAt(i)) == false)
                  {
                        char c = Character.toLowerCase(tinlo1.charAt(i));
                        tinlo2 += Character.toUpperCase(lo2.charAt(lo1.indexOf(c)));
                  }
                  else if(lo1.indexOf(tinlo1.charAt(i)) == -1)
                        tinlo2 += tinlo1.charAt(i);
                  else
                        tinlo2 += lo2.charAt(lo1.indexOf(tinlo1.charAt(i)));
		}
		System.out.println(tinlo2);
	}
}


import java.io.*;
import java.util.*;

public class KeyboardLayouts
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

            String lo1, lo2, tinlo1, tinlo2; //layout1, layout2, text in layout1, text in layout2
            lo1 = st.nextToken();
            st = new StringTokenizer(br.readLine());
            lo2 = st.nextToken();
            st = new StringTokenizer(br.readLine());
            tinlo1 = st.nextToken();
            tinlo2 = "";
	      for(int i=0; i<tinlo1.length(); i++)
		{
                  if(lo1.indexOf(Character.toLowerCase(tinlo1.charAt(i))) != -1 && Character.isLowerCase(tinlo1.charAt(i)) == false)
                  {
                        char c = Character.toLowerCase(tinlo1.charAt(i));
                        System.out.println(c);
                        tinlo2 += Character.toUpperCase(lo2.charAt(lo1.indexOf(c)));
                  }
                  else if(lo1.indexOf(tinlo1.charAt(i)) == -1)
                        tinlo2 += tinlo1.charAt(i);
                  else
                        tinlo2 += lo2.charAt(lo1.indexOf(tinlo1.charAt(i)));
		}
		System.out.println(tinlo2);
	}
}


import java.util.Scanner;
import java.util.*;

public class Prob2 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		String str = s.nextLine();
		StringBuilder newstr = new StringBuilder();

		for (int i = 0; i < str.length(); i++) {
			try {
				if(Character.isUpperCase(str.charAt(i))) {
				newstr.append(Character.toUpperCase(str2.charAt(str1.indexOf(Character.toLowerCase(str.charAt(i))))));
				}else {
				newstr.append(str2.charAt(str1.indexOf(str.charAt(i))));
				}
			} catch (Exception e) {
				newstr.append(str.charAt(i));
			}

		}
		System.out.println(newstr.toString());
	}

}


import java.util.Scanner;
import java.util.*;

public class Prob2 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		String str = s.nextLine();
		StringBuilder newstr = new StringBuilder();

		for (int i = 0; i < str.length(); i++) {
			try {
				newstr.append(str2.charAt(str1.indexOf(str.charAt(i))));

			} catch (Exception e) {
				newstr.append(str.charAt(i));
			}

		}

	}

}


import java.util.Scanner;
import java.util.*;

public class Prob2 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str1 = s.nextLine();
		String str2 = s.nextLine();
		String str = s.nextLine();
		StringBuilder newstr = new StringBuilder();

		for (int i = 0; i < str.length(); i++) {
			try {

				newstr.append(str2.charAt(str1.indexOf(Character.toLowerCase(str.charAt(i)))));

			} catch (Exception e) {
				newstr.append(str.charAt(i));
			}

		}
		System.out.println(newstr.toString());
	}

}


import java.util.Scanner;

public class secondP {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s = new Scanner(System.in);

		String s1 = s.nextLine();
		String s2 = s.nextLine();
		String answer = s.nextLine();
		String ans = "";

		int index = 0;
		int temp = 0;

		while(index < answer.length()){

			char c = Character.toLowerCase(answer.charAt(index));
			temp = s1.indexOf(c);

			if(Character.isUpperCase(answer.charAt(index))) {
				ans += Character.toUpperCase(s2.charAt(temp));
			}
			else if(Character.isLowerCase(answer.charAt(index))) {
				ans += s2.charAt(temp);
			}
			else {
				ans += answer.charAt(index);
			}
			index++;
		}

		System.out.println(ans);

	}

}


import java.util.Scanner;

public class secondP {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s = new Scanner(System.in);

		String s1 = s.nextLine();
		String s2 = s.nextLine();
		String answer = s.nextLine();
		String ans = "";
		s.close();
		int index = 0;
		int temp = 0;

		while(index < answer.length()){

			char c = Character.toLowerCase(answer.charAt(index));
			temp = s1.indexOf(c);

			if(Character.isUpperCase(answer.charAt(index))) {
				ans += Character.toUpperCase(s2.charAt(temp));
			}
			else if(Character.isLowerCase(answer.charAt(index))) {
				ans += s2.charAt(temp);
			}
			else {
				ans += answer.charAt(index);
			}
			index++;
		}

		System.out.println(ans);

	}

}


import java.util.Scanner;

public class secondP {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s = new Scanner(System.in);

		String s1 = s.nextLine();
		String s2 = s.nextLine();
		String answer =  s.nextLine();
		String ans = "";

		int index = 0;
		int temp = 0;

		while(index < answer.length()){

			char c = Character.toLowerCase(answer.charAt(index));
			temp = s1.indexOf(c);

			if(Character.isUpperCase(answer.charAt(index))) {
				ans += Character.toUpperCase(s2.charAt(temp));
			}
			else if(Character.isLowerCase(answer.charAt(index))) {
				ans += s2.charAt(temp);
			}
			else {
				ans += answer.charAt(index);
			}
			index++;
		}

		System.out.println(ans);

	}

}


public class KeyboardLayouts {
    public static void main(String args[]){
        Scanner S=new Scanner(System.in);
        String l1=S.next();
        String l2=S.next();
        String check=S.next();
        String s2="";
        for(int i=0;i<check.length();i++){
            char s1=Character.toLowerCase(check.charAt(i));
            if(Character.isDigit(check.charAt(i)))
                s2+=check.charAt(i);
            for(int j=0;j<l1.length();j++){
                if(l1.charAt(j)==s1){
                    if(l1.charAt(j)==l2.charAt(j)){
                       s2+=check.charAt(i);
                    }
                    else
                    {
                        if(Character.isUpperCase(check.charAt(i))){
                            s2+=Character.toUpperCase(l2.charAt(j));
                        }
                        else
                            s2+=l2.charAt(j);
                    }

                }
            }
        }
        System.out.println(s2);
    }
}


public class KeyboardLayouts {
    public static void main(String args[]){
        Scanner S=new Scanner(System.in);
        String l1=S.next();
        String l2=S.next();
        String check=S.next();
        String s2="";
        for(int i=0;i<check.length();i++){
            char s=Character.toLowerCase(check.charAt(i));
            if(Character.isDigit(check.charAt(i)))
                s2+=check.charAt(i);
            for(int j=0;j<l1.length();j++){
                if(l1.charAt(j)==s){
                    if(l1.charAt(j)==l2.charAt(j)){
                       s2+=check.charAt(i);
                    }
                    else
                    {
                        if(Character.isUpperCase(check.charAt(i))){
                            s2+=Character.toUpperCase(l2.charAt(j));
                        }
                        else
                            s2+=l2.charAt(j);
                    }

                }
            }
        }
        System.out.println(s2);
    }
}


import java.util.Scanner;

/**
 * Created by Rahul on 14-08-2017.
 */
public class KeyboardLayouts {
    public static void main(String args[]){
        Scanner S=new Scanner(System.in);
        String l1=S.next();
        String l2=S.next();
        String check=S.next();
        String s2="";
        for(int i=0;i<check.length();i++){
            char s1=Character.toLowerCase(check.charAt(i));
            if(Character.isDigit(check.charAt(i)))
                s2+=check.charAt(i);
            for(int j=0;j<l1.length();j++){
                if(l1.charAt(j)==s1){
                    if(l1.charAt(j)==l2.charAt(j)){
                       s2+=check.charAt(i);
                    }
                    else
                    {
                        if(Character.isUpperCase(check.charAt(i))){
                            s2+=Character.toUpperCase(l2.charAt(j));
                        }
                        else
                            s2+=l2.charAt(j);
                    }

                }
            }
        }
        System.out.println(s2);
    }
}


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

 public class ProblemB {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		//inputs
		String first = input.next();
		String second = input.next();
		String text = input.next();
		String temp = "";
		for(int i = 0 ; i < text.length() ; i++) {
			if(Character.isAlphabetic(text.charAt(i)) && !temp.contains(Character.toLowerCase(text.charAt(i))+"")){
			int index = first.indexOf(Character.toLowerCase(text.charAt(i)));
			char ch = second.charAt(index);
			temp += Character.toLowerCase(ch);
			ch = Character.isUpperCase(text.charAt(i)) ? Character.toUpperCase(ch) : ch;
			text = text.replaceFirst(text.charAt(i)+"", ch+"");
		  }
		}

		System.out.println(text);
	}
}


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

 public class ProblemB {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		//inputs
		String first = input.next();
		String second = input.next();
		String text = input.next();
		StringBuilder sb = new StringBuilder(text);
		for(int i = 0 ; i < text.length() ; i++) {
			if(Character.isAlphabetic(text.charAt(i))){
			int index = first.indexOf(Character.toLowerCase(text.charAt(i)));
			char ch = second.charAt(index);
			ch = Character.isUpperCase(text.charAt(i)) ? Character.toUpperCase(ch) : ch;
			 sb.setCharAt(i, ch);
		  }
		}

		System.out.println(sb);
	}
}


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

 public class ProblemB {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		//inputs
		String first = input.next();
		String second = input.next();
		String text = input.next();
		String temp = "";
		for(int i = 0 ; i < text.length() ; i++) {
			if(Character.isAlphabetic(text.charAt(i)) && !temp.contains(Character.toLowerCase(text.charAt(i))+"")){
			int index = first.indexOf(Character.toLowerCase(text.charAt(i)));
			char ch = second.charAt(index);
			temp += Character.toLowerCase(text.charAt(i));
			ch = Character.isUpperCase(text.charAt(i)) ? Character.toUpperCase(ch) : ch;
			text = text.replaceFirst(text.charAt(i)+"", ch+"");
		  }
		}

		System.out.println(text);
	}
}


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

 public class ProblemB {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		//inputs
		String first = input.next();
		String second = input.next();
		String text = input.next();
		StringBuilder sb = new StringBuilder(text);
		for(int i = 0 ; i < text.length() ; i++) {
			if(Character.isAlphabetic(text.charAt(i))){
			int index = first.indexOf(Character.toLowerCase(text.charAt(i)));
			char ch = Character.isUpperCase(text.charAt(i)) ? Character.toUpperCase(second.charAt(index)) : second.charAt(index);
			sb.setCharAt(i, ch);
		  }
		}

		System.out.println(sb);
	}
}


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

 public class ProblemB {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		//inputs
		String first = input.next();
		String second = input.next();
		String text = input.next();

		for(int i = 0 ; i < text.length() ; i++) {
			if(Character.isAlphabetic(text.charAt(i))){
			int index = first.indexOf(String.valueOf(text.charAt(i)).toLowerCase());
			String ch = Character.isUpperCase(text.charAt(i)) ? String.valueOf(second.charAt(index)).toUpperCase() : String.valueOf(second.charAt(index));
			text = text.replaceFirst(text.charAt(i)+"", ch);
		  }
		}

		System.out.println(text);
	}
}


import java.util.*;
import java.io.*;
import java.math.*;

/**
 *
 * @author superuser
 */
public class Main {

    static long mod = (int) (1e9+7);

    static void solve() {
        String s1 = s();
        String s2 = s();
        Map<Character,Character> mp = new HashMap<>();
        for(int i=0;i<26;i++)
            mp.put(s1.charAt(i),s2.charAt(i));
        String s3 = s();
        String ans = "";
        for(int i=0;i<s3.length();i++)
        {
            boolean flag = Character.isLowerCase(s3.charAt(i));
            if(flag)
                ans+=""+mp.get(s3.charAt(i));
            else
            {
                flag = Character.isUpperCase(s3.charAt(i));
                if(!flag)
                    ans+=""+s3.charAt(i);
                else
                {
                    char c = Character.toLowerCase(s3.charAt(i));
                    c = mp.get(c);
                    ans+=""+Character.toUpperCase(c);
                }
            }
        }
        out.println(ans);
        out.close();
    }

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) {

        new Thread(null,new Runnable() {
            @Override
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();
    }

    static class Pair implements Comparable<Pair>{

        int x,y,i;

        Pair (int x,int y,int i){
            this.x = x;
            this.y = y;
                    this.i = i;
        }

            Pair (int x,int y){
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
                        return -Integer.compare(this.i,o.i);
            //return 0;
        }

        public boolean equals(Object o) {
            if (o instanceof Pair) {
                Pair p = (Pair)o;
                return p.x == x && p.y==y;
            }
            return false;
        }

        @Override
        public String toString() {
            return x + " "+ y + " "+i;
        }

        public int hashCode() {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }

    }

    static class Merge {

        public static void sort(int inputArr[]) {
            int length = inputArr.length;
            doMergeSort(inputArr,0, length - 1);
        }

        private static void doMergeSort(int[] arr,int lowerIndex, int higherIndex) {
            if (lowerIndex < higherIndex) {
                int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
                doMergeSort(arr,lowerIndex, middle);
                doMergeSort(arr,middle + 1, higherIndex);
                mergeParts(arr,lowerIndex, middle, higherIndex);
            }
        }

        private static void mergeParts(int[]array,int lowerIndex, int middle, int higherIndex) {
            int[] temp=new int[higherIndex-lowerIndex+1];
            for (int i = lowerIndex; i <= higherIndex; i++) {
                temp[i-lowerIndex] = array[i];
            }
            int i = lowerIndex;
            int j = middle + 1;
            int k = lowerIndex;
            while (i <= middle && j <= higherIndex) {
                if (temp[i-lowerIndex] < temp[j-lowerIndex]) {
                    array[k] = temp[i-lowerIndex];
                    i++;
                } else {
                    array[k] = temp[j-lowerIndex];
                    j++;
                }
                k++;
            }
            while (i <= middle) {
                array[k] = temp[i-lowerIndex];
                k++;
                i++;
            }
            while(j<=higherIndex){
                array[k]=temp[j-lowerIndex];
                k++;
                j++;
            }
        }

    }

    static long add(long a,long b){
        long x=(a+b);
        while(x>=mod) x-=mod;
        return x;
    }

    static long sub(long a,long b){
        long x=(a-b);
        while(x<0) x+=mod;
        return x;
    }

    static long mul(long a,long b){
        a%=mod;
        b%=mod;
        long x=(a*b);
        return x%mod;
    }

    static boolean isPal(String s){
        for(int i=0, j=s.length()-1;i<=j;i++,j--){
                if(s.charAt(i)!=s.charAt(j)) return false;
        }
        return true;
    }
    static String rev(String s){
                StringBuilder sb=new StringBuilder(s);
                sb.reverse();
                return sb.toString();
    }

    static long gcd(long x,long y){
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static int gcd(int x,int y){
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static long gcdExtended(long a,long b,long[] x){

        if(a==0){
            x[0]=0;
            x[1]=1;
            return b;
        }
        long[] y=new long[2];
        long gcd=gcdExtended(b%a, a, y);

        x[0]=y[1]-(b/a)*y[0];
        x[1]=y[0];

        return gcd;
    }

    static long mulmod(long  a,long b,long m) {
        if (m <= 1000000009) return a * b % m;

        long res = 0;
        while (a > 0) {
            if ((a&1)!=0) {
                res += b;
                if (res >= m) res -= m;
            }
            a >>= 1;
            b <<= 1;
            if (b >= m) b -= m;
        }
        return res;
    }

    static int abs(int a,int b){
        return (int)Math.abs(a-b);
    }

    public static long abs(long a,long b){
        return (long)Math.abs(a-b);
    }

    static int max(int a,int b){
        if(a>b)
                return a;
        else
                return b;
    }

    static int min(int a,int b){
        if(a>b)
                return b;
        else
                return a;
    }

    static long max(long a,long b){
        if(a>b)
                return a;
        else
                return b;
    }

    static long min(long a,long b){
        if(a>b)
                return b;
        else
                return a;
    }

    static long pow(long n,long p,long m){
         long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            if(result>=m)
            result%=m;
            p >>=1;
            n*=n;
            if(n>=m)
            n%=m;
        }
        return result;
    }

    static long pow(long n,long p){
        long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            p >>=1;
            n*=n;
        }
        return result;
    }

    static void debug(Object... o) {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
                this.stream = stream;
        }

        public int snext() {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars) {
                        curChar = 0;
                        try {
                                snumChars = stream.read(buf);
                        } catch (IOException e) {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n) {
                long a[] = new long[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextLong();
                }
                return a;
        }

        public String nextLine() {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c) {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
        }

    }
    static int i()
    {
        return sc.nextInt();
    }
    static long l(){
        return sc.nextLong();
    }
    static int[] iarr(int n)
    {
        return sc.nextIntArray(n);
    }
    static long[] larr(int n)
    {
        return sc.nextLongArray(n);
    }
    static String s(){
        return sc.nextLine();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

/**
 *
 * @author superuser
 */
public class Main {

    static long mod = (int) (1e9+7);

    static void solve() {
        String s1 = s();
        String s2 = s();
        Map<Character,Character> mp = new HashMap<>();
        for(int i=0;i<26;i++)
        {
            mp.put(s1.charAt(i),s2.charAt(i));
            mp.put((char)(s1.charAt(i)-32),(char)(s2.charAt(i)-32));
        }
        String s = s();
        for(char c: s.toCharArray())
        {
            if(mp.containsKey(c))
                out.print(mp.get(c));
            else
                out.print(c);
        }

        out.close();
    }

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) {

        new Thread(null,new Runnable() {
            @Override
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();
    }

    static class Pair implements Comparable<Pair>{

        int x,y,i;

        Pair (int x,int y,int i){
            this.x = x;
            this.y = y;
                    this.i = i;
        }

            Pair (int x,int y){
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
                        return -Integer.compare(this.i,o.i);
            //return 0;
        }

        public boolean equals(Object o) {
            if (o instanceof Pair) {
                Pair p = (Pair)o;
                return p.x == x && p.y==y;
            }
            return false;
        }

        @Override
        public String toString() {
            return x + " "+ y + " "+i;
        }

        public int hashCode() {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }

    }

    static class Merge {

        public static void sort(int inputArr[]) {
            int length = inputArr.length;
            doMergeSort(inputArr,0, length - 1);
        }

        private static void doMergeSort(int[] arr,int lowerIndex, int higherIndex) {
            if (lowerIndex < higherIndex) {
                int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
                doMergeSort(arr,lowerIndex, middle);
                doMergeSort(arr,middle + 1, higherIndex);
                mergeParts(arr,lowerIndex, middle, higherIndex);
            }
        }

        private static void mergeParts(int[]array,int lowerIndex, int middle, int higherIndex) {
            int[] temp=new int[higherIndex-lowerIndex+1];
            for (int i = lowerIndex; i <= higherIndex; i++) {
                temp[i-lowerIndex] = array[i];
            }
            int i = lowerIndex;
            int j = middle + 1;
            int k = lowerIndex;
            while (i <= middle && j <= higherIndex) {
                if (temp[i-lowerIndex] < temp[j-lowerIndex]) {
                    array[k] = temp[i-lowerIndex];
                    i++;
                } else {
                    array[k] = temp[j-lowerIndex];
                    j++;
                }
                k++;
            }
            while (i <= middle) {
                array[k] = temp[i-lowerIndex];
                k++;
                i++;
            }
            while(j<=higherIndex){
                array[k]=temp[j-lowerIndex];
                k++;
                j++;
            }
        }

    }

    static long add(long a,long b){
        long x=(a+b);
        while(x>=mod) x-=mod;
        return x;
    }

    static long sub(long a,long b){
        long x=(a-b);
        while(x<0) x+=mod;
        return x;
    }

    static long mul(long a,long b){
        a%=mod;
        b%=mod;
        long x=(a*b);
        return x%mod;
    }

    static boolean isPal(String s){
        for(int i=0, j=s.length()-1;i<=j;i++,j--){
                if(s.charAt(i)!=s.charAt(j)) return false;
        }
        return true;
    }
    static String rev(String s){
                StringBuilder sb=new StringBuilder(s);
                sb.reverse();
                return sb.toString();
    }

    static long gcd(long x,long y){
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static int gcd(int x,int y){
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static long gcdExtended(long a,long b,long[] x){

        if(a==0){
            x[0]=0;
            x[1]=1;
            return b;
        }
        long[] y=new long[2];
        long gcd=gcdExtended(b%a, a, y);

        x[0]=y[1]-(b/a)*y[0];
        x[1]=y[0];

        return gcd;
    }

    static long mulmod(long  a,long b,long m) {
        if (m <= 1000000009) return a * b % m;

        long res = 0;
        while (a > 0) {
            if ((a&1)!=0) {
                res += b;
                if (res >= m) res -= m;
            }
            a >>= 1;
            b <<= 1;
            if (b >= m) b -= m;
        }
        return res;
    }

    static int abs(int a,int b){
        return (int)Math.abs(a-b);
    }

    public static long abs(long a,long b){
        return (long)Math.abs(a-b);
    }

    static int max(int a,int b){
        if(a>b)
                return a;
        else
                return b;
    }

    static int min(int a,int b){
        if(a>b)
                return b;
        else
                return a;
    }

    static long max(long a,long b){
        if(a>b)
                return a;
        else
                return b;
    }

    static long min(long a,long b){
        if(a>b)
                return b;
        else
                return a;
    }

    static long pow(long n,long p,long m){
         long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            if(result>=m)
            result%=m;
            p >>=1;
            n*=n;
            if(n>=m)
            n%=m;
        }
        return result;
    }

    static long pow(long n,long p){
        long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            p >>=1;
            n*=n;
        }
        return result;
    }

    static void debug(Object... o) {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
                this.stream = stream;
        }

        public int snext() {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars) {
                        curChar = 0;
                        try {
                                snumChars = stream.read(buf);
                        } catch (IOException e) {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n) {
                long a[] = new long[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextLong();
                }
                return a;
        }

        public String nextLine() {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c) {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
        }

    }
    static int i()
    {
        return sc.nextInt();
    }
    static long l(){
        return sc.nextLong();
    }
    static int[] iarr(int n)
    {
        return sc.nextIntArray(n);
    }
    static long[] larr(int n)
    {
        return sc.nextLongArray(n);
    }
    static String s(){
        return sc.nextLine();
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 *
 * @author elshamey
 */
public class Examples {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan =  new Scanner(System.in);
        String s1  = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        String answer = "";
        LinkedList<Character>l = new  LinkedList<>();
        for(int i = 0;i<26;i++)
        {
            l.add(s1.charAt(i));
        }

        for(int i = 0;i<s3.length();i++)
        {
            char c =Character.toLowerCase(s3.charAt(i));
            char c1 = s3.charAt(i);
            int a = l.indexOf(c);
            if(Character.isDigit(c))
            {
                answer += c;
            } else if(Character.isLowerCase(c1)){
                answer += Character.toLowerCase(s2.charAt(a));

            } else if(Character.isUpperCase(c1))
            {
                answer += Character.toUpperCase(s2.charAt(a));
            }
        }

        System.out.println(answer);

    }

}


import java.util.LinkedList;
import java.util.Scanner;

/**
 *
 * @author elshamey
 */
public class Examples {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan =  new Scanner(System.in);
        String s1  = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        String answer = "";
        LinkedList<Character>l = new  LinkedList<>();
        for(int i = 0;i<26;i++)
        {
            l.add(s1.charAt(i));
        }

        for(int i = 0;i<s3.length();i++)
        {
            char c =Character.toLowerCase(s3.charAt(i));
            int a = l.indexOf(c);
            if(Character.isDigit(c))
            {
                answer += c;
            } else if(Character.isLowerCase(c)){
                answer += Character.toLowerCase(s2.charAt(a));

            } else if(Character.isUpperCase(c))
            {
                answer += Character.toUpperCase(s2.charAt(a));
            }
        }

        System.out.println(answer);

    }

}


import java.util.Scanner;
public class CF831B {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        char[] x = new char[26];
        for(int i = 0; i<26;i++){
            x[a[i]-'a'] = b[i];
        }
        for(int i = 0; i < c.length;i++){
            if ('a'<=c[i] && c[i] <= 'z') {
                c[i] = x[c[i]-'a'];
            }
            if ('A' <= c[i] && c[i]<='Z'){
                c[i] = (char)(x[c[i]-'A'] - ('a' + 'A'));
            }
        }
        System.out.println(new String(c));
    }
}


import java.util.Scanner;
public class CF831B {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        char[] x = new char[26];
        for(int i = 0; i<26;i++){
            x[a[i]-'a'] = b[i];
        }
        for(int i = 0; i < c.length;i++){
            if ('a'<=c[i] && c[i] <= 'z') {
                c[i] = b[c[i]-'a'];
            }
            if ('A' <= c[i] && c[i]<='Z'){
                c[i] = b[c[i]-'A'] - (int)'a' + (int)'A';
            }
        }
        System.out.println(new String(c));
    }
}


import java.util.Scanner;
public class CF831B {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        char[] x = new char[26];
        for(int i = 0; i<26;i++){
            x[a[i]-'a'] = b[i];
        }
        for(int i = 0; i < c.length;i++){
            if ('a'<=c[i] && c[i] <= 'z') {
                c[i] = x[c[i]-'a'];
            }
            if ('A' <= c[i] && c[i]<='Z'){
                c[i] = (char)(x[c[i]-'A'] + ('A' - 'a'));
            }
        }
        System.out.println(new String(c));
    }
}


import java.util.Scanner;
public class CF831B {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        char[] x = new char[26];
        for(int i = 0; i<26;i++){
            x[a[i]-'a'] = b[i];
        }
        for(int i = 0; i < c.length;i++){
            if ('a'<=c[i] && c[i] <= 'z') {
                c[i] = b[c[i]-'a'];
            }
            if ('A' <= c[i] && c[i]<='Z'){
                c[i] = (char)(b[c[i]-'A'] -('a' + 'A'));
            }
        }
        System.out.println(new String(c));
    }
}


import java.util.Scanner;
public class CF831B {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        char[] x = new char[26];
        for(int i = 0; i<26;i++){
            x[a[i]-'a'] = b[i];
        }
        for(int i = 0; i < c.length;i++){
            if ('a'<=c[i] && c[i] <= 'z') {
                c[i] = b[c[i]-'a'];
            }
            if ('A' <= c[i] && c[i]<='Z'){
                c[i] = b[c[i]-'A'] - 'a' + 'A';
            }
        }
        System.out.println(new String(c));
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.InputMismatchException;

public class ques2 {

	static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                        numChars = stream.read(buf);
                } catch (IOException e) {
                        throw new InputMismatchException();
                }
                if (numChars <= 0) {
                        return -1;
                }
            }
            return buf[curChar++];
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }

        public String next() {
            return nextString();
        }

        public char nextChar(){
        	int c=read();
        	while (isSpaceChar(c)) {
                c = read();
            }
        	return (char)c;
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public Long nextLong() {
            return Long.parseLong(nextString());
        }

        public Double nextDouble() {
            return Double.parseDouble(nextString());
        }
    }

	public static void main(String[] args) {
		HashMap<Character,Character> map=new HashMap<>();
		InputReader s=new InputReader(System.in);
		String original=s.nextString();
		String convert=s.nextString();

		for(int i=0;i<original.length();i++)
		{
			char in1=original.charAt(i);
			char in2=convert.charAt(i);

			int in1num=in1;
			if(in1num>=65&&in1num<=90)
				in1num=in1num+32;

			if(!map.containsKey((char)in1num))
			{
				int in2num=in2;
				if(in2num>=65&&in2num<=90)
					in2num=in2num+32;

				map.put((char)in1num, (char)in2num);
			}
		}

		String input=s.nextString();
		StringBuilder output=new StringBuilder();
		for(int i=0;i<input.length();i++)
		{
			char ch1=input.charAt(i);
			int ch1num=ch1;
			if(ch1num>=65&&ch1num<=90)
			{
				ch1num+=32;
				int temp=map.get((char)ch1num);
				temp-=32;
				output.append((char)temp);
			}
			else if(ch1num>=97&&ch1num<=122)
				output.append(map.get(ch1));

			else
				output.append(ch1);
		}

		System.out.println(output);
	}

}


import java.util.HashMap;

import CDFR424.ques1.InputReader;

public class ques2 {

	public static void main(String[] args) {
		HashMap<Character,Character> map=new HashMap<>();
		InputReader s=new InputReader(System.in);
		String original=s.nextString();
		String convert=s.nextString();

		for(int i=0;i<original.length();i++)
		{
			char in1=original.charAt(i);
			char in2=convert.charAt(i);

			int in1num=in1;
			if(in1num>=65&&in1num<=90)
				in1num=in1num+32;

			if(!map.containsKey((char)in1num))
			{
				int in2num=in2;
				if(in2num>=65&&in2num<=90)
					in2num=in2num+32;

				map.put((char)in1num, (char)in2num);
			}
		}

		String input=s.nextString();
		StringBuilder output=new StringBuilder();
		for(int i=0;i<input.length();i++)
		{
			char ch1=input.charAt(i);
			int ch1num=ch1;
			if(ch1num>=65&&ch1num<=90)
			{
				ch1num+=32;
				int temp=map.get((char)ch1num);
				temp-=32;
				output.append((char)temp);
			}
			else if(ch1num>=97&&ch1num<=122)
				output.append(map.get(ch1));

			else
				output.append(ch1);
		}

		System.out.println(output);
	}

}


import java.util.Scanner;

    public class Two {
        public static void main(String[] args){
            Scanner scanner = new Scanner(System.in);
            String a = scanner.next();
            String b = scanner.next();
            String text = scanner.next();
            String answer="";
            for (int i = 0; i < text.length();i++){
                if(Character.isDigit(text.charAt(i))){
                    answer+=text.charAt(i);
                }
                for(int j=0;j<26;j++) {
                    if(text.charAt(i)==a.charAt(j)){
                        answer+=b.charAt(j);
                        break;
                    }
                    if(text.charAt(i)==a.charAt(j)-32){
                        answer+=(b.charAt(j)+32);
                    }
                }
            }
            System.out.print(answer);
        }

    }


import java.util.Scanner;

    public class Two {
        public static void main(String[] args){
            Scanner scanner = new Scanner(System.in);
            String a = scanner.next();
            String b = scanner.next();
            String text = scanner.next();
            String answer="";
            for (int i = 0; i < text.length();i++){
                if(Character.isDigit(text.charAt(i))){
                    answer+=text.charAt(i);
                }
                for(int j=0;j<a.length();j++) {
                    if(text.charAt(i)==a.charAt(j)){
                        answer+=b.charAt(j);
                        break;
                    }
                    if(text.charAt(i)==a.charAt(j)-32){
                        answer+=(char)(b.charAt(j)-32);
                    }
                }
            }
            System.out.print(answer);
        }

    }


import java.util.Arrays;
import java.util.Scanner;
import javax.swing.JFrame;

public class problemA{

public static void main (String []args ) throws IOException
{  Scanner sc=new Scanner(System.in);
String s1=sc.nextLine();
String s2=sc.nextLine();
String s3=sc.nextLine();
int k=0;
char []arr=new char[s3.length()];
for(int i=0;i<s3.length();i++)
{
	char d=s3.charAt(i);
	for(int j=0;j<s1.length();j++)
	{ d=Character.toLowerCase(d);
		if(s1.charAt(j)==d)
	{
		if(Character.isUpperCase(s3.charAt(i)))
		{ char f=s2.charAt(j);
			arr[k]=Character.toUpperCase(f);
			k++;
		}
		else {
			arr[k]=s2.charAt(j);
			k++;
		}
	}
		else if(Character.isDigit(d)) {
			arr[k]=d;
		k++;
		break;}

	}
}
for(int k2=0;k2<s3.length();k2++)
{    System.out.print(arr[k2]);
	}

}

}


import java.util.Arrays;
import java.util.Scanner;
import javax.swing.JFrame;

public class problemA{

public static void main (String []args )
{  Scanner sc=new Scanner(System.in);
String s1=sc.nextLine();
String s2=sc.nextLine();
String s3=sc.nextLine();
int k=0;
char []arr=new char[s3.length()];
for(int i=0;i<s3.length();i++)
{
	char d=s3.charAt(i);
	for(int j=0;j<s1.length();j++)
	{ d=Character.toLowerCase(d);
		if(s1.charAt(j)==d)
	{
		if(Character.isUpperCase(s3.charAt(i)))
		{ char f=s2.charAt(j);
			arr[k]=Character.toUpperCase(f);
			k++;
		}
		else {
			arr[k]=s2.charAt(j);
			k++;
		}
	}
		else if(Character.isDigit(d)) {
			arr[k]=d;
		k++;
		break;}

	}
}
for(int k2=0;k2<s3.length();k2++)
{    System.out.print(arr[k2]);
	}

}

}


import java.util.Scanner;
public class khob{
    public static char capital(char a){
		if (a=='A') a='a';
		if (a=='B') a='b';
		if (a=='C') a='c';
		if (a=='D') a='d';
		if (a=='E') a='e';
		if (a=='F') a='f';
		if (a=='G') a='g';
		if (a=='H') a='h';
		if (a=='I') a='i';
		if (a=='J') a='j';
		if (a=='K') a='k';
		if (a=='L') a='l';
		if (a=='M') a='m';
		if (a=='N') a='n';
		if (a=='O') a='o';
		if (a=='P') a='p';
		if (a=='Q') a='q';
		if (a=='R') a='r';
		if (a=='S') a='s';
		if (a=='T') a='t';
		if (a=='U') a='u';
		if (a=='V') a='v';
		if (a=='W') a='w';
		if (a=='X') a='x';
		if (a=='Y') a='y';
		if (a=='Z') a='z';
		return a;
	}
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        String x = scanner.next();
        for (int i=0;i<x.length();i++) {
            for (int j=0;j<26;j++) {
                if (x.charAt(i)==s1.charAt(j)) System.out.print(s2.charAt(j));
                else if (capital(x.charAt(i))==s1.charAt(j)) System.out.print(capital(s2.charAt(j)));
                else System.out.println(x.charAt(j));
            }
        }
        scanner.close();
}}


import java.util.Scanner;
public class keyboad {
	public static char small(char a){
		if (a=='A') a='a';
		if (a=='B') a='b';
		if (a=='C') a='c';
		if (a=='D') a='d';
		if (a=='E') a='e';
		if (a=='F') a='f';
		if (a=='G') a='g';
		if (a=='H') a='h';
		if (a=='I') a='i';
		if (a=='J') a='j';
		if (a=='K') a='k';
		if (a=='L') a='l';
		if (a=='M') a='m';
		if (a=='N') a='n';
		if (a=='O') a='o';
		if (a=='P') a='p';
		if (a=='Q') a='q';
		if (a=='R') a='r';
		if (a=='S') a='s';
		if (a=='T') a='t';
		if (a=='U') a='u';
		if (a=='V') a='v';
		if (a=='W') a='w';
		if (a=='X') a='x';
		if (a=='Y') a='y';
		if (a=='Z') a='z';
		return a;

	}
	public static char capital(char a){
		if (a=='a') a='A';
		if (a=='b') a='B';
		if (a=='c') a='C';
		if (a=='d') a='D';
		if (a=='e') a='E';
		if (a=='f') a='F';
		if (a=='g') a='G';
		if (a=='h') a='H';
		if (a=='i') a='I';
		if (a=='j') a='J';
		if (a=='k') a='K';
		if (a=='l') a='L';
		if (a=='m') a='M';
		if (a=='n') a='N';
		if (a=='o') a='O';
		if (a=='p') a='P';
		if (a=='q') a='Q';
		if (a=='r') a='R';
		if (a=='s') a='S';
		if (a=='t') a='T';
		if (a=='u') a='U';
		if (a=='v') a='V';
		if (a=='w') a='W';
		if (a=='x') a='X';
		if (a=='y') a='Y';
		if (a=='z') a='Z';
		return a;
	}

public static void main(String[] args) {
	Scanner scanner = new Scanner (System.in);
	String a = scanner.next();
	String b = scanner.next();
	String c = scanner.next();
	char s=' ';
	for (int i=0;i<c.length();i++) {
		for (int j=0;j<26;j++) {
			if (c.charAt(i)==a.charAt(j)) {s=b.charAt(j);break;}
			else if (small(c.charAt(i))==a.charAt(j)) {s=capital(b.charAt(j));break;}
			else s=c.charAt(i);
		}
		System.out.print(s);
	}
	scanner.close();
}
}


import java.util.Scanner;
public class khob{
    public static char capital(char a){
		if (a=='A') a='a';
		if (a=='B') a='b';
		if (a=='C') a='c';
		if (a=='D') a='d';
		if (a=='E') a='e';
		if (a=='F') a='f';
		if (a=='G') a='g';
		if (a=='H') a='h';
		if (a=='I') a='i';
		if (a=='J') a='j';
		if (a=='K') a='k';
		if (a=='L') a='l';
		if (a=='M') a='m';
		if (a=='N') a='n';
		if (a=='O') a='o';
		if (a=='P') a='p';
		if (a=='Q') a='q';
		if (a=='R') a='r';
		if (a=='S') a='s';
		if (a=='T') a='t';
		if (a=='U') a='u';
		if (a=='V') a='v';
		if (a=='W') a='w';
		if (a=='X') a='x';
		if (a=='Y') a='y';
		if (a=='Z') a='z';
		return a;
	}
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        String x = scanner.next();
        for (int i=0;i<x.length();i++) {
        	char s='';
            for (int j=0;j<26;j++) {
                if (x.charAt(i)==s1.charAt(j)) s=s2.charAt(j);
                else if (capital(x.charAt(i))==s1.charAt(j)) s=capital(s2.charAt(j));
                else s=x.charAt(i);
            }
            System.out.print(s);

        }
        scanner.close();
}}


#include<bits/stdc++.h>

typedef long long int ll;

#define pp pair<ll,ll>
#define dbg printf("in\n");
#define NL printf("\n");

#define inf 1000000000000

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    ll i,j,k;
    ll n;
    string s,t;

    map<char,char> mp;

    cin>>s>>t;

    for(i=0;i<s.length();i++)
        mp[s[i]]=t[i];

    cin>>s;

    char ch;
    for(i=0;i<s.length();i++)
    {
        if(isdigit(s[i]))
        {
            cout<<s[i];
            continue;
        }

        if(mp[s[i]])
            cout<<mp[s[i]];

        else
        {
            if(isupper(s[i]))
            {
                ch=mp[s[i]+32]-32;
                cout<<(ch);
            }

//            else
//            {
//                ch=mp[s[i]-32]+32;
//                cout<<ch;
//            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>

typedef long long int ll;

#define pp pair<ll,ll>
#define dbg printf("in\n");
#define NL printf("\n");

#define inf 1000000000000

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    ll i,j,k;
    ll n;
    string s,t;

    map<char,char> mp;

    cin>>s>>t;

    for(i=0;i<s.length();i++)
        mp[s[i]]=t[i];

    cin>>s;

    char ch;
    for(i=0;i<s.length();i++)
    {
        if(isdigit(s[i]))
        {
            cout<<s[i];
            continue;
        }

//        if(mp[s[i]])
//            cout<<mp[s[i]];

        else
        {
            if(isupper(s[i]))
            {
                ch=mp[s[i]+32]-32;
                cout<<(ch);
            }

            else
            {
                ch=mp[s[i]-32]+32;
                cout<<ch;
            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>

typedef long long int ll;

#define pp pair<ll,ll>
#define dbg printf("in\n");
#define NL printf("\n");

#define inf 1000000000000

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    ll i,j,k;
    ll n;
    string s,t;

    map<char,char> mp;

    cin>>s>>t;

    for(i=0;i<s.length();i++)
        mp[s[i]]=t[i];

    cin>>s;

    char ch;
    for(i=0;i<s.length();i++)
    {
        if(isdigit(s[i]))
        {
            cout<<s[i];
            continue;
        }

        if(mp[s[i]])
            cout<<mp[s[i]];

        else
        {
            if(isupper(s[i]))
            {
                ch=mp[s[i]+32]-32;
                cout<<(ch);
            }

            else
            {
                ch=mp[s[i]-32]+32;
                cout<<ch;
            }
        }
    }

    return 0;
}