#include <bits/stdc++.h>   using namespace std;   inline long long read() {     char ch = getchar();     long long p = 1, data = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) p = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       data = data * 10 + (ch ^ 48);       ch = getchar();     }     return p * data;   }   inline long long qpow(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = a * r;       a = a * a;       b >>= 1;     }     return r;   }   inline long long gcd(long long a, long long b) {     while (b ^= a ^= b ^= a %= b)       ;     return a;   }   inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   void exgcd(long long a, long long b, long long &x, long long &y) {     if (!b)       x = 1, y = 0;     else {       exgcd(b, a % b, y, x);       y -= x * (a / b);     }   }   const int mod = 1e9 + 7, maxn = 1e5 + 5;   char s[maxn], ans1[maxn], ans2[maxn];   int num[10];   int main() {     scanf( %s , s + 1);     int n = strlen(s + 1);     for (int i = 1; i <= n; i++) num[s[i] -  0 ]++;     int m = n;     int mx = 0, t1 = 0, t2 = 0;     for (int i = 1; i <= 5; i++) {       int t = 10 - i, now = 0;       if (!num[i] || !num[t]) continue;       int tn[10][2];       for (int j = 0; j <= 9; j++) tn[j][1] = tn[j][0] = num[j];       tn[i][1]--, tn[t][0]--;       for (int j = 0; j <= 9; j++) now += min(tn[j][1], tn[9 - j][0]);       if (now >= mx) {         t1 = i;         t2 = t;         mx = now;       }     }     int tn[10][2];     for (int j = 0; j <= 9; j++) tn[j][1] = tn[j][0] = num[j];     int pre = 0;     if (t1 || t2) {       pre = 1;       ans1[m] = t1 +  0 ;       ans2[m] = t2 +  0 ;       tn[t1][0]--;       tn[t2][1]--;       m--;     }     int flag = 0;     for (int i = m; i >= 1 + flag; i--) {       int OK = 0, f1 = 0, f2 = 0;       if (mx) {         mx--;         for (int j = 0; j <= 9; j++)           if (min(tn[j][0], tn[9 - j][1])) {             tn[j][0]--;             tn[9 - j][1]--;             f1 = j;             f2 = 9 - j;             ans1[i] = j +  0 ;             ans2[i] = 9 - j +  0 ;             OK = 1;             break;           }         pre = 1;       } else {         if (pre) {           int vis[10][2];           for (int j = 0; j <= 9; j++)             if (tn[j][0] && tn[9 - j][1]) vis[j][0] = vis[9 - j][1] = 1;           int ok = 0;           for (int j = 0; j <= 9; j++)             if (tn[j][0] && !vis[j][0]) {               f1 = j;               ans1[i] = j +  0 ;               ok++;               break;             }           for (int j = 0; j <= 9; j++)             if (tn[j][1] && !vis[j][1]) {               f2 = j;               ans2[i] = j +  0 ;               ok++;               break;             }           if (ok != 2) {             ok = 0;             for (int j = 0; j <= 9; j++)               if (tn[j][0]) {                 f1 = j;                 ans1[i] = j +  0 ;                 ok++;                 break;               }             for (int j = 0; j <= 9; j++)               if (tn[j][1]) {                 f2 = j;                 ans2[i] = j +  0 ;                 ok++;                 break;               }           }           tn[f1][0]--;           tn[f2][1]--;         } else {           int ok = 0;           for (int j = 0; j <= 9; j++) {             if (j == 0 && tn[j][0] && tn[j][1]) {               f1 = 0, f2 = 0, ok = 1, OK = 1;               tn[j][0]--, tn[j][1]--;               ans1[i] =  0 , ans2[i] =  0 ;               break;             } else if (j != 0 && tn[j][0] && tn[10 - j][1]) {               f1 = j, f2 = 10 - j, ok = 1, OK = 1;               tn[j][0]--, tn[10 - j][1]--;               ans1[i] = f1 +  0 , ans2[i] = f2 +  0 ;               break;             }           }           if (!ok) {             for (int j = 0; j <= 9; j++)               if (tn[j][0]) {                 tn[j][0]--;                 ans1[i] = j +  0 ;                 f1 = j;                 ok++;                 break;               }             for (int j = 0; j <= 9; j++)               if (tn[j][1]) {                 tn[j][1]--;                 ans2[i] = j +  0 ;                 f2 = j;                 ok++;                 break;               }           }           if (ok == 2) OK = 1;         }         pre = (f1 + f2 + 1 >= 10 ? 1 : 0);       }       if (f1 == 0 && f2 == 0) {         flag++;         i++;       }     }     printf( %s , ans1 + flag + 1);     for (int i = 1; i <= flag; i++) printf( 0 );     puts(  );     printf( %s , ans2 + flag + 1);     for (int i = 1; i <= flag; i++) printf( 0 );     return 0;   }