volia
#include <bits/stdc++.h>
using namespace std;string text, origin, after, result = "", allchar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";vector<int> chart(128);
void replace(string::iterator first, string::iterator last, char old_char, char new_char) {for (;first != last;first++) {if (*first == old_char) *first = new_char;}}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m, i;for (i = 0;i < (int)allchar.size();i++) {chart[(int)allchar[i]] = i;}cin >> n >> m;cin >> text >> origin >> after;for (i = 0;i < m;i++) {replace(code.begin(), code.end(), origin[i], after[i]);}for (i = 0;i < n;i++) {putchar(code[chart[(int)text[i]]]);}}