func_code_string: #include <bits/stdc++.h>   using namespace std;   char s[1000010], a[1000010], b[1000010];   char perm[300];   char used[300];   char savedPerm[300];   char savedUsed[300];   int k;   bool fit(char from, char to) {     if (perm[from] != 0) {       if (perm[from] != to) return false;     } else {       if (used[to] != 0) return false;       used[to] = 1;       perm[from] = to;     }     return true;   }   void fillUnused() {     char i, j =  a ;     for (i =  a ; i <  a  + k; i++) {       if (perm[i] == 0) {         while (used[j] == 1) j++;         perm[i] = j;         j++;       }     }   }   void solve() {     scanf( %d%s%s%s , &k, s, a, b);     memset(perm, 0, sizeof(perm));     memset(used, 0, sizeof(used));     int n = strlen(s);     int state = 0;     int conflict = -1;     for (int i = 0; i < n; i++) {       switch (state) {         case 0:           if (a[i] == b[i]) {             if (!fit(s[i], a[i])) {               printf( NO n );               return;             }           } else {             for (char ch = a[i] + 1; ch < b[i]; ch++) {               if (fit(s[i], ch)) {                 state = -1;                 break;               }             }             if (state != -1) {               memcpy(savedPerm, perm, sizeof(perm));               memcpy(savedUsed, used, sizeof(used));               if (conflict == -1) {                 if (fit(s[i], a[i])) {                   conflict = i;                   state = 1;                 } else if (fit(s[i], b[i]))                   state = 2;                 else {                   printf( NO n );                   return;                 }               } else if (fit(s[i], b[i]))                 state = 2;               else {                 printf( NO n );                 return;               }             }           }           break;         case 1:           for (char ch = a[i] + 1; ch <  a  + k; ch++) {             if (fit(s[i], ch)) {               state = -1;               break;             }           }           if (state != -1) {             if (!fit(s[i], a[i])) {               state = 0;               i = conflict - 1;               memcpy(perm, savedPerm, sizeof(perm));               memcpy(used, savedUsed, sizeof(used));               break;             }           }           break;         case 2:           for (char ch =  a ; ch < b[i]; ch++) {             if (fit(s[i], ch)) {               state = -1;               break;             }           }           if (state != -1) {             if (!fit(s[i], b[i])) {               printf( NO n );               return;             }           }           break;       }       if (state == -1) break;     }     fillUnused();     printf( YES n );     for (int i =  a ; i <  a  + k; i++) printf( %c , perm[i]);     printf(  n );   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       solve();     }     return 0;   }   