#include <bits/stdc++.h>   using namespace std;   int mx = 0;   string a, b;   string ba, bb;   int sum[123] = {};   void solve(int last) {     int cursum1[123];     int cursum2[123];     memcpy(cursum1, sum, sizeof sum);     memcpy(cursum2, sum, sizeof sum);     if (cursum1[last] == 0 || cursum2[(10 - last) % 10] == 0) {       int mn = min(cursum1[0], cursum2[0]);       if (mn == 0) return;       if (mn > mx) {         mx = mn;         sort(ba.begin(), ba.end(), greater<char>());         sort(bb.begin(), bb.end(), greater<char>());       }       return;     }     string na, nb;     string zero;     cursum1[last]--;     cursum2[(10 - last) % 10]--;     na += last +  0 ;     nb += ((10 - last) % 10) +  0 ;     int now = 1;     for (;;) {       bool fnd = false;       for (int put = 0; put <= 9; put++) {         int need = (9 - put) % 10;         if (cursum1[put] > 0 && cursum2[need] > 0) {           na += put +  0 ;           nb += need +  0 ;           cursum1[put]--;           cursum2[need]--;           fnd = true;           break;         }       }       if (fnd)         ++now;       else {         int mn = min(cursum1[0], cursum2[0]);         cursum1[0] -= mn;         cursum2[0] -= mn;         for (int i = 0; i < mn; i++) {           zero +=  0 ;         }         now += mn;         for (int put = 0; put <= 9; put++) {           for (int u = 0; u < cursum1[put]; u++) na += put +  0 ;         }         for (int put = 0; put <= 9; put++) {           for (int u = 0; u < cursum2[put]; u++) nb += put +  0 ;         }         break;       }     }     if (now > mx) {       mx = now;       reverse(na.begin(), na.end());       reverse(nb.begin(), nb.end());       ba = na + zero;       bb = nb + zero;     }   }   void solveAll(string& str) {     a = str;     memset(sum, 0, sizeof sum);     mx = 0;     for (int i = 0; i < a.size(); i++) sum[a[i] -  0 ]++;     ba = bb = a;     for (int last = 1; last <= 9; last++) {       solve(last);     }   }   int parse(const string& str) {     int ret = 0;     for (int i = 0; i < str.size(); i++) {       ret = ret * 10 + str[i] -  0 ;     }     return ret;   }   int count(int num) {     int ret = 0;     while (num) {       if (num % 10 == 0)         ++ret;       else         break;       num /= 10;     }     return ret;   }   void test() {     for (int i = 0; i < 1231; i++) {       string ran;       ran += (rand() % 9) + 1 +  0 ;       int len = rand() % 6;       ++len;       for (int u = 1; u < len; u++) {         ran += (rand() % 10) +  0 ;       }       solveAll(ran);       int mx1 = 0;       sort(ran.begin(), ran.end());       do {         string ran2 = ran;         sort(ran2.begin(), ran2.end());         do {           int num1 = parse(ran);           int num2 = parse(ran2);           num1 += num2;           int howmany = count(num1);           mx1 = max(mx1, howmany);         } while (next_permutation(ran2.begin(), ran2.end()));       } while (next_permutation(ran.begin(), ran.end()));       if (mx != mx1) {         cout << ran <<    wrong  << endl;         exit(0);       }     }     cout <<  OK  << endl;   }   int main() {     cin >> a;     solveAll(a);     cout << ba << endl << bb << endl;     return 0;   }