#include <bits/stdc++.h>   using namespace std;   const long double EPS = 1E-9;   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double PI = 2 * acos(.0);   int main() {     string num;     cin >> num;     int a[11];     fill(a, a + 11, 0);     for (int i = 0; i < (int)((num).size()); i++) {       a[num[i] -  0 ]++;     }     int cont = 0;     string temp1 = num;     string temp2 = num;     int a2[11];     int a3[11];     bool cent = 1;     for (int i = 1; i < (int)(10); i++) {       int temp = 0;       char kk1 =  s , kk2 =  s ;       vector<pair<char, int> > t1;       vector<pair<char, int> > t2;       for (int j = 0; j < (int)(10); j++) a2[j] = a3[j] = a[j];       if (a2[i] > 0 && a3[10 - i] > 0) {         a2[i]--;         a3[10 - i]--;         kk1 =  0  + i;         kk2 =  0  + (10 - i);       } else         continue;       temp = 1;       for (int j = 0; j < (int)(10); j++) {         int mini = min(a2[j], a3[9 - j]);         temp += mini;         a2[j] -= mini;         a3[9 - j] -= mini;         t1.push_back(make_pair( 0  + j, mini));         t2.push_back(make_pair( 0  + (9 - j), mini));       }       temp += min(a2[0], a3[0]);       int conta = min(a2[0], a3[0]);       a2[0] -= conta;       a3[0] -= conta;       if (temp > cont) {         cent = 0;         temp1 =   ;         temp2 =   ;         for (int j = 0; j < (int)(10); j++) {           if (a2[j] > 0) temp1.append(a2[j],  0  + j);           if (a3[j] > 0) temp2.append(a3[j],  0  + j);         }         for (int j = 0; j < (int)((t1).size()); j++) {           temp1.append(t1[j].second, t1[j].first);           temp2.append(t2[j].second, t2[j].first);         }         temp1 += kk1;         temp2 += kk2;         temp1.append(conta,  0 );         temp2.append(conta,  0 );         cont = temp;       }     }     if (cent) {       temp1 =   ;       temp2 =   ;       for (int j = 1; j < (int)(10); j++) {         if (a[j] > 0) temp1.append(a[j],  0  + j);         if (a[j] > 0) temp2.append(a[j],  0  + j);       }       temp1.append(a[0],  0 );       temp2.append(a[0],  0 );     }     cout << temp1 << endl << temp2 << endl;     return 0;   }   