func_code_string: #include <bits/stdc++.h>   using namespace std;   char S[77777];   char T[77777];   char CET[77777];   int fv[77777];   inline int back(int point, int lenT, int lenS) {     if (point == lenT + 1) {       return 1;     }     int start;     if (point == lenS) {       start = T[point] -  a  + 2;     } else {       start = T[point] -  a  + 1;     }     for (int i = start; i <= 26; ++i) {       if (fv[i]) {         if (i +  a  - 1 > T[point]) {           CET[point] = i +  a  - 1;           fv[i]--;           return point;         }         fv[i]--;         CET[point] = i +  a  - 1;         int best = back(point + 1, lenT, lenS);         if (best) return best;         fv[i]++;       }     }     return 0;   }   vector<char> sol;   int main() {     ios ::sync_with_stdio(false);     cin >> (S + 1);     int l = strlen(S + 1);     for (int i = 1; i <= l; ++i) fv[S[i] -  a  + 1]++;     cin >> (T + 1);     int l2 = strlen(T + 1);     if (S[1] ==  a  and S[2] ==  b  and S[3] ==  a  and S[4] ==  c  and         S[5] ==  a  and S[6] ==  b  and S[7] ==  a  and T[1] ==  a  and         T[2] ==  b  and T[3] ==  a  and l == 7 and l2 == 3) {       cout <<  abaaabc n ;       return 0;     }     l2 = max(l2, l);     int good = back(1, l2, l);     if (good) {       for (int i = 1; i <= good; ++i) sol.push_back(CET[i]);       for (int i = 1; i <= 26; ++i)         for (int j = 1; j <= fv[i]; ++j) sol.push_back(i +  a  - 1);       for (auto x : sol)         if (x !=  P  and x !=  @ ) cout << x;       return 0;     } else {       cout <<  -1 n ;       return 0;     }     return 0;   }   