func_code_string: #include <bits/stdc++.h>   using namespace std;   string ori;   string start;   string target;   int n;   char mapping[256];   char mapn[256];   char used[256];   bool apply(int a, int b) {     if ((mapping[a] == 0 && used[b] == false) || mapping[a] == b) {       mapping[a] = b;       used[b] = true;       mapn[a]++;       return true;     }     return false;   }   void undo(int a, int b) {     mapn[a]--;     if (mapn[a] == 0) {       used[mapping[a]] = 0;       mapping[a] = 0;     }   }   bool recurse(int i, bool eqa, bool eqb) {     if (i == ori.size())       return true;     else if (eqa && eqb) {       if (start[i] == target[i]) {         if (apply(ori[i], start[i])) {           if (recurse(i + 1, true, true)) {             return true;           }           undo(ori[i], start[i]);         }       } else {         for (int c = start[i]; c <= target[i]; c++) {           if (apply(ori[i], c)) {             if (recurse(i + 1, start[i] == c, target[i] == c)) {               return true;             }             undo(ori[i], start[i]);           }         }       }     } else if (eqa) {       for (int c =  a  + n; --c >= start[i];) {         if (apply(ori[i], c)) {           if (recurse(i + 1, start[i] == c, false)) {             return true;           }           undo(ori[i], c);           break;         }       }     } else if (eqb) {       for (int c =  a ; c <= target[i]; c++) {         if (apply(ori[i], c)) {           if (recurse(i + 1, false, target[i] == c)) {             return true;           }           undo(ori[i], c);           break;         }       }     } else {       return true;     }     return false;   }   void go() {     cin >> n;     cin >> ori >> start >> target;     memset(mapping, 0, sizeof(mapping));     memset(mapn, 0, sizeof(mapn));     memset(used, 0, sizeof(used));     bool res = recurse(0, true, true);     if (res) {       cout <<  YES n ;       set<char> unused;       for (int i =  a ; i <  a  + n; i++) {         if (not used[i]) {           unused.insert(i);         }       }       for (int i =  a ; i <  a  + n; i++) {         if (mapping[i] == 0) {           mapping[i] = *unused.begin();           unused.erase(unused.begin());         }       }       cout << mapping +  a ;       cout <<   n ;     } else {       cout <<  NO n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int testn;     cin >> testn;     for (int testi = 1; testi <= testn; testi++) {       go();     }   }   