Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
815 B
1
Indexable
Never
#pragma GCC optimize("O2,no-stack-protector,unroll-loops")
#define ll long long
#define pb push_back
#define ipar(arr, n) vector<ll> arr(n); for(int i=0;i<n;i++) cin>>arr[i];
#include <cmath>
#include <bits/stdc++.h>
#define pii pair<int, int>;
#define pll pair<ll, ll>;
using namespace std;

void solve(){
    ll n;cin>>n;
    string s;cin>>s;

    vector<char>final(26);
    for(ll i=0;i<26;i++) final[i]=i+'a'; 

    ll q;cin>>q;

    while(q--){
        char J, Q; cin>>J>>Q;
        for(ll i=0;i<26;i++){
            if(final[i]==J)final[i]=Q;
        }
    }

    for(ll i=0;i<n;i++){
        cout<<final[s[i]-'a'];
    }
    cout<<"\n";
}



signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
	//cin>>t;
	while(t--) solve();
}
Leave a Comment