#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
#endif // DEBUG

	ios::sync_with_stdio(false);

	string x;
	cin >> x;
	vector<int> v1(10);
	int n = x.length();
	for (int i = 0; i < n; ++i)
	{
		v1[x[i] - '0']++;
	}
	auto v2 = v1;
	int lst = 0;
	int mf = -1;
	int mc = 0;
	string ans1, ans2;
	for (int f = 1; f <= 9; ++f)
	{
		if (!(v1[f] > 0 && v2[10 - f] > 0)) continue;
		int c = 0;
		auto tv1 = v1;
		auto tv2 = v2;
		tv1[f]--;
		tv2[10 - f]--;
		lst = 1;
		c++;

		while (true)
		{
			bool fl = true;
			for (int i = 0; i <= 9; ++i)
			{
				int a = i;
				int b = (10 - i - lst) % 10;
				while (tv1[a] > 0 && tv2[b] > 0)
				{
					c++;
					tv1[a]--;
					tv2[b]--;
					lst = (a + b + lst) / 10;
					fl = false;
					break;
				}
				if (!fl)
					break;
			}
			if (fl)
				break;
		}
		while (tv1[0] > 0 && tv2[0] > 0)
		{
			c++;
			tv1[0]--;
			tv2[0]--;
		}
		if (c > mc)
		{
			mc = c;
			mf = f;
		}
	}
	if (mf >= 0)
	{
		ans1.push_back(mf + '0');
		ans2.push_back(10 - mf + '0');
		v1[mf]--;
		v2[10 - mf]--;
		lst = 1;
	}
	else lst = 0;
	while (true)
	{
		bool fl = true;
		for (int i = 0; i <= 9; ++i)
		{
			int a = i;
			int b = (10 - i - lst) % 10;
			while (v1[a] > 0 && v2[b] > 0)
			{
				ans1.push_back(a + '0');
				ans2.push_back(b + '0');
				v1[a]--;
				v2[b]--;
				lst = (a + b + lst) / 10;
				fl = false;
				break;
			}
			if (!fl)
				break;
		}
		if (fl)
			break;
	}
	while (v1[0] > 0 && v2[0] > 0)
	{
		ans1 = '0' + ans1;
		ans2 = '0' + ans2;
		v1[0]--;
		v2[0]--;
	}

	for (int i = 0; i < 10; ++i)
		while (v1[i]--)
			ans1.push_back(i + '0');
	for (int i = 0; i < 10; ++i)
		while (v2[i]--)
			ans2.push_back(i + '0');
	reverse(ans1.begin(), ans1.end());
	reverse(ans2.begin(), ans2.end());
	cout << ans1 << endl << ans2;

	return 0;
}

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <numeric>
#include <unordered_map>
#include <random>

using namespace std;
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define INF (1LL << 31)
#define INFLL (ll)(1e18)
#define EPS 1e-9
#define MOD 1000000007

template<class T>
istream &operator>>(istream &is, vector<T> &a) {
    for (int i = 0; i < a.size(); ++i)
        is >> a[i];
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> a) {
    for (auto i:a)
        os << i << " ";
    return os;
}

int main() {
    string n;
    cin >> n;
    vector<int> cnt1(10, 0), cnt2(10, 0);
    for (char i:n) {
        ++cnt1[i - '0'];
        ++cnt2[i - '0'];
    }
    int ans = 0, ansi = -1, ansz = -1;
    for (int zerocol = 0; zerocol <= cnt1[0]; ++zerocol) {
        for (int i = 1; i < 10; ++i) {
            auto cnt1b = cnt1;
            auto cnt2b = cnt2;
            int cur = zerocol;
            cnt1b[0] -= zerocol;
            cnt2b[0] -= zerocol;
            if (cnt1[i] && cnt2[10 - i]) {
                --cnt1b[i];
                --cnt2b[10 - i];
                ++cur;
                for (int j = 0; j < 10; ++j) {
                    int col = min(cnt1b[j], cnt2b[9 - j]);
                    cnt1b[j] -= col;
                    cnt2b[9 - j] -= col;
                    cur += col;
                }
            }
            if (cur >= ans) {
                ans = cur;
                ansi = i;
                ansz = zerocol;
            }
        }
    }
    string ans1, ans2;
    cnt1[0] -= ansz;
    cnt2[0] -= ansz;
    for (int i = 0; i < ansz; ++i)
        ans1.push_back('0');
    for (int i = 0; i < ansz; ++i)
        ans2.push_back('0');
    if (cnt1[ansi]) {
        --cnt1[ansi];
        ans1.push_back(ansi + '0');
    }
    if (cnt2[10 - ansi]) {
        --cnt2[10 - ansi];
        ans2.push_back(10 - ansi + '0');
    }
    for (int i = 0; i < 10; ++i) {
        int col = min(cnt1[i], cnt2[9 - i]);
        cnt1[i] -= col;
        cnt2[9 - i] -= col;
        for (int j = 0; j < col; ++j) {
            ans1.push_back(i + '0');
            ans2.push_back(9 - i + '0');
        }
    }
    for (int i = 0; i < 10; ++i)
        while (cnt1[i]) {
            ans1.push_back(i + '0');
            --cnt1[i];
        }
    for (int i = 0; i < 10; ++i)
        while (cnt2[i]) {
            ans2.push_back(i + '0');
            --cnt2[i];
        }
    reverse(all(ans1));
    reverse(all(ans2));
    cout << ans1 << "\n" << ans2;
}

#include <bits/stdc++.h>

#define pb push_back
#define db double
#define int long long
#define all(c) (c).begin(), (c).end()
using namespace std;

const int N = 1e6 + 1;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;

inline int read () {
    char c = getchar();
    int t = 0, f = 1;
    while (!isdigit(c)) f = (c == '-') ? -1 : 1, c = getchar();
    while (isdigit(c)) t = t * 10 + c - 48, c = getchar();
    return t * f;
}
int cnt1[10], cnt2[10];
int cnt3[10], cnt4[10];
main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        cnt3[s[i] - 48] ++;
        cnt4[s[i] - 48] ++;
    }
    int mx = 0;
    int kx = 0, ky = 0;
    for(int i = 1; i < 10; i++) {
        int x = i, y = 10 - i;
        int d = 0;
        for(int i = 0; i < 10; i++) {
            cnt1[i] = cnt3[i];
            cnt2[i] = cnt4[i];
        }
        if(cnt1[x] && cnt2[y]) {
            cnt1[x]--;
            cnt2[y]--;
            d++;
            for(int j = 0; j <= 9; j++) {
                int t1 = j, t2 = 9 - j;
                if(cnt1[t1] && cnt2[t2]) {
                    int mn = min(cnt1[t1], cnt2[t2]);
                    cnt1[t1] -= mn;
                    cnt2[t2] -= mn;
                    d += mn;
                }
            }
            d += min(cnt1[0], cnt2[0]);
            if(mx < d) {
                mx = d;
                kx = x;
                ky = y;
            }
        }
    }
//    cout << mx << " " << kx << " " << ky << endl;
    if(mx) {
        int x = kx, y = ky;
        string ans1, ans2;
        for(int i = 0; i < 10; i++) {
            cnt1[i] = cnt3[i];
            cnt2[i] = cnt4[i];
        }
        if(cnt1[x] && cnt2[y]) {
            cnt1[x]--;
            cnt2[y]--;
            ans1 += (char)(x + 48);
            ans2 += (char)(y + 48);
            for(int j = 0; j <= 9; j++) {
                int t1 = j, t2 = 9 - j;
                if(cnt1[t1] && cnt2[t2]) {
                    int mn = min(cnt1[t1], cnt2[t2]);
                    cnt1[t1] -= mn;
                    cnt2[t2] -= mn;
                    for(int k = 1; k <= mn; k++) {
                        ans1 += (char)(t1 + 48);
                        ans2 += (char)(t2 + 48);
                    }
                }
            }
        }
//        cout << ans1 << " " << ans2 << endl;
        for(int i = 1; i < 10; i++) {
            for(int j = 1; j <= cnt1[i]; j++)
                ans1 += (char)(i + 48);
            for(int j = 1; j <= cnt2[i]; j++)
                ans2 += (char)(i + 48);
        }
        if(cnt1[0] < cnt2[0]) {
            for(int j = 1; j <= cnt2[0] - cnt1[0]; j++)
                ans2 += '0';
        }
        else {
            for(int j = 1; j <= cnt1[0] - cnt2[0]; j++)
                ans1 += '0';
        }
        reverse(all(ans1));
        reverse(all(ans2));
        for(int j = 1; j <= min(cnt1[0], cnt2[0]); j++)
            ans1 += '0', ans2 += '0';
//        for(int j = 1; j <= cnt2[0]; j++)
//            ans2 += '0';
        cout << ans1 << "\n" << ans2;
    }
    else {
        sort(s.rbegin(), s.rend());
        cout << s << "\n" << s;
    }
}
/*
5057017252180797906185
*/

    #include <bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;

    #define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long
    #define ld long double

    #define vi vector<int>
    #define vl vector<long>
    #define vll vector<long long>

    #define infi INT_MAX
    #define infl LONG_LONG_MAX
    #define infd LDBL_MAX
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
    #define F first
    #define S second
    #define G(a,b) get<a>(b)
    #define MP make_pair
    #define MT make_tuple
    #define pll pair<ll,ll>
    #define endl "\n"
    #define ALL(v) v.begin(),v.end()
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;
    #define deb printf("***************************************************************************************\n");
    #define moshi printf("moshi moshi ! \n");
    #define hi printf("hi ! \n");
    #define bye printf("bye bye ! \n");
    #define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define number_of_set_bits  __builtin_popcountll

    //template<typename T>
    //#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
    //member functions :
    //1. order_of_key(k) : number of elements strictly lesser than k
    //2. find_by_order(k) : k-th element in the set

    //const ll N=1e6+7;
    ll p=1e9+7;
    //ll fac[N];

    ll gcd(ll a, ll b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    inline ll ceil(ll a,ll b)
    {
      return (a+b-1)/b;
    }

    ll max(ll x,ll y,ll z)
    {
      return max(x,max(y,z));
    }

    ll modpro(ll x,ll y,ll z=1)
    {
      x%=p;
      y%=p;
      z%=p;
      ll res=(x*y)%p;
      res=(res*z)%p;
      return res;
    }

    ll modadd(ll x,ll y,ll z=0)
    {
      ll res=(x+y)%p;
      res=(res+z)%p;
      return res;
    }

    ll pow_mod_p(ll a,ll b)
    {
      a=a%p;
      ll res=1;
      while(b>0)
      {
        if(b&1) res=(res*a)%p;
        b=b>>1;
        a=(a*a)%p;
      }
      return res;
    }

    inline ll mod_inv(ll x)
    {
      return pow_mod_p(x,p-2);
    }

    /*
    ll nCr(ll x,ll y)
    {
      if(x<y) return 0;
      ll res=fac[x];
      ll den=(fac[y]*fac[x-y])%p;
      ll deni=mod_inv(den);
      res=(res*deni)%p;
      return res;
    }*/

    ll is_set(ll a,ll i)
    {
      if( ( a & ((ll)1<<i) ) == 0 ) return 0;
      else return 1;
    }

    //  Comparator should follow :
    //  1: x<=y or y<=x uniquely
    //  2: Transitivity : a<=b and b<=c implies a<=c
    //  3: Anti-Symmetry: a<=b and b<=a implies a=b
    // return 1 to put x before y in sorted order
    inline bool comp(pll &x,pll &y)
    {
        if(x.F<y.F) return 1;
        else if(x.F==y.F)
        {
            if(x.S>y.S) return 1;
            else return 0;
        }
        return 0;
    }

    struct custom_hash {
        static uint64_t splitmix64(uint64_t x) {
            // http://xorshift.di.unimi.it/splitmix64.c
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
    };

    // resize : str.resize(new_size)   new size <= old size

    // for Vector :
    // lower_bound(starting iterator , iterator next to end , value)  :  iterator to first element greater than or equal to value
    // upper_bound(starting iterator , iterator next to end , value)  :  iterator to first element strictly greater than value

    // For Set :      s.lower_bound(value)
    // if no such element exists they return  vector.end() or s.end()

    // x bits : [x-1 , x-2 , .... , 1(1st bit) , 0(0th bit)] =>   leftmost 1 at 2^(x-1)    max number that can be represented : 2^(x) -1
    // 63 bits is greater than 10^18

    // 1<<x  :  2 ^ x  (left shift)

    // Min heap :  priority_queue < ll , vector<ll>, greater<ll> > q
    // Max heap :  priority_queue < ll > q
    // Set in descending order  :   set< ll,greater <ll> >

    // While debugging :
    // 1 : check if array size is correct  :  It may give unexpected results
    // 2 : check if you have swapped i and j at some part of program
    // 3 : for string check if you are trying to acces  index = -1

    // Bitwise Tricks :
    // 1 : While using 1<<i  use (ll)1<<i  because in former one "1" is considered as int
    // 2 : To flip first k-bits of a number :  x xor (2^k-1)  or x ^ (((ll)1<<k)-1)  : 2^k-1 is the largest number of k bits
    // 3 : To flip k-th bit (0-based)  :  x xor (2^k)  or  x ^ ((ll)1<<k)
    // 4 : To set k-th bit (0-based)   :  x or (2^k)   or  x | ((ll)1<<k)
    // 5 : To un-set k-th bit (0-based)   :  x & (~ ((ll)1<<k) )

    // To prove Greedy :
    // 1 : Optimal Choice at each step
    // 2 : Exchange Argument
    // 3 : Find a lower or upper bound on answer and then construct an answer for that bound
    // 4 : Find properties which Optimal Solution must satisfy ( This can be useful to deduce form of Optimal answer)

    // Erase one occurrence in multiset : it=s.find(element)   s.erase(it)
    // putchar('a'+j) : to print (j+1)th character
    // getline(cin,str) : To input string until newline

    void lps(string &pp,ll *lps)
    {
       ll xx=pp.length();
       //ll lps[xx]={};
       f(i,1,xx)
       {
         ll j=lps[i-1];
         while(j>0 && pp[j]!=pp[i]) j=lps[j-1];
         if(pp[i]==pp[j]) j++;
         lps[i]=j;
       }
    }

    void func()
    {
       string s;
       cin>>s;

       ll cnt[10]={};
       ll n=s.length();
       f(i,0,n) cnt[s[i]-'0']++;

       ll ans=cnt[0];
       ll ind=-1;

       ll cntx[10],cnty[10];
       f(i,0,10) cntx[i]=cnty[i]=cnt[i];

       f(i,1,10)
       {
          if(cntx[i]>0 && cnty[10-i]>0)
          {
             cntx[i]--;
             cnty[10-i]--;

             ll tot=1;
             f(j,0,10) tot+=min(cntx[j],cnty[9-j]);

             tot+=min( cntx[0]-min(cntx[0],cnty[9]) , cnty[0]-min(cnty[0],cntx[9]) );

             if(tot>ans)
             {
                ind=i;
                ans=tot;
             }

             cntx[i]++;
             cnty[10-i]++;

          }
       }

       if(ind==-1)
       {

         f(tt,0,2)
         {
            f(i,1,10)
            {
              f(j,0,cnt[i]) pr(i)
            }

            f(j,0,cnt[0]) cout<<"0";

            nl
         }

         return;
       }

       vll pp,qq;
       cntx[ind]--;
       cnty[10-ind]--;

       f(j,0,10)
       {
         ll kk=min(cntx[j],cnty[9-j]);
         f(z,0,kk)
         {
            pp.pb(j);
            qq.pb(9-j);
            cntx[j]--;
            cnty[9-j]--;
         }
       }

       pp.pb(ind);
       qq.pb(10-ind);

       ll kk=min( cntx[0]-min(cntx[0],cnty[9]) , cnty[0]-min(cnty[0],cnty[9]) );
       f(i,0,kk)
       {
         pp.pb((ll)0);
         qq.pb((ll)0);
         cntx[0]--;
         cnty[0]--;
       }

       f(i,0,10)
       {
         f(j,0,cntx[i]) pr(i)
       }

       for(auto i:pp) pr(i)
       nl

       f(i,0,10)
       {
         f(j,0,cnty[i]) pr(i)
       }

       for(auto i:qq) pr(i)
        nl

    }

    int main()
    {
        //fast
        //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //#endif // ONLINE_JUDGE

        ll ntc=1;
        //cin>>ntc;

        f(i,1,ntc+1)
        {
          //cout<<"Case #"<<i<<": ";
          func();
        }

        return 0;
    }

// Problem : B. Digits Permutations
// Contest : Codeforces - Codeforces Beta Round #99 (Div. 1)
// URL : https://codeforces.com/problemset/problem/138/B
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define pf push_front

string s;
int x[10],y[10];

void solve(){
    cin>>s;
    for(auto i : s){
        x[i-'0']++;
        y[i-'0']++;
    }
    int idx = 0, mx = -1;
    for(int i=1;i<=9;i++){
        if(x[i] && y[10-i]){
            x[i]--, y[10-i]--;
            int sum = 0;
            for(int j=0;j<=9;j++) sum += min(x[j],y[9-j]);
            if(sum > mx){
                mx = sum;
                idx = i;
            }
            x[i]++, y[10-i]++;
        }
    }
    //cout<<idx<<endl;
    if(!idx){
        for(int i=9;i>=0;i--) while(x[i]--) cout<<i;
        cout<<endl;
        for(int i=9;i>=0;i--) while(y[i]--) cout<<i;
        return;
    }
    list<int> a,b;
    a.pf(idx);
    b.pf(10-idx);
    x[idx]--, y[10-idx]--;
    for(int i=0;i<=9;i++){
        int cnt = min(x[i],y[9-i]);
        for(int j=0;j<cnt;j++){
            a.pf(i);
            b.pf(9-i);
        }
        x[i] -= cnt, y[9-i] -= cnt;
    }
    int cnt = min(x[0],y[0]);
    for(int i=0;i<cnt;i++){
        a.pb(0);
        b.pb(0);
    }
    x[0] -= cnt, y[0] -= cnt;
    for(int i=9;i>=0;i--) while(x[i]--) a.pf(i);
    for(int i=9;i>=0;i--) while(y[i]--) b.pf(i);
    for(int i:a) cout<<i;
    cout<<endl;
    for(int i:b) cout<<i;
    cout<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int maxn = 1e5 + 7;
char str[maxn];
int sum[10][2];
int pa9[10];
int least[10][2];
vector<pii> G, S;
stack<int> Q1, Q2;
void print()
{
    while (least[0][0] > 0 && least[0][1] > 0)
        Q1.push(0), Q2.push(0), least[0][1]--, least[0][0]--;
    if (!G.empty())
    {
        // printf("%d %d\n", G[0].first, G[0].second);
        Q1.push(G[0].first);
        Q2.push(G[0].second);
    }
    for (int i = 0; i < 10; i++)
    {
        while (pa9[i] > 0)
        {
            Q1.push(i);
            Q2.push(9 - i);
            pa9[i]--;
        }
    }
    for (int i = 0; i < 10; i++)
    {
        while (least[i][0] > 0)
            Q1.push(i), least[i][0]--;
        while (least[i][1] > 0)
            Q2.push(i), least[i][1]--;
    }
    while (!Q1.empty())
        printf("%d", Q1.top()), Q1.pop();
    cout << endl;
    while (!Q2.empty())
        printf("%d", Q2.top()), Q2.pop();
}
int main()
{
    memset(sum, 0, sizeof(sum));
    memset(pa9, 0, sizeof(pa9));
    memset(least, 0, sizeof(least));
    scanf("%s", str);
    int l = strlen(str);
    // printf("%d\n", l);
    for (int i = 0; i < l; i++)
    {
        int id = str[i] - '0';
        sum[id][0]++, sum[id][1]++;
    }
    for (int i = 0; i < 5; i++)
        if (sum[i][0] > 0 && sum[9 - i][1] > 0)
            pa9[9 - i] = pa9[i] = min(sum[i][0], sum[9 - i][1]);
    // for (int i = 0; i < 10; i++)
    //     printf("%d ", pa9[i]);
    // cout << endl;
    for (int i = 0; i < 10; i++)
        least[i][1] = least[i][0] = max(0, sum[i][0] - pa9[i]);
    for (int i = 1; i < 10; i++)
        if (least[i][0] > 0 && least[10 - i][1] > 0)
        {
            G.push_back(make_pair(i, 10 - i)), least[i][0]--, least[10 - i][1]--;
            break;
        }
    // for (int i = 0; i < 10; i++)
    //     printf("i:%d 1:%d 2:%d\n", i, least[i][0], least[i][1]);
    // cout << endl;
    if (G.empty())
    {
        // printf("1\n");
        for (int i = 1; i < 10; i++)
            if (least[i][0] > 0 && pa9[10 - i] > 0)
            {
                // printf("%d %d\n", i, 10 - i);
                G.push_back(make_pair(i, 10 - i));
                // pa9[10 - i]--;
                pa9[i - 1]--;
                least[i - 1][0]++;
                least[i][0]--;
                break;
            }
    }
    // for (int i = 0; i < 10; i++)
    //     printf("i:%d 1:%d 2:%d\n", i, least[i][0], least[i][1]);
    // cout << endl;
    // for (int i = 0; i < 10; i++)
    //     printf("%d ", pa9[i]);
    // cout << endl;
    if (G.empty())
    {
        for (int i = 1; i < 10; i++)
        {
            if (pa9[i] > 0 && pa9[10 - i] > 0)
            {
                printf("2\n");
                G.push_back(make_pair(i, 10 - i));
                // pa9[i]--, pa9[10 - i]--;
                pa9[i]--, pa9[i - 1]--;
                least[9 - i][1]++, least[i - 1][0]++;
                break;
            }
        }
    }
    // for (int i = 0; i < 10; i++)
    //     printf("i:%d 1:%d 2:%d\n", i, least[i][0], least[i][1]);
    // cout << endl;
    // for (int i = 0; i < 10; i++)
    //     printf("%d ", pa9[i]);
    // cout << endl;
    print();
    return 0;
}

# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
#define debug(x) cout << #x << " => " << x << endl
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
//const int _p = 1007;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

string st,s="",t="",s0="",t0="";
int a[15],l=0,ans=0,p,x,b[15],c[15],b0[15],c0[15],yyy=0;

int main() {
    //file_put();

    cin>>st;
    l=st.length();
    for (int i=0; i<=l+10; i++) s+=' ';
    for (int i=0; i<l; i++) a[st[i]-'0']++;
    for (int i=1; i<=5; i++) {
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
        s="";
        t="";
        if (a[i]==0 || a[10-i]==0) continue;
        b[i]++;
        c[10-i]++;
        for (int j=0; j<=9; j++) {
            int k=min(a[j]-b[j],a[9-j]-c[9-j]);
            for (int e=1; e<=k; e++){
                s+=(j+'0');
                t+=(9-j+'0');
            }
            b[j]+=k;
            c[9-j]+=k;
        }
        s+=(i+'0');
        t+=(10-i+'0');
        int yy=min(a[0]-b[0],a[0]-c[0]);
        if (s.length()+yy>ans){
            ans=s.length()+yy;
            s0=s;
            t0=t;
            yyy=yy;
            for (int j=0; j<=9; j++) b0[j]=b[j];
            for (int j=0; j<=9; j++) c0[j]=c[j];
        }
    }
    for (int i=0; i<=9; i++) b0[i]=a[i]-b0[i];
    for (int i=0; i<=9; i++) c0[i]=a[i]-c0[i];
    b0[0]-=yyy;
    c0[0]-=yyy;
    for (int i=9; i>=0; i--) for (int j=1; j<=b0[i]; j++) printf("%d",i);
    cout<<s0;
    for (int i=1; i<=yyy; i++) printf("0");
    printf("\n");
    for (int i=9; i>=0; i--) for (int j=1; j<=c0[i]; j++) printf("%d",i);
    cout<<t0;
    for (int i=1; i<=yyy; i++) printf("0");
    printf("\n");
    //cout<<ans<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#undef _GLIBCXX_DEBUG

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true": "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << "\033[33;0m" << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename T>
void debug_out (T a[], int n) {
	cerr << "{" << to_string(a[0]);
	for (int i = 1; i < n; ++i) cerr << ", " << to_string(a[i]);
	cerr << "}";
	debug_out();
}

#define LOCAL

#ifdef LOCAL
#define dbg(...)  cerr << "\033[33;1m" << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

using LL = long long;
using PII = pair<int,int>;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x.size()))
#define sqr(x) ((x)*(x))

LL powmod (LL a, LL b, LL MOD) {
	LL ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return ans % MOD;
}
const int N = 100005, MOD = 1e9+7, INF = 1e9;

// head

//your code goes there

string s, ansS, ansT;
int cnt1[10], cnt2[10], cnt[10];
void init () {
	cin >> s;
	for (int i = 0; i < SZ(s); ++i) cnt[s[i]-'0']++;
}

void work () {
	for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
	int Sum = 0, S;
	for (int i = 0; i < 10; ++i) {
		while (cnt1[i]) --cnt1[i], ansS.push_back(i+'0');
		while (cnt2[i]) --cnt2[i], ansT.push_back(i+'0');
	}
	for (int ed = 1; ed <= 9; ++ed) {
		int p1 = ed, p2 = (10-p1)%10;
		S = 0;
		string nowS, nowT;
		for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
		if (cnt1[p1] and cnt2[p2]) {
			nowS.push_back(p1+'0');
			nowT.push_back(p2+'0');
			cnt1[p1]--;
			cnt2[p2]--;
			++S;
		} else {
			continue;
		}
		for (int d = 0; d <= 9; ++d) {
			p1 = d, p2 = (9-d);
			while (cnt1[p1] and cnt2[p2]) {
				nowS.push_back(p1+'0');
				nowT.push_back(p2+'0');
				cnt1[p1]--;
				cnt2[p2]--;
				++S;
			}
			swap (p1, p2);
			while (cnt1[p1] and cnt2[p2]) {
				nowS.push_back(p1+'0');
				nowT.push_back(p2+'0');
				cnt1[p1]--;
				cnt2[p2]--;
				++S;
			}
		}
		for (int i = 0; i < 10; ++i) {
			while (cnt1[i]) --cnt1[i], nowS.push_back(i+'0');
			while (cnt2[i]) --cnt2[i], nowT.push_back(i+'0');
		}
		if (S > Sum) ansS = nowS, ansT = nowT, Sum = S;
		//cout << "D = " << ed << " " << S << endl;
	}
	S = 0;
	int qwq = -1, id = -1, Max = 0;
	dbg(cnt, 10);
	for (int i = 1; i <= 9; ++i) {
		S += min(cnt[i], cnt[9-i]);
		if (cnt[i] > cnt[9-i] and cnt[10-i] > cnt[9-(10-i)] and i != 1) qwq = i;
		else if (cnt[9-i] > cnt[i] and cnt[10-(9-i)] > cnt[9-(10-(9-i))]) qwq = 9-i;
	}
	if (cnt[5] > cnt[4]) qwq = 5;
	if (qwq == -1) {
		for (int i = 1; i <= 4; ++i) {
			if (cnt[i] > cnt[9-i] and cnt[10-i]) qwq = i;
			else if (cnt[9-i] > cnt[i] and cnt[10-(9-i)]) qwq = 9-i;
		}
		if (qwq != -1) S--;
	}
	for (int p = 1; p <= cnt[0]; ++p) {
		int now = S;
		if (qwq != -1) {
			now = now + p + min(cnt[9],cnt[0]-p) + 1;
		} else {
			now = now + p + min(cnt[9],cnt[0]-p);
		}
		if (now > Max) Max = now, id = p;
	}
	dbg(S);
	dbg(qwq);
	if (Max > Sum and qwq != -1) {
		string nowS, nowT;
		for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
		for (int d = 1; d <= id; ++d) {
			nowS.push_back('0');
			nowT.push_back('0');
			cnt1[0]--, cnt2[0]--;
		}
		if (qwq != -1) {
			assert(qwq != 0);
			assert(qwq != 9);
			assert(qwq != 10);
			nowS.push_back(qwq+'0');
			nowT.push_back(10-qwq+'0');
			cnt1[qwq]--, cnt2[10-qwq]--;
		}
		for (int d = 0; d <= 9; ++d) {
			int p1 = d, p2 = (9-d);
			while (cnt1[p1] and cnt2[p2]) {
				nowS.push_back(p1+'0');
				nowT.push_back(p2+'0');
				cnt1[p1]--;
				cnt2[p2]--;
				++S;
			}
			swap (p1, p2);
			while (cnt1[p1] and cnt2[p2]) {
				nowS.push_back(p1+'0');
				nowT.push_back(p2+'0');
				cnt1[p1]--;
				cnt2[p2]--;
				++S;
			}
		}
		for (int i = 0; i < 10; ++i) {
			while (cnt1[i]) --cnt1[i], nowS.push_back(i+'0');
			while (cnt2[i]) --cnt2[i], nowT.push_back(i+'0');
		}
		ansS = nowS, ansT = nowT;
		Sum = Max;
	}
	dbg(Max);
	reverse(ansS.begin(),ansS.end());
	reverse(ansT.begin(),ansT.end());
	cout << ansS << "\n" << ansT << endl;
}
int main () {
	time_t tic = clock();
	int T = 1;
	//scanf("%d",&T);
	while (T--) {
		init ();
		work ();
	}
	time_t toc = clock();
	cerr << "execute time = " << (toc-tic) / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <bitset>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <sys/time.h>
using namespace std;
#define li        long long int
#define rep(i,to) for(int i=0;i<((int)(to));++i)
#define pb        push_back
#define sz(v)     ((li)(v).size())
#define bit(n)    (1ll<<(li)(n))
#define all(vec)  (vec).begin(),(vec).end()
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define MP        make_pair
#define F         first
#define S         second

li cnt[2][10];
string s0, s1;

li recur(li num0, li num1){
	if(num0 == 10) return 0;
	li mini = min(cnt[0][num0], cnt[1][num1]);
	cnt[0][num0] -= mini;
	cnt[1][num1] -= mini;
	s0 += string(mini, '0' + num0);
	s1 += string(mini, '0' + num1);
	return recur(num0 + 1, num1 - 1) + mini;
}

int main(){
	string a;
	cin >> a;
	sort(all(a));
	reverse(all(a));
	li best = 0;
	pair<string,string> res = MP(a, a);

	for(li num0 = 1; num0 <= 5; num0++){
		li num1 = 10 - num0;
		rep(i, 10) cnt[0][i] = cnt[1][i] = count(all(a), '0' + i);
		cnt[0][num0]--;
		cnt[1][num1]--;
		if(0 <= cnt[0][num0] && 0 <= cnt[1][num1]){
			s0 = string(1, '0' + num0);
			s1 = string(1, '0' + num1);
			li t = recur(0, 9);
			li mini = min(cnt[0][0], cnt[1][0]);
			t += mini + 1;
			s0 = string(mini, '0') + s0;
			s1 = string(mini, '0') + s1;
			cnt[0][0] -= mini;
			cnt[1][0] -= mini;
			rep(i, 10) s0 += string(cnt[0][i], '0' + i);
			rep(i, 10) s1 += string(cnt[1][i], '0' + i);
			if(best < t){
				best = t;
				reverse(all(s0));
				reverse(all(s1));
				res = MP(s0, s1);
			}
		}
		cnt[0][num0]++;
		cnt[1][num1]++;
	}
	cout << res.F << endl << res.S << endl;
}

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
#define pb push_back
#define fap(x) cout << __LINE__ << " says: " << #x << " = " << x << "\n"

const int D = 10;
int c1[D], c2[D];
int c[D];
int n;

int zpair[D][D];

int zeroCount(int x, int y) {
    if(x + y < D) return 0;

    int ret = 0, done = 0;
    --c1[x], --c2[y];
    ++done;
    if(x + y == D) ++ret;

    for(int i=0; i<D; ++i) {
        int cur = min(c1[i], c2[D-1-i]);
        c1[i] -= cur;
        c2[D-1-i] -= cur;
        ret += cur;
        done += cur;
        // if(cur) fap(i), fap(D-1-i);
    }

    // fap(done), fap(ret);

    int mzero = min(c1[0], c2[0]);
    c1[0] -= mzero;
    c2[0] -= mzero;
    done += mzero;
    ret += mzero;

    return ret;
}

vector<pii> permute(int x, int y) {
    vector<pii> ret;
    int done = 0;
    --c1[x], --c2[y];
    ret.pb({x, y});
    ++done;

    for(int i=0; i<D; ++i) {
        int cur = min(c1[i], c2[D-1-i]);
        c1[i] -= cur;
        c2[D-1-i] -= cur;
        done += cur;
        for(int k=0; k<cur; ++k) ret.pb({i, D-1-i});
    }

    int mzero = min(c1[0], c2[0]);
    c1[0] -= mzero;
    c2[0] -= mzero;
    done += mzero;

    vector<pii> temp(mzero, pii(0, 0));
    for(auto &x : ret) temp.pb(x);
    ret = temp;

    vector<int> v1, v2;
    for(int i=0; i<D; ++i) {
        while(c1[i]) {
            v1.pb(i);
            --c1[i];
        }
        while(c2[i]) {
            v2.pb(i);
            --c2[i];
        }
    }
    for(int i=0; i<(int) v1.size(); ++i) {
        ret.pb({v1[i], v2[i]});
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s;
    cin >> s;
    n = (int) s.size();
    for(char ch : s) ++c[ch-'0'];

    pii st(-1, -1);
    int tot = -1;

    for(int i=1; i<D; ++i) {
        for(int j=1; j<D; ++j) {
            for(int k=0; k<D; ++k) c1[k] = c2[k] = c[k];

            if(!c1[i] or !c2[j]) continue;

            int zer = zeroCount(i, j);
            // cout << "for " << i << " " << j << ": " << zer << "\n";
            if(zer > tot) {
                tot = zer;
                st = make_pair(i, j);
            }
        }
    }

    // fap(st.first), fap(st.second);

    for(int k=0; k<D; ++k) c1[k] = c2[k] = c[k];
    auto res = permute(st.first, st.second);
    reverse(res.begin(), res.end());
    for(auto &x : res) cout << x.first;
    cout << "\n";
    for(auto &x : res) cout << x.second;
    cout << "\n";

    return 0;
}

// This bitch -_~

#include <bits/stdc++.h>
#define MAX 500005
#define ll long long
#define MOD 1000000007
#define s(x) scanf("%d", &x);

using namespace std;

int cnt[100],cnt1[100],cnt2[100],c[100];
vector<int> ans1,ans2;
int ansv;
int c1[100],c2[100];

int main() {
    string str;
    int s,bst,ans;
    cin>>str;
    for (int i = 0; i < str.size(); i++) {
        cnt[str[i]-48]++;
    }

    ansv = -1;
    ans = cnt[0];
    bst = ans;

    for (int zeros = 0; zeros <= cnt[0]; zeros++) {
        for (int pp = 0; pp <= 9; pp++) {
            for (int i = 0; i <= 9; i++)
                c1[i] = c2[i] = cnt[i];
            c1[0]-=zeros;
            s = zeros;
            if (c1[pp] == 0 || c2[10-pp] == 0)continue;

            c1[pp]--;
            c2[10-pp]--;

            for (int i = 0; i <= 9; i++)
                s+=min(c1[i],c2[9-i]);
            s++;

            if (s > bst) {
                bst = s;
                ans = zeros;
                ansv = pp;
            }
        }
    }

    for (int i = 0; i <= 9; i++)
        cnt1[i] = cnt2[i] = cnt[i];

    for (int i = 0; i < ans; i++) {
        ans1.push_back(0);
        ans2.push_back(0);
        --cnt1[0];
        --cnt2[0];
    }

    if (ansv!=-1) {
        ans1.push_back(ansv);
        --cnt1[ansv];
        ans2.push_back(10-ansv);
        --cnt2[10-ansv];
    }

    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j < min(cnt1[i],cnt2[9-i]); j++) {
            ans1.push_back(i);
            ans2.push_back(9-i);
        }
        int q = min(cnt1[i],cnt2[9-i]);
        for (int j=0; j < q; j++) {
            --cnt1[i];
            --cnt2[9-i];
        }

    }

    for (int i=0; i <= 9; i++)
        for (int j=0; j < cnt1[i]; j++)
            ans1.push_back(i);

    for (int i = 0; i <= 9; i++)
        for (int j = 0; j < cnt2[i]; j++)
            ans2.push_back(i);

    reverse(ans1.begin(),ans1.end());
    reverse(ans2.begin(),ans2.end());

    for (int i = 0 ; i < ans1.size(); i++)
        cout<<ans1[i];
    cout<<endl;

    for (int i = 0; i < ans2.size(); i++)
        cout<<ans2[i];
    cout<<endl;

    return 0;
}

#include <cstdint>
#include <algorithm>
#include <numeric>
#include <iostream>
using namespace std;

template<typename T, typename U>
static constexpr void maximize(T &t, const U &u) noexcept(noexcept(u > t ? (void)(t = u) : (void)(0))) {
    if (u > t)
        t = u;
}

static inline void print_digit(const uint_fast8_t d) {
    cout << static_cast<char>('0' + d);
}

struct V {
    uint_fast32_t k1[10];
    uint_fast32_t k2[10];
    uint_fast32_t s9[10];
    uint_fast8_t b;
    uint_fast32_t z;
    uint_fast32_t t;

    V(const uint_fast32_t (&k)[10]) noexcept {
        copy_n(k, 10, k1);
        copy_n(k, 10, k2);
        fill_n(s9, 10, 0);
        b = 0;
        z = min(k1[0], k2[0]);
        k1[0] -= z;
        k2[0] -= z;
        t = z;
    }

    V(const uint_fast32_t (&k)[10], const uint_fast8_t x) noexcept {
        copy_n(k, 10, k1);
        copy_n(k, 10, k2);
        fill_n(s9, 10, 0);
        b = x;
        k1[b]--;
        k2[10-b]--;
        for (uint_fast8_t d = 0; d < 10; d++) {
            s9[d] = min(k1[d], k2[9-d]);
            k1[d] -= s9[d];
            k2[9-d] -= s9[d];
        }
        z = min(k1[0], k2[0]);
        k1[0] -= z;
        k2[0] -= z;
        t = accumulate(s9, s9 + 10, static_cast<uint_fast32_t>(0)) + 1 + z;
    }

    void print() const {
        for (uint_fast8_t d = 0; d < 10; d++)
            for (uint_fast32_t i = 0; i < k1[d]; i++)
                print_digit(d);
        if (b) {
            for (uint_fast8_t d = 0; d < 10; d++)
                for (uint_fast32_t i = 0; i < s9[d]; i++)
                    print_digit(d);
            print_digit(b);
        }
        for (uint_fast32_t i = 0; i < z; i++)
            print_digit(0);

        cout << '\n';

        for (uint_fast8_t d = 0; d < 10; d++)
            for (uint_fast32_t i = 0; i < k2[d]; i++)
                print_digit(d);
        if (b) {
            for (uint_fast8_t d = 0; d < 10; d++)
                for (uint_fast32_t i = 0; i < s9[d]; i++)
                    print_digit(static_cast<uint_fast8_t>(9u-d));
            print_digit(static_cast<uint_fast8_t>(10u-b));
        }
        for (uint_fast32_t i = 0; i < z; i++)
            print_digit(0);
    }
};

static constexpr bool operator >(const V &v1, const V &v2) noexcept {
    return v1.t > v2.t;
}

static char n[100'000 + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    uint_fast32_t k[10] = {};

    cin >> n;
    for (const char *d = n; *d; d++) {
        k[*d - '0']++;
    }

    V m(k);

    for (uint_fast8_t x = 1; x < 10; x++) {
        if (k[x] && k[10-x])
            maximize(m, V(k, x));
    }

    m.print();
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;

#define	sqr(a)		((a)*(a))
#define	rep(i,a,b)	for(int i=(a);i<(int)(b);i++)
#define	per(i,a,b)	for(int i=((a)-1);i>=(int)(b);i--)
#define	PER(i,n)	per(i,n,0)
#define	REP(i,n)	rep(i,0,n)
#define	clr(a)		memset((a),0,sizeof (a))
#define	SZ(a)		((int)((a).size()))
#define	ALL(x)		x.begin(),x.end()
#define	mabs(a)		((a)>0?(a):(-(a)))
#define	inf			(0x7fffffff)
#define	eps			1e-6

#define	MAXN
#define MODN		1000000007

int fun(int* a,int* b)
{
	int ret = 0;
	for (int i = 0;i <= 9;i++)
	{
		ret += min(a[i],b[9 - i]);
	}
	return ret;
}

int main()
{
	string s;
	int a[11];
	int b[11];
	clr(a);
	clr(b);
	cin>>s;
	int len = s.length();
	for (int i = 0;i < len;i++)
	{
		a[s[i] - '0']++;
		b[s[i] - '0']++;
	}

	int res = -1;
	int resi = -1;
	for (int i = 1;i <= 5;i++)
	{
		if (a[i] > 0 && b[10 - i] > 0)
		{
			a[i]--;
			b[10 - i]--;
			int temp = fun(a,b);
			if (temp > res)
			{
				res = temp;
				resi = i;
			}
			a[i]++;
			b[10 - i]++;
		}
	}
	if (res == -1)
	{
		string x = "";
		string y = "";
		for (int i = 9;i >= 0;i--)
		{
			for (int j = 0;j < a[i];j++)
			{
				x += i + '0';
				y += i + '0';
			}
		}
		cout<<x<<endl<<y<<endl;
		return 0;
	}

	a[resi]--;
	b[10 - resi]--;
	string x = "";
	string y = "";
	string zero = "";
	if (a[0] > b[9])
	{
		int t = min(a[0] - b[9],b[0] - a[9]);
		if (t > 0)
		{
			REP(i,t)
			{
				zero += '0';
			}
			a[0] -= t;
			b[0] -= t;
		}

	}
	for (int i = 0;i <= 9;i++)
	{
		if (a[i] > b[9 - i])
		{
			int t = a[i] - b[9 - i];
			REP(j,t)
			{
				x += i + '0';
			}
			a[i] -= t;
		}
		else if (a[i] < b[9 - i])
		{
			int t = b[9 - i] - a[i];
			REP(j,t)
			{
				y += (9 - i) + '0';
			}
			b[9 - i] -= t;
		}
	}

	for (int i = 0;i <= 9;i++)
	{
		int r = min(a[i],b[9 - i]);
		for (int j = 0;j < r;j++)
		{
			x += i + '0';
			y += (9 - i) + '0';
		}
	}
	x += resi + '0';
	y += (10 - resi) + '0';
	x += zero;
	y += zero;

	cout<<x<<endl<<y<<endl;

	return 0;
}

#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <math.h>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int func(vector <int> c1, vector <int> c2, string &s, string &t)
{
	int c = 0;
	for (int i = 0; i <= 9; i++)
	{
		while(c1[i] > 0 && c2[9 - i] > 0)
		{
			c1[i]--;
			c2[9 - i]--;
			s += (char)(i + '0');
			t += (char)(9 - i + '0');
			c++;
		}
	}
	for (int i = 0; i <= 9; i++)
	{
		while(c1[i]--)
		{
			s += (char)(i + '0');
		}
		while(c2[i]--)
		{
			t += (char)(i + '0');
		}
	}
	return c;
}
int main()
{
	string in;
	cin >> in;
	int n = (int) in.size();
	vector <int> c1(10), c2(10);
	for (int i = 0; i < n; i++)
	{
		c1[in[i] - '0']++;
		c2[in[i] - '0']++;
	}
	vector <int> t1(c1), t2(c2);
	string ps, pt;
	int res = -1;
	for (int i = 1; i <= 9; i++)
	{
		int ans = -1;
		string s, t;
		if(c1[i] > 0 && c2[10 - i] > 0)
		{
			c1[i]--;
			c2[10 - i]--;
			int zeros = max(c1[0] - c2[9], 0);
			ans = (zeros + 1);
			while(zeros--)
			{
				s += '0';
				t += '0';
				c1[0]--;
				c2[0]--;
			}
			s += (char) ('0' + i);
			t += (char) ('0' + 10 - i);
			ans += func(c1, c2, s, t);
		}
		if(ans > res)
		{
			res = ans;
			ps = s;
			pt = t;
		}
		c1 = t1;
		c2 = t2;
	}
	if(res == -1)
	{
		while(c1[0] > 0)
		{
			ps += '0';
			pt += '0';
			c1[0]--;
			c2[0]--;
		}
		for (int i = 0; i <= 9; i++)
		{
			while(c1[i]--)
			{
				ps += (char)(i + '0');
			}
			while(c2[i]--)
			{
				pt += (char)(i + '0');
			}
		}
	}

	reverse(all(ps));
	reverse(all(pt));
	cout << ps << "\n" << pt << "\n";
}

#pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;

const int inf = 0x3f3f3f3f;

int n, a[10], b[10], j, ans;
string s, t1, t2;

int calc() {
	int res = 0;
	for (int i = 0; i < 10; i++)
		res += min(a[i], b[9 - i]);
	return res;
}

int main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++)
		a[s[i] - '0'] ++, b[s[i] - '0'] ++;
	ans = a[0];
	for (int i = 1; i < 10; i++) {
		if (a[i] && b[10 - i]) {
			a[i] --;
			b[10 - i] --;
			int res = 1 + calc() + min(b[0] - min(b[0], a[9]), a[0] - min(a[0], b[9]));
			if (res > ans)
				ans = res, j = i;
			a[i] ++;
			b[10 - i] ++;
		}
	}
	if (ans != a[0]) {
		a[j] --;
		b[10 - j] --;
	}
	int cnt0 = min(b[0] - min(b[0], a[9]), a[0] - min(a[0], b[9]));
	a[0] -= cnt0;
	b[0] -= cnt0;
	for (int i = 0; i < cnt0; i++) {
		t1 += '0';
		t2 += '0';
	}
	if (ans != a[0] + cnt0) {
		t1 = char(j + '0') + t1;
		t2 = char(10 - j + '0') + t2;
	}
	for (int i = 0; i < 10; i++) {
		int cnti = min(a[i], b[9 - i]);
		for (int k = 0; k < cnti; k++) {
			t1 = char(i + '0') + t1;
			t2 = char(9 - i + '0') + t2;
		}
		a[i] -= cnti;
		b[9 - i] -= cnti;
	}
	for (int i = 0; i < 10; i++) {
		for (int k = 0; k < a[i]; k++)
			t1 = char(i + '0') + t1;
		for (int k = 0; k < b[i]; k++)
			t2 = char(i + '0') + t2;
	}
	cout << t1 << endl << t2 << endl;
	return 0;
}

//http://codeforces.com/problemset/problem/144/D

#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <malloc.h>
#include <ctype.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <set>
#include <map>

using namespace std;

int has[20];
int has2[20];
int has3[20];
char str[100010];

char str1[100010];
char str2[100010];
int main()
{
	scanf("%s",str);
	memset(has,0,sizeof has);
	for(int i=0;str[i];i++)
	{
		str1[i]=str2[i]=str[i];
		has[str[i]-'0']++;
	}
	int len=strlen(str);
	str1[len]=str2[len]=0;
	//cout<<a<<endl;
	for(int i=0;i<20;i++)
	{
		has2[i]=has[i];
		has3[i]=has[i];
	}
	int ans=0;
	int num=0;
	int flag=-1;
	for(int i=1;i<=9;i++)
	{//找另一个加和为 10的  当最后一个
		num=0;
		if(has[i]&&has2[10-i])
		{
			has[i]--;
			has2[10-i]--;
			num++;
			int tem;

			for(int j=0;j<=9;j++)
			{
				tem=min(has[j],has2[9-j]);
				num+=tem;
				has[j]-=tem;
				has2[9-j]-=tem;
			}

			tem=min(has[0],has2[0]);

			num+=tem;
			has[0]-=tem;
			has2[0]-=tem;
		}
		//ans=max(ans,num);
		if(ans<num)
		{
			ans=num;
			flag=i;
		}

		for(int j=0;j<20;j++)
		{
			has2[j]=has3[j];
			has[j]=has3[j];
		}
	}

	ans=max(ans,has[0]);
	int t1,t2;
	t1=t2=len-1;
	str1[len]=str2[len]=0;
	if(flag!=-1)//凑 10  然后 凑 0 然后 凑其他
	{
		str1[t1--]=flag+'0';
		str2[t2--]=10-flag+'0';
		has[flag]--;
		has2[10-flag]--;

		for(int i=0;i<=9;i++)
		{
			int tem=min(has[i],has2[9-i]);
			has[i]-=tem;
			has2[9-i]-=tem;
			int tt=tem;
			while(tt--)
			{
				str1[t1--]=i+'0';
				str2[t2--]=9-i+'0';
			}
		}
	}

	int ling=0;
	ling=min(has[0],has2[0]);
	has[0]-=ling;
	has2[0]-=ling;

	for(int i=0;i<=9;i++)
	{
		while(has[i]--)
			str1[t1--]=i+'0';
		while(has2[i]--)
			str2[t2--]=i+'0';
	}

	//printf("%s\n%s\n",str1+ling,str2+ling);
	printf("%s",str1+ling);
	int tt=ling;
	while(tt--)
		printf("0");
	puts("");

	printf("%s",str2+ling);
	while(ling--)
		printf("0");
	puts("");

	return 0;
}

#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#define INFY 1000000000
#define MAXN 100010
using namespace std;

char a[MAXN];
char r1[MAXN];
char r2[MAXN];
int num[10];
int num2[10];

/*vector <char> r1;
vector <char> r2;*/

int main(){
    int n, i, j, k, x=-1, n0, y=0;
    scanf("%s", &a);
    n = strlen(a);
    if(n==1){
        cout<<a<<endl<<a;
        return 0;
    }
    for(i=0 ; i<n ; i++){
        num[a[i]-'0']++;
    }
    for(i=0 ; i<10 ; i++){
        num2[i]=num[i];
    }
    int m = 0;
    for(n0=0; n0<=num[0]; n0++){
        num[0]-=n0;
        num2[0]-=n0;
        for(i=1; i<=5; i++) if(num[i]>0 && num2[10-i]>0){
            num[i]--;num2[10-i]--;
            k = 1+n0;
            for(j=0; j<=9; j++){
                k+= min(num[j], num2[9-j]);
            }
            num[i]++;num2[10-i]++;
            if(m<k){
                x = i;
                y = n0;
                m = k;
            }
        }
        num[0]+=n0;
        num2[0]+=n0;
    }
        int run1 = n-1;
        int run2 = n-1;

        for(i=0; i<y; i++) {
            r1[run1]= '0';
            r2[run2] = '0';
            run1--;
            run2--;
        }
        num[0] -= y;
        num2[0] -= y;

        if(x>=0){
            r1[run1] = x+'0';
            r2[run2] = 10-x+'0';
            run1--;
            run2--;
            num[x]--;
            num2[10-x]--;
            for(j=0; j<=9; j++){
                while(num[j]>0 && num2[9-j]>0){
                    r1[run1] = j+'0';
                    r2[run2] = 9-j+'0';
                    run1--;
                    run2--;
                    num[j]--;
                    num2[9-j]--;
                }
            }
        }

        for(i=0; i<=9; i++){
            while(num[i]>0) {
                r1[run1] = i+'0';
                run1--;
                num[i]--;
            }
            while(num2[i]>0) {
                r2[run2] = i+'0';
                run2--;
                num2[i]--;
            }
        }
    r1[n] = 0;
    r2[n] = 0;
    for(i=0; i<n; i++) printf("%c", r1[i]);
    printf("\n");
    for(i=0; i<n; i++) printf("%c", r2[i]);
    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

#define clr(p) memset(p,0,sizeof(p))
#define Min(x,y) (x)>(y)?(y):(x)
const int maxn = 100010 ;

char s[maxn];
int a[maxn],b[maxn],aa[maxn],bb[maxn];
int cnt[13],len,cc,flag,cn[13],ans;
int acnt[13],acn[13];

void solve()
{
    int ca;
    for(int i=0;i<10;i++)
    {
        if(acnt[i] && acn[9-i])
        {
            int tmp=Min(acnt[i],acn[9-i]);
            for(int j=0;j<tmp;j++)
            {
                aa[cc]=i;bb[cc]=9-i;
                cc++;
            }
            acnt[i]-=tmp;
            acn[9-i]-=tmp;
        }
    }
    int kk=cc;
    ca=cc;
    for(int i=0;i<10;i++) if(acnt[i]) for(int j=0;j<acnt[i];j++) aa[kk++]=i;
    for(int i=0;i<10;i++) if(acn[i]) for(int j=0;j<acn[i];j++) bb[cc++]=i;
    if(ca>ans)
    {
        for(int i=0;i<len;i++)
        {
            a[i]=aa[i];
            b[i]=bb[i];
        }
        ans=ca;
    }
}

int main()
{
    int uu,vv;
    gets(s);
    len=strlen(s);
    clr(cnt);
    clr(cn);
    for(int i=0;i<len;i++)
    {
        cnt[s[i]-'0']++;
        cn[s[i]-'0']++;
    }
    cc=vv=0;
    flag=0;
    if(cnt[0]>cnt[9])
    {
        for(int i=0;i<cnt[0]-cnt[9];i++)
            aa[i]=bb[i]=0;
        cc=cnt[0]-cnt[9];
        uu=cc;
        cnt[0]=cnt[9];
        cn[0]=cn[9];
        flag=1;
    }
    ans=-1;
    for(int i=1;i<=5;i++)
    {
        if(cnt[i] && cn[10-i])
        {
            vv=1;
            for(int i=0;i<10;i++)
            {
                acnt[i]=cnt[i];
                acn[i]=cn[i];
            }
            if(flag) cc=uu;
            else cc=0;
            aa[cc]=i;bb[cc]=10-i;
            acnt[i]--;acn[10-i]--;
            cc++;
            solve();
        }
    }
    if(vv==0)
    {
        int kk=cc;
        for(int i=0;i<10;i++) if(cnt[i]) for(int j=0;j<cnt[i];j++) a[kk++]=i;
        for(int i=0;i<10;i++) if(cn[i]) for(int j=0;j<cn[i];j++) b[cc++]=i;
    }
/*  if(flag==0 && cnt[5])
    {
        aa[cc]=bb[cc]=5;
        cc++;
        cnt[5]--;
        cn[5]--;
    }*/
    for(int i=len-1;i>=0;i--) printf("%d",a[i]); puts("");
    for(int i=len-1;i>=0;i--) printf("%d",b[i]); puts("");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
const int maxn = 1e5+7;

char str[maxn];

int ar[10];
int br[10];
int aar[10];
int bbr[10];
int main()
{
    cin>>str;
    int cnt = 0;
    vector<int> s,t;
    int pp ;
    int len = strlen(str);
    for(int i = 0 ; i < len ; i++)
    {
        aar[str[i]-'0']++;
        bbr[str[i]-'0']++;
    }
    // cout<<"fdas";
    for(int i = 0 ; i < 10 ; i++)
    {
        int j = 10 - i;
        if(aar[i] > 0 && bbr[j] > 0)
        {
            for(int i = 0 ; i < 10 ; i++) ar[i] = aar[i],br[i] = bbr[i];
            vector<int> ans, ans1;
            ans.push_back(i);
            ans1.push_back(j);
            ar[i]--;
            br[j]--;
            for(int i = 0 ; i < 10 ;)
            {
                //   cout<<"fdas";
                if(ar[i] > 0 && br[9 - i] > 0)
                {
                    ans.push_back(i);
                    ans1.push_back(9-i);
                    ar[i]--;
                    br[9-i]--;
                }
                else
                {
                    i++;
                }
            }
            int cc = min(ar[0], br[0]);
            ar[0] -= cc;
            br[0] -= cc;
            if(cc + ans.size() > cnt)
            {
                cnt = cc+ans.size();
                for(int i = 0 ; i < 10 ; i++)
                {
                    while(ar[i] > 0) ans.push_back(i), ar[i]--;
                }
                // for(int i = 0 ; i < 10 ; i++ ) cout<<br[i]<<" ";
                for(int i = 0 ; i < 10 ; i++)
                {
                    while(br[i] > 0) ans1.push_back(i),br[i]--;
                }
                pp = cc;
                s = ans;
                t = ans1;
            }
        }
    }
    if(s.size() == 0)
    {
        pp = aar[0];
        aar[0] = bbr[0] = 0;
        for(int i = 0 ; i < 10 ; i++)
        {
            while(aar[i] > 0) s.push_back(i), aar[i]--;
            while(bbr[i] > 0) t.push_back(i),bbr[i]--;
        }
    }
    for(int i = s.size()-1 ; i>= 0  ; i--) cout<<s[i];
    for(int i = 0 ; i < pp ; i++) cout<<0;
    cout<<endl;
    for(int i = t.size()-1 ; i>= 0 ; i--) cout<<t[i];
    for(int i = 0 ; i < pp ; i++) cout<<0;
    cout<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <memory.h>

using namespace std;

#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif

#define sqr(a) (a)*(a)
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define dbg(x) cerr << #x << " == " << x << " "
#define dbgL(x) cerr << #x << " == " << x << endl

string s;
map<int, int> z, z2;
vector<int> a, b, ba, bb;
int bans;

int go() {
	int tek = 1;
	while (1) {
		int as = -1, af = -1;
		for (int i = 0; i < 10; ++i)
			if (z[i] > 0 && z2[9 - i] > 0) {
				as = i;
				af = 9 - i;
				break;
			}
		if (as == -1)
			break;
		a.push_back(as);
		b.push_back(af);
		--z[as];
		--z2[af];
		++tek;
	}
	int col = 0;
	while (z[0] > 0 && z2[0] > 0) {
		++col;
		++tek;
		--z[0];
		--z2[0];
	}
	while (1) {
		bool h = false;
		for (int i = 0; i < 10; ++i)
			if (z[i] > 0) {
				a.push_back(i);
				z[i]--;
				h = true;
				break;
			}
		if (!h)
			break;
		for (int i = 0; i < 10; ++i)
			if (z2[i] > 0) {
				b.push_back(i);
				z2[i]--;
				h = true;
				break;
			}
	}
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	for (int i = 0; i < col; ++i) {
		a.push_back(0);
		b.push_back(0);
	}
	return tek;
}

int main()
{
	cin >> s;

	for (int i = 0; i < s.size(); ++i) {
		int t = s[i] - '0';
		if (z.find(t) == z.end())
			z[t] = 1, z2[t] = 1;
		else z[t] += 1, z2[t] += 1;
		ba.push_back(t);
		bb.push_back(t);
	}

	for (int i = 0; i < 10; ++i) {
		z.clear();
		z2.clear();
		for (int i = 0; i < s.size(); ++i) {
			int t = s[i] - '0';
			if (z.find(t) == z.end())
				z[t] = 1, z2[t] = 1;
			else z[t] += 1, z2[t] += 1;
		}

		a.clear();
		b.clear();
		if (z[i] > 0 && z2[10 - i] > 0) {
			z[i]--;
			z2[10 - i]--;
			a.push_back(i);
			b.push_back(10 - i);
			int tmpans = go();

			if (tmpans > bans) {
				bans = tmpans;
				ba = a;
				bb = b;
			}
		}
	}
	if (bans == 0) {
		sort(ba.rbegin(), ba.rend());
		sort(bb.rbegin(), bb.rend());
	}

	for (int i = 0; i < s.size(); ++i)
		cout << ba[i];
	cout << endl;
	for (int i = 0; i < s.size(); ++i)
		cout << bb[i];

	return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <queue>
#include <vector>
#include <math.h>
#include <string.h>
#include <stack>
using namespace std;
string s;
int a[10],b[10];
deque<int> q,d;
int main()
{
    //freopen("in.txt","r",stdin);
    cin>>s;
    for(int i=0;s[i];i++)a[s[i]-'0']++;
    memcpy(b,a,sizeof(a));
    int z=-1,mark;
    for(int i=1;i<=5;i++)
    if(a[i]&&b[10-i])
    {
        a[i]--;
        b[10-i]--;
        int t=0;
        for(int i=0;i<10;i++) t+=min(a[i],b[9-i]);
        if(t>z)
        {
            z=t;
            mark=i;
        }
        a[i]++;
        b[10-i]++;
    }
    if(z==-1)
    {
        for(int i=9;i>=0;i--)
        while(a[i]--)printf("%d",i);puts("");
        for(int i=9;i>=0;i--)
        while(b[i]--)printf("%d",i);puts("");
    }else
    {
        q.push_front(mark);
        d.push_front(10-mark);
        a[mark]--;b[10-mark]--;
        for(int i=0;i<10;i++)
        {
            int t=min(a[i],b[9-i]);
            a[i]-=t;
            b[9-i]-=t;
            while(t--)
            {
                q.push_front(i);
                d.push_front(9-i);
            }
        }
        int j=0;
        for(int i=0;i<=9;i++)
        if(a[i]>=0)
        {
            while(a[i]--)
            {
                while(b[j]==0&&j<10) j++;
                b[j]--;
                if(!i&&!j)
                {
                    q.push_back(i);
                    d.push_back(j);
                }else
                {
                    q.push_front(i);
                    d.push_front(j);
                }
            }
        }
        int tmp=a[0];
        while(!q.empty()) printf("%d",q.front()),q.pop_front();
//        for(int i=0;i<tmp;i++) printf("0");
puts("");
        while(!d.empty()) printf("%d",d.front()),d.pop_front();
//        for(int i=0;i<tmp;i++) printf("0");
puts("");
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
#include <vector>
#include <sstream>

using namespace std;

#define pb push_back
#define sz(x) ((x).size())

typedef unsigned long long ll;

const int N=100010;

char s[N];
int cnt[11];

int main()
{
	scanf("%s",s);
	for(int i=0;s[i];i++)
		cnt[s[i]-'0']++;
	int id=0,ret=cnt[0];
	int a[11],b[11];
	for(int i=1;i<10;i++)
	{
		if(cnt[i] && cnt[10-i])
		{
			for(int j=0;j<10;j++)
				a[j]=b[j]=cnt[j];
			a[i]--,b[10-i]--;
			int tmp=0;
			for(int j=0;j<10;j++)
			{
				tmp+=min(a[j],b[9-j]);
				b[9-j]-=min(a[j],b[9-j]);
			}
			tmp+=1+min(a[0],b[0]);
			if(ret<tmp) id=i,ret=tmp;
		}
	}
	if(id==0)
	{
		for(int i=9;i>=0;i--)
			for(int j=cnt[i];j>0;j--)
				cout<<i;
		cout<<endl;
		for(int i=9;i>=0;i--)
			for(int j=cnt[i];j>0;j--)
				cout<<i;
		cout<<endl;
	}
	else
	{
		int i=id;
		vector<int> A,B;
		for(int j=0;j<10;j++)
			a[j]=b[j]=cnt[j];
		a[i]--,b[10-i]--;
		A.pb(i);B.pb(10-i);
		int tmp=0;
		for(int j=0;j<10;j++)
		{
			for(int k=0;k<min(a[j],b[9-j]);k++)
				A.pb(j),B.pb(9-j);
			int t=min(a[j],b[9-j]);
			a[j]-=t;
			b[9-j]-=t;
		}
		tmp=min(a[0],b[0]);
		a[0]-=tmp,b[0]-=tmp;
		for(int j=9;j>=0;j--)
			for(int k=a[j];k>0;k--)
				cout<<j;
		for(int j=sz(A);j>0;j--)
			cout<<A[j-1];
		for(int j=0;j<tmp;j++)
			cout<<"0";
		cout<<endl;
		for(int j=9;j>=0;j--)
			for(int k=b[j];k>0;k--)
				cout<<j;
		for(int j=sz(B);j>0;j--)
			cout<<B[j-1];
		for(int j=0;j<tmp;j++)
			cout<<"0";
		cout<<endl;
	}
	return 0;
}

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 101000;

char input[N];
char data[N];
char data2[N];
int n;
int maxlen;
int rr[12];
int rec[12];
int rec2[12];
int ans[N];
int ans2[N];

pair<int, int> deal (int num)
{
    if (min(rec[num], rec2[10 - num]) == 0)
        return make_pair(0, min(rec[0], rec2[0]));
    int ret = 1;
    int i;
    rec[num] --, rec2[10 - num] --;
    for (i = 0; i <= 9; i ++)
    {
        int m = min(rec[i], rec2[9 - i]);
        ret += m;
        rec[i] -= m;
        rec2[9 - i] -= m;
    }
    return make_pair(ret, min(rec[0], rec2[0]));
}

int main ()
{

    while (scanf ("%s", input) != EOF)
    {
        memset (rr, 0, sizeof (rr));
        int i;
        n = strlen (input);
        for (i = 0; i < n; i ++)
        {
            rr[input[i] - '0'] ++;
        }
        pair<int, int> maxlen = make_pair(-1, -1);
        int x = -1;
        for (i = 1; i <= 9; i ++)
        {
            memcpy (rec, rr, sizeof (rr));
            memcpy (rec2, rr, sizeof (rec));
            pair<int, int> temp = deal (i);
            if (temp.first + temp.second > maxlen.first + maxlen.second)
            {
                maxlen = temp;
                x = i;
            }
        }
        int cc = 0;
        memcpy (rec, rr, sizeof (rr));
        memcpy (rec2, rr, sizeof (rec));
        for (i = 0; i < maxlen.second; i ++)
        {
            ans[cc] = ans2[cc] = 0;
            rec[0] --, rec2[0] --;
            cc ++;
        }
        if (rec[x] != 0 && rec[10 - x] != 0)
        {
            ans[cc] = x;
            ans2[cc ++] = 10 - x;
            rec[x] --;
            rec2[10 - x] --;
            for (i = 0; i <= 9; i ++)
                while (rec[i] && rec2[9 - i])
                {
                    ans[cc] = i;
                    ans2[cc] = 9 - i;
                    cc ++;
                    rec[i] --;
                    rec2[9 - i] --;
                }
        }
        int cc2 = cc;
        for (i = 0; i <= 9; i ++)
        {
            while (rec[i])
            {
                ans[cc ++] = i;
                rec[i] --;
            }
            while (rec2[i])
            {
                ans2[cc2 ++] = i;
                rec2[i] --;
            }
        }
        for (i = n - 1; i >= 0; i --)
            printf ("%d", ans[i]);
        printf ("\n");
        for (i = n - 1; i >= 0; i --)
            printf ("%d", ans2[i]);
        printf ("\n");
    }
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>

using namespace std;

#define ll long long

const int MN = 1000 * 100 + 10;

int cnt1[10], cnt2[10];
char str[MN];

vector <int> ans1, ans2;

bool used1[MN], used2[MN];

int best_len = 0, zero = -1, st = -1;

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        gets(str);
        int n = strlen(str);
        for(int i = 0; i < n; i ++)
                cnt1[str[i] - '0'] ++, cnt2[str[i] - '0'] ++;
        int kol = cnt1[0];
        for(int i = 0; i <= kol; i ++) {
                cnt1[0] -= i, cnt2[0] -= i;
                for(int j = 1; j <= 9; j ++) {
                        if (!cnt1[j] || !cnt2[10 - j])
                                continue;
                        cnt1[j] --, cnt2[10 - j] --;
                        int k = i + 1;
                        for(int x = 0; x <= 9; x ++)
                                k += min(cnt1[x], cnt2[10 - x - 1]);
                        cnt1[j] ++, cnt2[10 - j] ++;
                        if (k > best_len) {
                                best_len = k;
                                zero = i;
                                st = j;
                        }
                }
                cnt1[0] += i, cnt2[0] += i;
        }
        ans1.reserve(n);
        ans2.reserve(n);
        for(int i = 0; i < zero; i ++) {
                ans1.push_back(0);
                ans2.push_back(0);
        }
        if (zero != -1)
                cnt1[0] -= zero, cnt2[0] -= zero;
        if (st != -1) {
                ans1.push_back(st);
                ans2.push_back(10 - st);
                cnt1[st] --, cnt2[10 - st] --;
                for(int i = 0; i <= 9; i ++) {
                        int x = min(cnt1[i], cnt2[10 - i - 1]);
                        cnt1[i] -= x, cnt2[10 - i - 1] -= x;
                        for(int j = 0; j < x; j ++) {
                                ans1.push_back(i);
                                ans2.push_back(10 - i - 1);
                        }
                }
        }
        for(int i = 0; i <= 9; i ++)
                for(int j = 0; j < cnt1[i]; j ++)
                        ans1.push_back(i);
        for(int i = 0; i <= 9; i ++)
                for(int j = 0; j < cnt2[i]; j ++)
                        ans2.push_back(i);
        reverse(ans1.begin(), ans1.end());
        reverse(ans2.begin(), ans2.end());
        for(int i = 0; i < ans1.size(); i ++)
                printf("%d", ans1[i]);
        printf("\n");
        for(int i = 0; i < ans2.size(); i ++)
                printf("%d", ans2[i]);
        return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int vis1[10];
int vis2[10];
int s2[10];
string str;

int sum_9()
{
    int i,j;
    int res=0;
    for(i=0; i<=9; i++)
    {
        res+=min(vis1[i],vis2[9-i]);
    }
    return res;
}

int getmax()
{
    int i,j;
    int res=0;
    int idx=-1;
    for(i=1; i<=5; i++)
    {
        if(vis1[i]&&vis2[10-i])
        {
            vis1[i]--,vis2[10-i]--;
            int t=sum_9()+1;
            vis1[i]++,vis2[10-i]++;

            if(t>res)
            {
                idx=i;
                res=t;
            }
        }
    }
    return idx;
}

int main()
{
   // freopen("input.txt","r",stdin);
    int i,j;
    cin>>str;
    for(i=0; i<str.size(); i++)
    {
        vis1[str[i]-'0']++;
        vis2[str[i]-'0']++;
    }
    int id=getmax();

    string ans1,ans2;

    if(id!=-1)
    {
        ans1+=id+'0';
        ans2+=10-id+'0';
        vis1[id]--,vis2[10-id]--;

        for(i=0; i<=9; i++)
        {
            while(vis1[i]&&vis2[9-i])
            {
                ans1+=i+'0';
                ans2+=9-i+'0';
                vis1[i]--,vis2[9-i]--;
            }
        }

        reverse(ans1.begin(),ans1.end());
        reverse(ans2.begin(),ans2.end());
    }

    while(vis1[0]&&vis2[0])
    {
        ans1+=0+'0';
        ans2+=0+'0';
        vis1[0]--;
        vis2[0]--;
    }

    reverse(ans1.begin(),ans1.end());
    reverse(ans2.begin(),ans2.end());

    for(i=0; i<=9; i++)
    {
        while(vis1[i])
        {
            ans1+=i+'0';
            vis1[i]--;
        }
        while(vis2[i])
        {
            ans2+=i+'0';
            vis2[i]--;
        }
    }

    reverse(ans1.begin(),ans1.end());
    reverse(ans2.begin(),ans2.end());

    cout<<ans1<<endl<<ans2<<endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;

const int INF = 100000000;

string str;
string s1,s2;
int st1[10];
int st2[10];

int sum9()
{
    int c=0;
    for(int i=0;i<=9;i++) c+=min(st1[i],st2[9-i]);
    return c;
}

int best()
{
    int maxx=0,index=-1;
    for(int i=1;i<=5;i++)
        if( st1[i]&&st2[10-i])
        {
            st1[i]--; st2[10-i]--;
            int ans=sum9()+1;
            st1[i]++; st2[10-i]++;
            if(ans>maxx) { maxx=ans;index=i; }
        }
    return index;
}

int main()
{
   // freopen("input.txt","r",stdin);
    cin>>str;
    for(size_t i=0;i<str.length();i++)
    {
        st1[str[i]-'0']++;
        st2[str[i]-'0']++;
    }

    int b = best();
    if(b!=-1)
    {
        s1.push_back(b+'0'); st1[b]--;
        s2.push_back(10-b+'0'); st2[10-b]--;
        for(int i=0;i<=9;i++)
            while( st1[i]&&st2[9-i] )
            {
                s1.push_back(i+'0'); st1[i]--;
                s2.push_back(9-i+'0'); st2[9-i]--;
            }
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
    }
    while(st1[0]&&st2[0])
    {
        s1.push_back('0'); st1[0]--;
        s2.push_back('0'); st2[0]--;
    }

    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());

    for(int i=0;i<=9;i++)
    {
        while(st1[i]) { s1.push_back(i+'0'); st1[i]--; }
        while(st2[i]) { s2.push_back(i+'0'); st2[i]--; }
    }

    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());

    cout << s1 << '\n';
    cout << s2 << '\n';

    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define PI acos(-1.0)
#define LL long long
#define EPS 1e-9
#define PL printf("\n")
#define PS printf(" ")
#define PInt(n) printf("%d",n)
#define SI(n) scanf("%d",&n)
#define pb push_back
#define mp make_pair

using namespace std;

int counter1[11]={0},counter2[11]={0},temp1[11]={0},temp2[11]={0};

vector<int> a,b;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string temp;
    int bigcounter=0;
    cin >> temp;
    for(int i=0;i<temp.size();i++)
    {
        counter1[temp[i]-'0']++;
        counter2[temp[i]-'0']++;
        temp1[temp[i]-'0']++;
        temp2[temp[i]-'0']++;
        bigcounter++;
    }
    int maxi=INF_MIN,maxind=-1;
    for(int i=1;i<=5;i++)
    {
        int counter=0;
        if(!temp1[i] || !temp2[10-i])
            continue;
        temp1[i]--,temp2[10-i]--;
        counter++;
        for(int j=0;j<5;j++)
        {
            int mini=min(temp1[j],temp2[9-j]);
            temp1[j]-=mini,temp2[9-j]-=mini;
            counter+=mini;
        }
        for(int j=0;j<5;j++)
        {
            int mini=min(temp1[9-j],temp2[j]);
            temp1[9-j]-=mini,temp2[j]-=mini;
            counter+=mini;
        }
        int minii=0;
        for(int j=1;j<=5;j++)
        {
            int mini=min(temp1[j],temp2[10-j]);
            temp1[j]-=mini,temp2[10-j]-=mini;
            minii+=mini;
        }
        for(int j=1;j<=5;j++)
        {
            int mini=min(temp1[10-j],temp2[j]);
            temp1[10-j]-=mini,temp2[j]-=mini;
            minii+=mini;
        }
        int mini=min(temp1[0],temp2[0]);
        temp1[0]-=mini,temp2[0]-=mini;
        counter+=mini;
        int rest=bigcounter-counter-minii;
        counter+=min(rest,mini);
        if(counter>maxi)
        {
            maxi=counter;
            maxind=i;
        }
        for(int i=0;i<10;i++)
        {
            temp1[i]=counter1[i];
            temp2[i]=counter2[i];
        }
    }
    if(maxind == -1)
    {
        for(int i=0;i<10;i++)
            for(int j=0;j<counter1[i];j++)
                a.pb(i),b.pb(i);
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        for(int i=0;i<a.size();i++)
            PInt(a[i]);
        PL;
        for(int i=0;i<a.size();i++)
            PInt(b[i]);
        return 0;
    }
    a.pb(maxind),b.pb(10-maxind);
    counter1[maxind]--,counter2[10-maxind]--;
    for(int j=0;j<10;j++)
    {
        int mini=min(counter1[j],counter2[9-j]);
        counter1[j]-=mini,counter2[9-j]-=mini;
        for(int i=0;i<mini;i++)
            a.pb(j),b.pb(9-j);
    }
    vector<int> resta,restb;
    if(counter1[0] > counter2[0])
    {
        for(int j=0;j<counter1[0]-counter2[0];j++)
            resta.pb(0);
        counter1[0]=counter2[0];
    }
    else if(counter1[0] < counter2[0])
    {
        for(int j=0;j<counter2[0]-counter1[0];j++)
            restb.pb(0);
        counter2[0]=counter1[0];
    }
    for(int i=1;i<10;i++)
    {
        if(counter1[i] > counter2[10-i])
        {
            for(int j=0;j<counter1[i]-counter2[10-i];j++)
                resta.pb(i);
            counter1[i]=counter2[10-i];
        }
        if(counter1[10-i] < counter2[i])
        {
            for(int j=0;j<counter2[i]-counter1[10-i];j++)
                restb.pb(i);
            counter2[i]=counter1[10-i];
        }
    }
    int n=resta.size();
    vector<int> tensa,tensb;
    for(int i=1;i<10;i++)
        for(int j=0;j<counter1[i];j++)
        {
            tensa.pb(i);
            tensb.pb(10-i);
        }
    int m=tensa.size();
    for(int i=0;i<n;i++)
    {
        a.pb(resta[i]),b.pb(restb[i]);
        if(i<m)
            a.pb(tensa[i]),b.pb(tensb[i]);
    }
    for(int i=n;i<m;i++)
        a.pb(tensa[i]),b.pb(tensb[i]);
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    for(int i=0;i<counter1[0];i++)
        a.pb(0),b.pb(0);
    for(int i=0;i<a.size();i++)
        PInt(a[i]);
    PL;
    for(int i=0;i<a.size();i++)
        PInt(b[i]);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <complex>
#include <stack>
#include <queue>
#include <ctime>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef complex <double> pt;
typedef complex <ll> pti;

int main() {
	//ifstream fin("input.txt", ios::in);
	//ofstream fout("output.txt", ios::out);
	//FILE *fpin=fopen("input.txt", "r");
	//FILE *fpout=fopen("output.txt", "w");
	istream &fin=cin;
	ostream &fout=cout;
	FILE *fpin=stdin;
	FILE *fpout=stdout;

	string s;
	fin >> s;
	int n=s.size();

	vector <int> cnt(10);
	for(int i=0; i<n; i++) {
		cnt[s[i]-'0']++;
	}

	vector <int> sum9cnt(10);
	for(int i=0; i<=4; i++) {
		sum9cnt[i]=min(cnt[i], cnt[9-i]);
		sum9cnt[9-i]=sum9cnt[i];
	}

	int sum10=-1;
	for(int i=1; i<=4; i++) {
		if(cnt[i]-sum9cnt[i] && cnt[10-i]-sum9cnt[10-i]) {
			sum10=i;
			break;
		}
	}
	if(sum10==-1 && cnt[5]-sum9cnt[5]) sum10=5;

	bool sum10usesum9[2];
	sum10usesum9[0]=sum10usesum9[1]=false;
	if(sum10==-1) {
		for(int i=1; i<=4; i++) {
			if(cnt[i] && cnt[10-i]) {
				sum10=i;
				if(cnt[i]-sum9cnt[i]==0) sum10usesum9[0]=true;
				if(cnt[10-i]-sum9cnt[10-i]==0) sum10usesum9[1]=true;
				break;
			}
		}
	}
	if(sum10==-1 && cnt[5]) {
		sum10=5;
		if(cnt[5]-sum9cnt[5]==0) sum10usesum9[0]=true;
		if(cnt[4]-sum9cnt[4]==0) sum10usesum9[1]=true;
	}

	int sum0=0;
	if(sum10==-1) {
		for(int i=0; i<10; i++) sum9cnt[i]=0;
		sum0=cnt[0];
	} else {
		sum0=cnt[0]-sum9cnt[0];
	}

	for(int i=0; i<10; i++) {
		int loopnum=cnt[i]-sum9cnt[i];
		if(!sum10usesum9[0] && sum10==i) loopnum--;
		if(i==0) loopnum-=sum0;
		for(int j=0; j<loopnum; j++) {
			fout << i;
		}
	}
	if(sum10>=0) {
		for(int i=0; i<10; i++) {
			int loopnum=sum9cnt[i];
			if(sum10usesum9[0] && sum10==i) loopnum--;
			for(int j=0; j<loopnum; j++) {
				fout << i;
			}
		}
		fout << sum10;
	}
	for(int i=0; i<sum0; i++) {
		fout << '0';
	}
	fout << endl;

	for(int i=0; i<10; i++) {
		int loopnum=cnt[i]-sum9cnt[i];
		if(!sum10usesum9[1] && 10-sum10==i) loopnum--;
		if(i==0) loopnum-=sum0;
		for(int j=0; j<loopnum; j++) {
			fout << i;
		}
	}
	if(sum10>=0) {
		for(int i=9; i>=0; i--) {
			int loopnum=sum9cnt[i];
			if(sum10usesum9[1] && sum10==10-i) loopnum--;
			for(int j=0; j<loopnum; j++) {
				fout << i;
			}
		}
		fout << 10-sum10;
	}
	for(int i=0; i<sum0; i++) {
		fout << '0';
	}
	fout << endl;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

string s;
int cnt1[11], cnt2[11], res1[100005], res2[100005];

int main() {
    cin>>s;
    for(int i= 0;i<s.size();++i) {
        ++cnt1[s[i]-'0'];
        ++cnt2[s[i]-'0'];
    }
    int res = 0, cntZero = 0, t1 = -1, t2 = -1;
    for(int x = 0;x<=cnt1[0];++x) {
        cnt1[0] -= x;
        cnt2[0] -= x;
        for(int i = 1;i<=5;++i) {
            int j = 10-i;
            if(cnt1[i] && cnt2[j]) {
                --cnt1[i];
                --cnt2[j];
                int numZeroes = x + 1;
                for(int k = 0;k<=9;++k)
                    numZeroes += min(cnt1[k],cnt2[9-k]);
                if(numZeroes > res) {
                    res = numZeroes;
                    cntZero = x;
                    t1 = i;
                    t2 = j;
                }
                ++cnt1[i];
                ++cnt2[j];
            }
        }
        cnt1[0] += x;
        cnt2[0] += x;
    }
    if(t1 == -1 && t2 == -1) {
        sort(s.begin(),s.end());
        reverse(s.begin(),s.end());
        cout<<s<<endl;
        cout<<s<<endl;
        return 0;
    }

    for(int i = 0;i<cntZero;++i)
        res1[i] = res2[i] = 0;
    cnt1[0] -= cntZero;
    cnt2[0] -= cntZero;
    --cnt1[t1];
    --cnt2[t2];
    res1[cntZero] = t1;
    res2[cntZero] = t2;
    for(int i = cntZero+1;i<s.size();++i) {
        bool ok = false;
        for(int j = 0;j<=9;++j) {
            if(cnt1[j] && cnt2[9-j]) {
                --cnt1[j];
                --cnt2[9-j];
                ok = true;
                res1[i] = j;
                res2[i] = 9-j;
                break;
            }
        }
        if(!ok) {
            for(int j = 0;j<=9;++j) {
                if(cnt1[j]) {
                    res1[i] = j;
                    --cnt1[j];
                    break;
                }
            }
            for(int j = 0;j<=9;++j) {
                if(cnt2[j]) {
                    res2[i] = j;
                    --cnt2[j];
                    break;
                }
            }
        }
    }
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res1[i]);
    printf("\n");
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res2[i]);
    printf("\n");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

string s;
int cnt1[11], cnt2[11], res1[100005], res2[100005];

int main() {
    cin>>s;
    for(int i= 0;i<s.size();++i) {
        ++cnt1[s[i]-'0'];
        ++cnt2[s[i]-'0'];
    }
    int res = 0, cntZero = 0, t1 = -1, t2 = -1;
    for(int x = 0;x<=cnt1[0];++x) {
        cnt1[0] -= x;
        cnt2[0] -= x;
        for(int i = 1;i<=5;++i) {
            int j = 10-i;
            if(cnt1[i] && cnt2[j]) {
                --cnt1[i];
                --cnt2[j];
                int numZeroes = x + 1;
                for(int k = 0;k<=9;++k)
                    numZeroes += min(cnt1[k],cnt2[9-k]);
                if(numZeroes > res) {
                    res = numZeroes;
                    cntZero = x;
                    t1 = i;
                    t2 = j;
                }
                ++cnt1[i];
                ++cnt2[j];
            }
        }
        cnt1[0] += x;
        cnt2[0] += x;
    }
    if(t1 == -1 && t2 == -1) {
        sort(s.begin(),s.end());
        reverse(s.begin(),s.end());
        cout<<s<<endl;
        cout<<s<<endl;
        return 0;
    }

    for(int i = 0;i<cntZero;++i)
        res1[i] = res2[i] = 0;

    cnt1[0] -= cntZero;
    cnt2[0] -= cntZero;
    --cnt1[t1];
    --cnt2[t2];
    res1[cntZero] = t1;
    res2[cntZero] = t2;
    for(int i = cntZero+1;i<s.size();++i) {
        bool ok = false;
        for(int j = 0;j<=9;++j) {
            if(cnt1[j] && cnt2[9-j]) {
                --cnt1[j];
                --cnt2[9-j];
                ok = true;
                res1[i] = j;
                res2[i] = 9-j;
                break;
            }
        }
        if(!ok) {
            for(int j = 0;j<=9;++j) {
                if(cnt1[j]) {
                    res1[i] = j;
                    --cnt1[j];
                    break;
                }
            }
            for(int j = 0;j<=9;++j) {
                if(cnt2[j]) {
                    res2[i] = j;
                    --cnt2[j];
                    break;
                }
            }
        }
    }
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res1[i]);
    printf("\n");
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res2[i]);
    printf("\n");

    return 0;
}

#include <stdio.h>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <utility>

//#define M_PI 3.141592653589793238462643
#define eps 1e-8
#define inf ((int)1e9)
#define pb push_back
#define mp make_pair

using namespace std;

char resf[110000], ress[110000], s[110000];
int len, A[12], B[12], C[12], res, ef, es;

void add (int f, int s)
{
  resf[ef++]=(char)(f+'0'), ress[es++]=(char)(s+'0');
}

void addf (int f)
{
  resf[ef++]=(char)(f+'0');
}

void adds (int s)
{
  ress[es++]=(char)(s+'0');
}

void madd (int f, int s, int num)
{
  while (num>0)
    add(f,s), num--;
}

int main()
{
  int i, j, cnt, d, cn;
  bool flf, fls;
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  gets(s), len=strlen(s);
  for (i=0; i<len; i++)
    A[(int)(s[i]-'0')]++;
  for (i=1; i<=9; i++)
    madd(i,i,A[i]);
  madd(0,0,A[0]), res=A[0];
  for (i=1; i<=5; i++)
  {
    memcpy(B,A,sizeof(A));
    memcpy(C,A,sizeof(A));

    if (B[i]==0 || C[10-i]==0)
      continue;
    B[i]--, C[10-i]--, flf=0, fls=0;
    for (cnt=1, j=0; j<=9; j++)
      cnt+=min(B[j],C[9-j]);
    cn=min(B[0]-min(B[0],C[9]),C[0]-min(C[0],B[9])), cnt+=cn;
    if (cnt<=res)
      continue;
    res=cnt, ef=0, es=0;
    for (j=1; j<=9; j++)
    {
      while (B[j]>min(B[j],C[9-j]))
        addf(j), B[j]--;
      while (C[j]>min(C[j],B[9-j]))
        adds(j), C[j]--;
    }
    while (B[0]>cn+C[9])
      addf(0), B[0]--;
    while (C[0]>cn+B[9])
      adds(0), C[0]--;
    for (j=0; j<=9; j++)
      d=min(C[j],B[9-j]), madd(9-j,j,d), C[j]-=d, B[9-j]-=d;
    add(i,10-i);
    madd(0,0,B[0]);
  }
  printf("%s\n%s\n", resf, ress);
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int num1[10] = {0};
int num2[10] = {0};
int getcnt9()
{
    int res = 0;
    for (int i = 0; i <= 9; i++)
    {
        int p1 = num1[i];
        int p2 = num2[9 - i];
        res += min(p1,p2);
    }
    return res;
}
int main()
{
    //freopen ("input.txt","r",stdin);

    char ch;
    while(scanf ("%c",&ch) != EOF)
    {
        if(isdigit(ch))
        {
            num1[ch - '0']++;
            num2[ch - '0']++;
        }
    }
    int ans = 0;
    int up,down;
    for (int i = 1; i < 10; i++)
    {
        int p1 = num1[i];
        int p2 = num2[10 - i];

        if(min(p1,p2) > 0)
        {

            int s = 1;
            num1[i]--;
            num2[10 - i]--;
            s += getcnt9();
            if(s > ans)
            {
                ans = s;
                up = i;
                down = 10 - i;
            }
            num1[i]++;
            num2[10 - i]++;
        }
    }
    int cntzero = num1[0];
    int cntnine = num1[9];
    cntzero -= cntnine;
    if(cntzero < 0) cntzero = 0;
    num1[0] -= cntzero;
    num2[0] -= cntzero;
    int res = ans;
    vector<int> numup(cntzero,0);
    vector<int> numdown(cntzero,0);
    if(ans != 0)
    {
        numup.push_back(up);
        numdown.push_back(down);
        num1[up]--;
        num2[down]--;
        for (int i = 0; i <= 9;  i++)
        {
            int p1 = num1[i];
            int p2 = num2[9 - i];
            int p3 = min(p1,p2);
            for (int j = 0; j < p3; j++)
            {
                numup.push_back(i);
                numdown.push_back(9 - i);
                num1[i]--;
                num2[9 - i]--;
            }
        }
    }
    for (int i = 0; i < 10; i++)
    {
        while(num1[i] != 0) numup.push_back(i),num1[i]--;
        while(num2[i] != 0) numdown.push_back(i),num2[i]--;
    }
    for (int i = 0; i < numup.size(); i++)
    {
        printf ("%d",numup[numup.size() - 1 - i]);
    }
    printf ("\n");
    for (int i = 0; i < numdown.size(); i++)
    {
        printf ("%d",numdown[numdown.size() - 1 - i]);
    }
    return 0;
}

#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<double> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define MOD 1000000007
#define EPS 1e-8
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(i,x.size())printf("%d%c",x[i],i+1==x.size()?'\n':' ');

int c[10];
int z1[10],z2[10];
char s[114514];
string sub[10];

int main()
{
    rep(i,10)rep(j,300000)sub[i]+=char('0'+i);

    scanf("%s",&s);
    int n=strlen(s);
    rep(i,n)c[s[i]-'0']++;
    string r1,r2;
    int rs=c[0];
    repn(i,1,10)r1+=sub[i].substr(0,c[i]);
    r1+=sub[0].substr(0,c[0]);
    r2=r1;
    repn(k,1,10)if(c[k]&&c[10-k])
    {
        string s1,s2;
        int nc=1;
        rep(i,10)z1[i]=z2[i]=c[i];
        z1[k]--,z2[10-k]--;
        s1+=char('0'+k);
        s2+=char('0'+10-k);

        rep(i,10)
        {
            int del=min(z1[i],z2[9-i]);
            nc+=del;
            s1=sub[i].substr(0,del)+s1;
            s2=sub[9-i].substr(0,del)+s2;
            z1[i]-=del,z2[9-i]-=del;
        }
        int tt=min(z1[0],z2[0]);
        z1[0]-=tt,z2[0]-=tt;
        nc+=tt;
        s1+=sub[0].substr(0,tt);
        s2+=sub[0].substr(0,tt);
        rep(i,10)
        {
            s1=sub[i].substr(0,z1[i])+s1;
            s2=sub[i].substr(0,z2[i])+s2;
        }
        if(rs<nc)rs=nc,r1=s1,r2=s2;

    }
    cout<<r1<<endl<<r2<<endl;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define REV(i,k,n) for(int i=k;i>=n;i--)
#define SZ(x) ((int)x.size())
#define CLR(v,c) memset(v,c,sizeof (v))
#define eps 1e-10

typedef  long long ll ;
typedef  long double ld ;

const int NN = 100 * 1000 + 100 ;

int dig [12] ;
char s [NN] ;
int A [NN] , B [NN] ;
int dig_a [12] , dig_b [12] ;

int mod (int x) {
	x %= 10 ;
	return (x + 10) % 10 ;
}

int main () {
#ifdef HOMEPC
	freopen ("in.in","r",stdin) ;
#endif
	CLR (dig,0) ;
	scanf ("%s",s) ;
	int n = strlen (s) ;
	REP (i,0,n) {
		dig [s[i] - '0'] += 2 ;
	}

	int Max = -1 ;
	int I,J ;
	int Zero ;
	I = J = Zero = -1 ;

	REP (i,1,10)  if (dig [i] > 0 && dig [10 - i] > 0) {
		int sum = 0 ;
		int j = 10 - i ;
		dig [i] -- , dig [j] -- ;
		REP (k,0,10) {
			sum += min (dig [k],dig [9 - k]) ;
		}
		int m_z = min (dig [0],dig [9]) ;
		sum /= 2 ;
		if (sum > Max) {
			Max = sum ;
			I = i , J = j ;
			Zero = dig [0] - m_z ;
			Zero >>= 1;
		}
		dig [i] ++ , dig [j] ++ ;
	}

	//cout << Max + 1 << endl ;

	int index = n - 1;

	memcpy (dig_a,dig,sizeof (dig_a)) ;
	memcpy (dig_b,dig,sizeof (dig_b)) ;
	REP (i,0,10) dig_a [i] >>= 1 , dig_b [i] >>= 1 ;

	//Zero = dig_a [0] ;

	if (Zero > 0) {
		while (Zero --) {
			dig_a [0] -- ;
			dig_b [0] -- ;
			A [index ] = 0 ;
			B [index --] = 0 ;
		}
	}

	if (I != -1) {
		A [index] = I ;
		B [index] = J ;
		index -- ;
		dig_a [I] -- ;
		dig_b [J] -- ;
	}

	if (I != -1) {
		REP (k,0,10) {
			int m = min (dig_a [k],dig_b [9 - k]) ;
			while (m --) {
				A [index] = k ;
				B [index] = 9 - k ;
				dig_a [k] -- ;
				dig_b [9 - k] -- ;
				index -- ;
			}
		}
	}

	int indx = index ;
	REP (i,0,10) {
		while (dig_a [i] --) {
			A [indx --] = i ;
		}
	}
	indx = index ;
	REP (i,0,10) {
		while (dig_b [i] --) {
			B [indx --] = i ;
		}
	}
	REP (i,0,n) printf ("%d",A [i]) ;
	printf ("\n") ;
	REP (i,0,n) printf ("%d",B [i]) ;
	printf ("\n") ;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>

#include <string>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#ifdef ILIKEGENTOO
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#define E(x) { cerr << #x << " = " << (x) << "   "; }
template<typename T, size_t N> struct array { T val[N]; T& operator[](size_t n) { if(n >= N) assert(false); return val[n]; } T* data() { return &val[0]; } };
#else
#define Eo(x)
#define E(x)
#include <array>
#endif
#define EO(x) Eo(x)
#define Sz(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()

template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }

typedef double real;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;

const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const real eps = 1e-5;

int cnt[3][10];

int main() {
	ios_base::sync_with_stdio(false);
	string n; cin >> n;
	Eo(n);
	for(int i=0; i<Sz(n); i++) cnt[0][n[i]-'0']++;
	for(int i=0; i<10; i++) cnt[2][i] = cnt[1][i] = cnt[0][i];

	int maxres = -1;
	vector<int> ans[2];
	for(int i=1; i<10; i++) if(false || true) {
		int ii = 10-i;
		vector<int> curans[2];
		int curres = 0;
		if(cnt[0][i] && cnt[0][ii]) {
			curres++;
			cnt[0][i]--; cnt[1][ii]--;
			curans[0].push_back(i);
			curans[1].push_back(ii);
		} else continue;

		for(int j=0; j<10; j++) {
			int t = min(cnt[0][j], cnt[1][9-j]);
			curres += t;
			cnt[0][j] -= t;
			cnt[1][9-j] -= t;
			for(int k=0; k<t; k++) {
				curans[0].push_back(j);
				curans[1].push_back(9-j);
			}
		}
		int t = min(cnt[0][0], cnt[1][0]);
		for(int j=0; j<10; j++) {
			for(int k=0; k<2; k++) {
				int ost = cnt[k][j];
				if(!j) ost -= t;
				for(int q=0; q<ost; q++) curans[k].push_back(j);
			}
		}
		reverse(All(curans[0])); reverse(All(curans[1]));
		curres += t;
		for(int j=0; j<t; j++) {
			curans[0].push_back(0);
			curans[1].push_back(0);
		}

		EO(curres);
		if(curres > maxres) {
			maxres = curres;
			ans[0].swap(curans[0]);
			ans[1].swap(curans[1]);
		}
		for(int j=0; j<10; j++) cnt[0][j] = cnt[1][j] = cnt[2][j];
	}
	if(Sz(ans[0]) == 0) {
		for(int i=9; i>=0; i--) for(int j=0; j<cnt[0][i]; j++) {
			ans[0].push_back(i);
			ans[1].push_back(i);
		}
	}

	for(int i=0; i<2; i++) {
		for(int j=0; j<Sz(ans[i]); j++) cout << ans[i][j];
		cout << endl;
	}

	return 0;
}

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <numeric>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <fstream>
#include <list>
#include <sstream>
#include <iostream>
#include <iomanip>

using namespace std;
#define MAX 100005
int aux[ 15 ], a[ 15 ] , a2[ 15 ], aux2[ 15 ];
int getNueve( ){
    int nueves = 0;
    for( int i = 0 ; i < 10 ; ++i ) nueves += min( aux[ i ] , aux2[ 9 - i ] );
    return nueves;
}

int main(){

    char s[ MAX ];
    int l;
    scanf("%s" , &s );
    l = strlen( s );
    memset( a , 0 , sizeof( a ) );
    memset( a2 , 0 , sizeof( a2 ) );
    //int a[ 15 ] = { 0 }, a2[ 15 ] = { 0 };
    string n1 = "" , n2 = "";
    for( int i = 0 ; s[ i ] ; ++i ){
        a[ s[ i ] - '0' ]++;
        a2[ s[ i ] - '0' ]++;
    }

    int v1 = 0, v2 = 0, nueves = 0;
    //for( int i = 0 ; i < 10 ; ++i ) nueves += min( a[ i ] , a2[ 9 - i ] );
    //cout<<nueves<<endl;
    int maxi = -1, mini = 1<<30;
    for( int i = 0 ; i < 10 ; ++i ){
        //cout<<a[ i ]<<endl;
        int t = min( a[ i ] , a2[ 10 - i ] );
        int nv = min( a[ i ] , a2[ 9 - i ] );
        //cout<<nv<<" ten "<<t<<endl;
        if( t != 0 && nv == 0 ){
            v1 = i;
            v2 = 10 - i;
            break;
        }
        else if( t != 0 && nv != 0 ){
            /*if( nv < mini ){
                v1 = i;
                v2 = 10 - i;
                mini = nv;
            }*/
            for( int j = 0 ; j < 15 ; ++j ) { aux[ j ] = a[ j ]; aux2[ j ] = a2[ j ]; }
            aux[ i ]--;
            aux2[ 10 - i ]--;
            int n = getNueve();
            if( n > maxi ){
                maxi = n;
                v1 = i;
                v2 = 10 - i;
            }
        }
    }
    //cout<<v1<<" "<<v2<<endl;
    if( v1 != 0 ){
        n1 += (char)( v1 + '0');
        n2 += (char)( v2 + '0');
        a[ v1 ]--;
        a2[ v2 ]--;
    }
    //nueves despues del 1er 10
    for( int i = 0 ; i < 10 ; ++i ){
        int nv = min( a[ i ] , a2[ 9 - i ] );
        for( int j = 0 ; j < nv; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 9 - i + '0');
        }
        a[ i ] -= nv;
        a2[ 9 - i ] -= nv;
    }
    //zeros sobrantes al final
    int z = min( a[ 0 ] , a2[ 0 ] );
    for( int i = 0 ; i < z ; ++i ){
        n1 = "0" + n1;
        n2 = "0" + n2;
    }
    a[ 0 ] -= z;
    a2[ 0 ] -= z;
    //dieces
    for( int i = 1 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        for( int j = 0 ; j < t ; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 10 - i + '0');
        }
        a[ i ] -= t;
        a2[ 10 - i ] -= t;
    }

    for( int i = 0 ; i < 10 ; ++i ){
        for( int j = 0 ; j < a[ i ] ; ++j ) n1 += (char)( i + '0');
        for( int j = 0 ; j < a2[ i ] ; ++j ) n2 += (char)( i + '0');
    }

    reverse( n1.begin() , n1.end() );
    reverse( n2.begin() , n2.end() );
    printf("%s\n%s\n" , n1.c_str() , n2.c_str() );

    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <cassert>
#include <sstream>
//~ #include <unordered_map>
//~ #include <unordered_set>

using namespace std;

#define INF 0x3f3f3f3f
#define ll long long
#define SZ(x) (int)((x).size())

void imprime(vector<int> &v) {
    reverse(v.begin(),v.end());
    for (int i=0; i<SZ(v); i++)
        printf("%d",v[i]);
    printf("\n");
}

char s[100010];

int main() {
    //~ cin.sync_with_stdio(false);
    scanf(" %s",s);
    vector<int> n1,n2;
    int n = strlen(s);
    int cnt1[10] = {0}, cnt2[10] = {0}, v[10] = {0};

    for (int i=0; i<n; i++)
        cnt1[s[i]-'0']++, cnt2[s[i]-'0']++;

    for (int i=0; i<=9; i++)
        v[i] = min(cnt1[i],cnt2[9-i]);

    for (int i=1; i<=9; i++)
        if (cnt1[i]>v[i] && cnt2[10-i]>v[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }
            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return 0;
        }

    for (int i=1; i<=9; i++)
        if (cnt1[i]>v[i] && v[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--; v[i-1]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }

            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return 0;
        }

    for (int i=1; i<=9; i++)
        if (cnt1[i] && cnt2[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--; v[i]--; v[i-1]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }
            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return  0;
        }

    sort(s,s+n);
    reverse(s,s+n);
    printf("%s\n",s);
    printf("%s\n",s);

    return 0;
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef unsigned long long LL;
#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define FORD(k,a,b) for(int k(a-1); k >= (b); --k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPD(k,a) for(int k=a-1; k >-1; --k)
#define ABS(a) ((a)>0?(a):-(a))
int calc(int k)
{
	int res=0;
	while(!(k%10))
	{
		++res;
		k/=10;
	}
	return res;
}

int main()
{
 #ifdef HOME
 	freopen ("in.txt","r",stdin);
 	freopen ("out.txt","w",stdout);
	int TTT;
	cin >> TTT;
	REP(testcase,TTT)
	{
 #endif
//code
	string s;
	cin >> s;
	int n=s.size();
	string res1,res2;
	map<int,int> m1,m2;
	REP(i,s.size())
	{
		++m1[s[i]-'0'];
		++m2[s[i]-'0'];
	}
	res1.reserve(n);
	res2.reserve(n);
	res1.clear();
	res2.clear();
	//m1[0]=0;
	//m2[0]=0;
	int besti=-1,bestj=-1,best=0,bestzer=0;
	FOR(i,1,10)
	REP(j,10)
	if(((i+j)%10==0) && m1[i] && m2[j])
	{
		int ctr=1;

		--m1[i];
		--m2[j];
		int zer1=0,zer2=0;
		REP(ii,10)
		REP(jj,10)
		if(ii+jj==9)
		{
			ctr+=min(m1[ii],m2[jj]);
			if(ii==0)
				zer1=min(m1[ii],m2[jj]);
			if(jj==0)
				zer2=min(m1[ii],m2[jj]);
		}
		ctr+=min(m1[0]-zer1,m2[0]-zer2);
		if(ctr>best)
		{
			best=ctr;
			besti=i;
			bestj=j;
			bestzer=min(m1[0]-zer1,m2[0]-zer2);
		}
		++m1[i];
		++m2[j];

	}
	if(besti!=-1)
	{
		res1.append(bestzer,'0');
		res2.append(bestzer,'0');
		m1[0]-=bestzer;
		m2[0]-=bestzer;

		res1.push_back('0'+besti);
		res2.push_back('0'+bestj);
		--m1[besti];
		--m2[bestj];
		REP(i,10)
		REP(j,10)
		if(i+j==9)
		{
			int t=min(m1[i],m2[j]);
			res1.append(t,'0'+i);
			res2.append(t,'0'+j);
			m1[i]-=t;
			m2[j]-=t;
		}
	}
	REP(i,10)
		res1.append(m1[i],'0'+i);
	REP(i,10)
		res2.append(m2[i],'0'+i);
	reverse(res1.begin(),res1.end());
	reverse(res2.begin(),res2.end());
	cout << res1 << endl;
	cout << res2 << endl;
#ifdef HOME
	}
#endif
	return 0;
}

//program 139D

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

void Output(int x,int y)
{
  while(y--)putchar(x+48);
}

int main()
{
  int A[10],B[10];memset(A,0,sizeof(A));memset(B,0,sizeof(B));
  char c;while(c=getchar(),c>='0'&&c<='9'){A[c-48]++;B[c-48]++;}
  int Max=-1,Best;
  for(int X=1;X<=5;X++)
    if(A[X]&&B[10-X])
      {
        int C[10],D[10];
        for(int i=0;i<10;i++){C[i]=A[i];D[i]=B[i];}
        C[X]--;D[10-X]--;
        int Sum=0;
        for(int i=0;i<10;i++)
          {
            int Tmp=min(C[i],D[9-i]);
            C[i]-=Tmp;D[9-i]-=Tmp;Sum+=Tmp;
          }
        Sum+=min(C[0],D[0]);
        if(Sum>Max){Max=Sum;Best=X;}
      }
  if(Max==-1)
    {
      for(int i=9;i>=0;i--)Output(i,A[i]);putchar('\n');
      for(int i=9;i>=0;i--)Output(i,B[i]);putchar('\n');
    }
  else
    {
      A[Best]--;B[10-Best]--;int C[10];
      for(int i=0;i<10;i++)
        {
          C[i]=min(A[i],B[9-i]);
          A[i]-=C[i];B[9-i]-=C[i];
        }
      int Zero=min(A[0],B[0]);A[0]-=Zero;B[0]-=Zero;
      for(int i=9;i>=0;i--)Output(i,A[i]);
      for(int i=0;i<10;i++)Output(i,C[i]);
      putchar(Best+48);Output(0,Zero);putchar('\n');
      for(int i=9;i>=0;i--)Output(i,B[i]);
      for(int i=0;i<10;i++)Output(9-i,C[i]);
      putchar(58-Best);Output(0,Zero);putchar('\n');
    }
  return 0;
}

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
pair<int,int>lazem;
int d[100001];
int e[100001];
int a[10],b[10],c[10],x[10],y[10],chert,ans = 0,z;
int main(){
	string s;
	cin >> s;
	for(int i = 0;i < s.size();i++)
		a[int(s[i]- '0')]++;
	lazem.first = a[0];
	lazem.second = 20;
	for(int i = 0;i < 10;i++){
		x[i] = a[i];
		y[i] = a[i];
	}
	for(int i = 0;i <= a[0];i++)
		for(int j = 1;j < 10;j++){
			for(int k = 0;k < 10;k++){
				b[k] = a[k];
				c[k] = a[k];
			}
			b[0] -= i;
			c[0] -= i;
			if(b[j] > 0 && c[10 - j] > 0){
				b[j]--;
				c[10 - j]--;
				chert = i + 1;
				for(int k = 0;k < 10;k++)
					chert += min(b[k],c[9 - k]);
				if(chert > ans){
					lazem.first = i;
					lazem.second = j;
					ans = chert;
				}
			}
		}
	//cout << ans << " " << lazem.first << " " << lazem.second << endl;
	if(lazem.second == 20){
		for(int i = 9;i >= 0;i--)
			for(int j = 0;j < a[i];j++)
				cout << i;
		cout << endl;
		for(int i = 9;i >= 0;i--)
			for(int j = 0;j < a[i];j++)
				cout << i;
		cout << endl;
	}
	else{
	int pointer = 0;
	for(int i = 0;i < lazem.first;i++){
		d[pointer] = 0;
		e[pointer] = 0;
		pointer++;
	}
	y[0] -= lazem.first;
	x[0] -= lazem.first;
	d[pointer] = lazem.second;
	e[pointer] = 10 - lazem.second;
	pointer++;
	y[10 - lazem.second]--;
	x[lazem.second]--;
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < min(x[i],y[9 - i]);j++){
			d[pointer] = i;
			e[pointer] = 9 - i;
			pointer++;
		}
		z = min(x[i],y[9 - i]);
		x[i] -= z;
		y[9 - i] -= z;
	}
	for(int i = 0;i < 10;i++)
		for(int j = 0;j < x[i];j++)
			cout << i;
	for(int i = pointer - 1;i >= 0;i--)
		cout << d[i];
	cout << endl;
	for(int i = 0;i < 10;i++)
		for(int j = 0;j < y[i];j++)
			cout << i;
	for(int i = pointer - 1;i >= 0;i--)
		cout << e[i];
	cout << endl;
	}
	//system("pause");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define rpt(i,l,r) for(register int i=(l);i<=(r);++i)
#define upt(i,r,l) for(register int i=(r);i>=(l);--i)
const int maxn=110000;
int n,a[10];

namespace Ninit{
	char buf[maxn];
	void init(){
		scanf("%s",buf+1),n=strlen(buf+1);
		rpt(i,1,n)++a[buf[i]-'0'];
	}
}

namespace Nsolve{
	int A[maxn],B[maxn],La,Lb;
	int mx,mxv,b[10],c[10];
	void chaos(){
		rpt(i,0,9)rpt(j,1,b[i])A[++La]=i;
		rpt(i,0,9)rpt(j,1,c[i])B[++Lb]=i;
	}
	void solve(){
		mx=1,mxv=0;
		for(int i=1,tmp;tmp=1,i<6;++i){
			memcpy(b,a,sizeof a);
			memcpy(c,a,sizeof a);
			if(b[i] && c[10-i])--b[i],--c[10-i];else continue;
			rpt(j,0,9)tmp+=min(b[j],c[9-j]);
			tmp+=max(0,a[0]-b[9]);
			if(mxv<tmp)mxv=tmp,mx=i;
		}
		memcpy(b,a,sizeof a);memcpy(c,a,sizeof a);
		if(mxv){
			--b[mx],--c[10-mx];
			rpt(i,1,max(0,a[0]-b[9]))A[++La]=0,B[++Lb]=0;
			b[0]-=max(0,a[0]-b[9]),c[0]-=max(0,a[0]-b[9]);
			A[++La]=mx,B[++Lb]=10-mx;
			rpt(i,0,9){
				int mn=min(b[i],c[9-i]);
				b[i]-=mn,c[9-i]-=mn;
				rpt(j,1,mn)A[++La]=i,B[++Lb]=9-i;
			}
		}
		else{
			rpt(i,1,a[0])A[++La]=0,B[++Lb]=0;
			b[0]=c[0]=0;
		}
		chaos();

		upt(i,n,1)printf("%d",A[i]);cout<<endl;
		upt(i,n,1)printf("%d",B[i]);cout<<endl;
	}
}

int main(){
	Ninit::init();
	Nsolve::solve();
	return 0;
}

#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <vector>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define INF 1e9
#define pb push_back
#define mp make_pair
#define forn(i,n) for (int i = 0; i < n; i++)
#define MAXN 10

using namespace std;

typedef long long ll;
typedef vector <int> vt;

string s;
vector <int> g(MAXN);

int ans = -1, mxa, mxz;
string ans1, ans2;

void solve(int z, int a)
{
    vt x = g;
    vt y = g;
    if (z > x[0])
        return;
    int res = 0;
    res += z;
    x[0] -= z;
    y[0] -= z;
    if (x[a] && y[10 - a])
    {
        x[a]--;
        y[10 - a]--;
        res++;
    }
    else
    {
        if (res > ans)
        {
            ans = res;
            mxa = a;
            mxz = z;
        }
        return;
    }
    for (int i = 0; i < 10; i++)
    {
        int m = min(x[i], y[9 - i]);
        res += m;
        x[i] -= m;
        y[9 - i] -= m;
    }
    if (res > ans)
    {
        ans = res;
        mxa = a;
        mxz = z;
    }
    return;
}

void add(vt x, string &s)
{
    forn (i, 10)
    {
        int t = x[i];
        forn (j, t)
        {
            s.pb(i + '0');
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> s;
    forn (i, s.size())
    {
        g[s[i] - '0']++;
    }
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j < 10; j++)
        {
            solve(i, j);
        }
    }
    //printf("<ans %d zero %d last %d>\n", ans, mxz, mxa);
    vt x = g;
    vt y = g;
    forn (i, mxz)
    {
        ans1.pb('0');
        ans2.pb('0');
        x[0]--;
        y[0]--;
    }
    if (x[mxa] && y[10 - mxa])
    {
        ans1.pb(mxa + '0');
        ans2.pb(10 - mxa + '0');
        x[mxa]--;
        y[10 - mxa]--;
    }
    for (int i = 0; i < 10; i++)
    {
        int m = min(x[i], y[9 - i]);
        forn (j, m)
        {
            ans1.pb(i + '0');
            ans2.pb(9 - i + '0');
        }
        x[i] -= m;
        y[9 - i] -= m;
    }
    add(x, ans1);
    add(y, ans2);
    reverse(ans1.begin(), ans1.end());
    reverse(ans2.begin(), ans2.end());
    cout << ans1 << endl;
    cout << ans2 << endl;
    return 0;
}

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

char line[131072];
int cnt[11];
int tc1[11];
int tc2[11];
int use[11];
int n;
int p1[131072];
int p2[131072];
int best1[131072];
int best2[131072];

bool cmp(int x,int y)
{
    return x>y;
}

int findout(int num)
{
    if (cnt[num]==0 || cnt[10-num]==0)
        return 0;
    int ans=1;
    memcpy(tc1,cnt,44);
    memcpy(tc2,cnt,44);
    tc1[num]--;
    tc2[10-num]--;
    for (int i=0;i<10;i++)
    {
        use[i]=min(tc1[i],tc2[9-i]);
        ans+=use[i]*2;
    }
    ans+=tc1[0]-max(use[0],use[9]);
    int now=n;
    for (int i=0;i<tc1[0]-max(use[0],use[9]);i++)
        p1[now-i]=p2[now-i]=0;
    now-=tc1[0]-max(use[0],use[9]);
    p1[now]=num,p2[now]=10-num;
    now--;
    for (int i=0;i<10;i++)
    {
        for (int j=0;j<use[i];j++)
            p1[now-j]=i,p2[now-j]=9-i;
        now-=use[i];
    }
    int bnow=now;
    for (int i=1;i<=9;i++)
    {
        for (int j=0;j<tc1[i]-use[i];j++)
            p1[now-j]=i;
        now-=tc1[i]-use[i];
    }
    now=bnow;
    for (int i=1;i<=9;i++)
    {
        for (int j=0;j<tc2[i]-use[9-i];j++)
            p2[now-j]=i;
        now-=tc2[i]-use[9-i];
    }
    return ans;
}

int main()
{
    //freopen("in.txt","r",stdin);
    memset(cnt,0,sizeof(cnt));
    gets(line+1);
    n=strlen(line+1);
    for (int i=1;i<=n;i++)
        cnt[line[i]-48]++;
    int ans=0;
    for (int i=1;i<=n;i++)
        best1[i]=best2[i]=line[i]-48;
    sort(best1+1,best1+1+n,cmp);
    sort(best2+1,best2+1+n,cmp);
    for (int i=1;i<=5;i++)
    {
        int tmp=findout(i);
        if (tmp>ans)
        {
            ans=tmp;
            memcpy(best1,p1,sizeof(p1));
            memcpy(best2,p2,sizeof(p2));
        }
    }
    for (int i=1;i<=n;i++)
        printf("%d",best1[i]);
    printf("\n");
    for (int i=1;i<=n;i++)
        printf("%d",best2[i]);
    printf("\n");
    return 0;
}

#include <bits/stdc++.h>
//Practice makes perfect

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<int, pss> pis;

int cnt[10], t1[10], t2[10];

pis solve1(int a){
	string x, y; int ans = 0, k = 1;
	for (int i = 0; i < 10; i++) t1[i] = t2[i] = cnt[i];

	x = y = string(t1[0], '0');

	if ( t2[ ((10 -a) % 10) ] && t1[a] ){
		x += a + '0';
		y += ((10 - a) % 10) + '0';

		t1[a]--;
		t2[ ((10 -a) % 10) ]--;
		ans ++;
	}else
		k = 0;

	for (int i = 1; i < 9; i++)
		if (t1[i] && t2[9 - i]){
			int cnt = min(t1[i], t2[9 - i]);

			x += string(cnt, char(i + '0'));
			y += string(cnt, char(9 - i + '0') );

			t1[i] -= cnt;
			t2[9 - i] -= cnt;
			ans += cnt;
		}

	for (int i = 1; i < 10; i++){
		if (t1[i]) x += string(t1[i], char(i + '0'));
		if (t2[i]) y += string(t2[i], char(i + '0'));
	}

	reverse(x.begin(), x.end());
	reverse(y.begin(), y.end());

	return pis( ans * k, pss(x, y) );
}

pis solve2(int a){
	string x, y; int ans = 0, k = 1;
	for (int i = 0; i < 10; i++) t1[i] = t2[i] = cnt[i];

	if ( t2[ ((10 -a) % 10) ] && t1[a] ){
		x += a + '0';
		y += ((10 - a) % 10) + '0';

		t1[a]--;
		t2[ ((10 -a) % 10) ]--;
		ans ++;
	}else
		k = 0;

	for (int i = 0; i < 10; i++)
		if (t1[i] && t2[9 - i]){
			int cnt = min(t1[i], t2[9 - i]);

			x += string(cnt, char(i + '0'));
			y += string(cnt, char(9 - i + '0') );

			t1[i] -= cnt;
			t2[9 - i] -= cnt;
			ans += cnt;
		}

	int cnt = min(t1[0], t2[0]);
	x = string(cnt, '0') + x;
	y = string(cnt, '0') + y;
	t1[0] -= cnt;
	t2[0] -= cnt;
	ans += cnt;

	for (int i = 0; i < 10; i++){
		if (t1[i]) x += string(t1[i], char(i + '0'));
		if (t2[i]) y += string(t2[i], char(i + '0'));
	}

	reverse(x.begin(), x.end());
	reverse(y.begin(), y.end());

	return pis( ans * k, pss(x, y) );
}

int main(){
	ios::sync_with_stdio( false );
	cout.tie(0); cin.tie(0);

	pis ans = pis(0, pss("", ""));
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++)
		cnt[ s[i] - '0' ]++;

	for (int i = 1; i < 10; i++){
//		cerr << solve(i).first << " " << solve(i).second.first << " " << solve(i).second.second << endl;
		ans = max(ans, max(solve1(i), solve2(i)));
	}

	cout << ans.second.first << endl << ans.second.second << endl;
}

// (.Y.)™

#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define  ll          long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back

#define all(x) x.begin(), x.end()

#define DEBUG(x) cout << #x << ": " << (x) << endl;

int C1[10];
int C2[10];

int main() {
#ifndef ONLINE_JUDGE
    freopen( "input.txt", "rt", stdin );
    //freopen("output.txt", "wt", stdout);
#endif

    string s;
    cin >> s;

    for (int i = 0; i < s.length(); i++)
        C1[s[i]-'0']++;

    memcpy(C2, C1, sizeof(C1));

    pair <int, int> best(0, 0);

    for (int i = 1, j = 9, MAX = -1; i <= 5; i++, j--) {
        if ( C1[i] == 0 || C1[j] == 0 )
            continue;

        C1[i]--; C2[j]--;

        int cnt = 0;

        for (int i = 0, j = 9; i <= 9; i++, j--)
            cnt += min(C1[i], C2[j]);

        if ( MAX < cnt ) {
             MAX = cnt;
            best = mp(i, 10-i);
        }

        C1[i]++; C2[j]++;
    }

    string res1;
    string res2;

    if ( best == mp(0, 0) )
        goto last;

    res1.pb(best.first +'0');
    res2.pb(best.second+'0');

    C1[best.first ]--; C2[best.second]--;

    for (int i = 0, j = 9; i <= 9; i++, j--)
        while ( C1[i] > 0 && C2[j] > 0 ) {
            res1.pb(i+'0');
            res2.pb(j+'0');

            C1[i]--; C2[j]--;
        }

last:
    int tmp = min(C1[0], C2[0]);

    res1.insert(0, string(tmp, '0'));
    res2.insert(0, string(tmp, '0'));

    C1[0] -= tmp; C2[0] -= tmp;

    for (int i = 0; i <= 9; i++) {
        while ( C1[i] > 0 ) {
            res1.pb(i+'0');

            C1[i]--;
        }

        while ( C2[i] > 0 ) {
            res2.pb(i+'0');

            C2[i]--;
        }
    }

    reverse(all(res1));
    reverse(all(res2));

    cout << res1 << endl << res2;

exit:
    return ( 0 );
}

#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:268435456")

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

const string IN_NAME = "input.txt";
const string OUT_NAME = "output.txt";

//const string NAME = "";
//const string IN_NAME = NAME + ".in";
//const string OUT_NAME = NAME + ".out";

template<class T> T abs(T &x)       { return ((x) >= 0) ? (x) : (-(x)); }
template<class T> T sqr(T &x)       { return (x) * (x); }
template<class T> T min(T &a, T &b) { return ((a) < (b)) ? (a) : (b); }
template<class T> T max(T &a, T &b) { return ((a) > (b)) ? (a) : (b); }

#define sz(v) ((int) ((v).size()))
#define all(v) (v).begin(), (v).end()
#define fori(i,n) for (int i = 0; i < (n); i++)

typedef long long ll;
typedef pair<int, int> ii;

//------------------------------------------------------------------------------

int n;

char buf[100500];

vector<int> a, b, c;
vector<int> cntB, cntC;
vector<int> resB, resC;
vector<int> bestB, bestC;

void printAnswer()
{
    for (int i = 0; i < n; i++)
        printf("%d", bestB[i]);
    printf("\n");

    for (int i = 0; i < n; i++)
        printf("%d", bestC[i]);
    printf("\n");
}

int bestZeros = -100500;

int tryAdd()
{
    int zeros = 0;
    int p = 0;
    for (int i = n-1; i >= 0; i--)
    {
        int x = (resB[i] + resC[i] + p) % 10;
        p = (resB[i] + resC[i] + p) / 10;
        if (x == 0)
            zeros++;
        else
            break;
    }
    return zeros;
}

void updateAnswer()
{
    resB.clear();
    resC.clear();

    for (int i = n-cntB[0]-1; i >= 0; i--)
        resB.push_back(b[i]);
    for (int i = 0; i < cntB[0]; i++)
        resB.push_back(0);

    for (int i = n-cntC[0]-1; i >= 0; i--)
        resC.push_back(c[i]);
    for (int i = 0; i < cntC[0]; i++)
        resC.push_back(0);

    int zeros = tryAdd();

    if (zeros > bestZeros)
    {
        bestZeros = zeros;
        bestB = resB;
        bestC = resC;
    }
}

void way1(int startDigit)
{
    for (int i = 0; i < 10; i++)
        cntB[i] = cntC[i] = 0;

    for (int i = 0; i < n; i++)
    {
        cntB[a[i]]++;
        cntC[a[i]]++;
    }

    bool ok = false;
    //for (int i = 1; i <= 9; i++)
    for (int i = startDigit; i <= startDigit; i++)
    {
        if (cntB[i]>0 && cntC[10-i]>0)
        {
            cntB[i]--;
            cntC[10-i]--;
            b.push_back(i);
            c.push_back(10-i);
            ok = true;
            break;
        }
    }

    if (!ok)
    {
        for (int i = 1; i <= 9; i++)
        {
            while(cntB[i]--)
            {
                b.push_back(i);
            }
            while(cntC[i]--)
            {
                c.push_back(i);
            }
        }
        while (sz(b) < sz(c)) { b.push_back(0); cntB[0]--; }
        while (sz(c) < sz(b)) { c.push_back(0); cntC[0]--; }
        updateAnswer();
        return;
    }

    for (int i = 0; i <= 9; i++)
    {
        int j = 9 - i;
        int z = min(cntB[i], cntC[j]);
        for (int zz = 0; zz < z; zz++)
        {
            b.push_back(i);
            c.push_back(j);
        }
        cntB[i] -= z;
        cntC[j] -= z;
    }

    for (int i = 1; i <= 9; i++)
    {
        while(cntB[i]--)
        {
            b.push_back(i);
        }
        while(cntC[i]--)
        {
            c.push_back(i);
        }
    }
    while (sz(b) < sz(c)) { b.push_back(0); cntB[0]--; }
    while (sz(c) < sz(b)) { c.push_back(0); cntC[0]--; }
    updateAnswer();
}

void way2(int startDigit)
{
    for (int i = 0; i < 10; i++)
        cntB[i] = cntC[i] = 0;

    for (int i = 0; i < n; i++)
    {
        cntB[a[i]]++;
        cntC[a[i]]++;
    }

    for (int zz = 0; zz < cntB[0]; zz++)
    {
        b.push_back(0);
        c.push_back(0);
    }
    cntB[0] = 0;
    cntC[0] = 0;

    bool ok = false;
    //for (int i = 1; i <= 9; i++)
    for (int i = startDigit; i <= startDigit; i++)
    {
        if (cntB[i]>0 && cntC[10-i]>0)
        {
            cntB[i]--;
            cntC[10-i]--;
            b.push_back(i);
            c.push_back(10-i);
            ok = true;
            break;
        }
    }

    if (!ok)
    {
        for (int i = 1; i <= 9; i++)
        {
            while(cntB[i]--)
            {
                b.push_back(i);
            }
            while(cntC[i]--)
            {
                c.push_back(i);
            }
        }
        updateAnswer();
        return;
    }

    for (int i = 1; i <= 8; i++)
    {
        int j = 9 - i;
        int z = min(cntB[i], cntC[j]);
        for (int zz = 0; zz < z; zz++)
        {
            b.push_back(i);
            c.push_back(j);
        }
        cntB[i] -= z;
        cntC[j] -= z;
    }

    for (int i = 1; i <= 9; i++)
    {
        while(cntB[i]--)
        {
            b.push_back(i);
        }
        while(cntC[i]--)
        {
            c.push_back(i);
        }
    }

    updateAnswer();
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen(IN_NAME.c_str(), "r", stdin);
    freopen(OUT_NAME.c_str(), "w", stdout);
#endif

    /*for (int i = 0; i < 100000; i++)
        printf("%d",rand() % 10);
    printf("\n\n");
    return 0;*/

    scanf("%s", buf);
    n = strlen(buf);
    a.resize(n);
    //b.resize(n);
    //c.resize(n);
    for (int i = 0; i < n; i++)
        a[i] = buf[i] - '0';

    cntB.resize(10);
    cntC.resize(10);

    for (int s = 1; s <= 9; s++)
    {
        b.clear();
        c.clear();
        way1(s);
    }

    for (int s = 1; s <= 9; s++)
    {
        b.clear();
        c.clear();
        way2(s);
    }

    printAnswer();
}

#include <cstdio>
#include <vector>
#include <string>
#include <list>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

char s[100005];

int main(){
    int n=strlen(gets(s)),x[10]={},y[10]={},ans=-1,tag=0;
    for(int i=0;i<n;i++){
        x[s[i]-'0']++;
        y[s[i]-'0']++;
    }
    for(int i=1;i<=9;i++){
        x[i]--;
        y[10-i]--;
        if(x[i]>=0 && y[10-i]>=0){
            int sum=0;
            for(int j=0;j<=9;j++) sum+=min(x[j],y[9-j]);
            if(sum>ans){
                ans=sum;
                tag=i;
            }
        }
        y[10-i]++;
        x[i]++;
    }
    if(!tag){
        for(int i=9;~i;i--) while(x[i]--) putchar('0'+i); puts("");
        for(int i=9;~i;i--) while(y[i]--) putchar('0'+i); puts("");
    }else{
        list<char> p,q;
        x[tag]--;
        y[10-tag]--;
        p.push_back('0'+tag);
        q.push_back('0'+10-tag);
        for(int j=0;j<=9;j++){
            int c=min(x[j],y[9-j]);
            for(int k=0;k<c;k++){
                p.push_front('0'+j);
                q.push_front('0'+9-j);
            }
            x[j]-=c;
            y[9-j]-=c;
        }
        int c=min(x[0],y[0]);
        for(int k=0;k<c;k++){
            p.push_back('0');
            q.push_back('0');
        }
        x[0]-=c;
        y[0]-=c;
        for(int i=9;~i;i--) while(x[i]--) p.push_front('0'+i);
        for(int i=9;~i;i--) while(y[i]--) q.push_front('0'+i);
        for(auto x:p) putchar(x); puts("");
        for(auto x:q) putchar(x); puts("");
    }
}

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<sstream>
#include<deque>
#include<math.h>
#include<cstring>
#include <bitset>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>

#define all(v) v.begin(),v.end()
#define mpair make_pair

using namespace std;
typedef long double ld;
const ld epsilon = 1e-9;
typedef long long ll;

int main()
{
	//freopen("bobi.in", "r", stdin);

	string n;
	cin >> n;
	vector<int> nums(10);
	for(int i = 0; i < n.size(); i++)
		nums[n[i] - '0']++;
	int maxm = 0;
	vector<string> maxAns(2);
	maxAns[0] = maxAns[1] = n;
	for(int i = 0; i < n.size(); i++)
	{
		maxAns[0][i] -= '0';
		maxAns[1][i] -= '0';
	}
	if(nums[0] > 0)
	{
		maxm = nums[0];
		sort(n.rbegin(), n.rend());
		maxAns[0] = maxAns[1] = n;
		for(int i = 0; i < n.size(); i++)
		{
			maxAns[0][i] -= '0';
			maxAns[1][i] -= '0';
		}
	}
	int sz = n.size();
	int cn;
	for(int i = 1; i < 10; i++)
	{
		vector<int> cnts1(nums);
		vector<int> cnts2(nums);
		if(cnts1[i] == 0)
			continue;
		cnts1[i]--;
		if(cnts2[(10 - i) % 10] == 0)
			continue;
		cnts2[(10 - i) % 10]--;
		int tmp = 1;
		if(cnts1[0] > cnts2[9] && cnts1[9] < cnts2[0])
		{
			tmp += min(cnts1[0] - cnts2[9], cnts2[0] - cnts1[9]);
		}
		for(int j = 0; j < 10; j++)
		{
			tmp += min(cnts1[j], cnts2[9 - j]);
		}
		if(tmp > maxm)
		{
			maxm = tmp;
			int idx = sz - 1;
			if(cnts1[0] > cnts2[9] && cnts1[9] < cnts2[0])
			{
				cn = min(cnts1[0] - cnts2[9], cnts2[0] - cnts1[9]);
				for(int j = 0; j < cn; j++)
				{
					maxAns[0][--idx] = 0;
					maxAns[1][idx] = 0;
					cnts1[0]--;
					cnts2[0]--;
				}
			}
			maxAns[0][idx] = i;
			maxAns[1][idx] = (10 - i) % 10;

			for(int j = 0; j < 10; j++)
			{
				cn = min(cnts1[j], cnts2[9 - j]);
				for(int k = 0; k < cn; k++)
				{
					maxAns[0][--idx] = j;
					maxAns[1][idx] = 9 - j;
					cnts1[j]--;
					cnts2[9 - j]--;
				}
			}
			idx = 0;
			for(int j = 0; j < 10; j++)
			{
				for(int k = 0; k < cnts1[j]; k++)
				{
					maxAns[0][idx++] = j;
				}
			}
			idx = 0;
			for(int j = 0; j < 10; j++)
			{
				for(int k = 0; k < cnts2[j]; k++)
				{
					maxAns[1][idx++] = j;
				}
			}
		}
	}
	for(int i = 0; i < n.size(); i++)
	{
		maxAns[0][i] += '0';
		maxAns[1][i] += '0';
	}
	cout << maxAns[0] << endl;
	cout << maxAns[1] << endl;
	return 0;
}

#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
int cnt[10];

void solve() {
	cin >> S; N = sz(S);
	rep(i, 0, N) {
		cnt[S[i] - '0']++;
	}
	int res = cnt[0];
	string t, u;
	rep(i, 1, 10) {
		rep(j, 0, cnt[i]) {
			t += char('0' + i);
			u += char('0' + i);
		}
	}
	rep(i, 0, cnt[0]) {
		t += '0';
		u += '0';
	}
	rep(i, 1, 10) {
		int j = 10 - i;
		int tmp = 1;
		string ss, tt; //garbage
		string rs, rt; //core

		if(!cnt[i] || !cnt[j]) continue;
		int z1 = 0, z2 = 0;

		rep(a, 0, 10) {
			int b = 9 - a;
			int v = cnt[a] - (i == a);
			int w = cnt[b] - (j == b);
			if(a == 0) z1 += max(v - w, 0);
			if(b == 0) z2 += max(w - v, 0);
			tmp += min(v, w);
			rep(j, 0, min(v, w)) {
				rs += char('0' + a);
				rt += char('0' + b);
			}
			if(a != 0) rep(j, 0, v - min(v, w)) ss += char('0' + a);
			if(b != 0) rep(j, 0, w - min(v, w)) tt += char('0' + b);
		}
		rs += char('0' + i);
		rt += char('0' + j);
		tmp += min(z1, z2);
		rep(j, 0, min(z1, z2)) {
			rs += '0'; rt += '0';
		}
		rep(j, 0, z1 - min(z1, z2)) ss += '0';
		rep(j, 0, z2 - min(z1, z2)) tt += '0';
		if(tmp > res) {
			res = tmp;
			t = ss + rs;
			u = tt + rt;
		}
	}
	cout << t << "\n" << u << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100010
using namespace std;
string str;
int num[10];
int main()
{
    int i,j;
    cin>>str;
    int len=str.length();
    for(i=0;i<len;i++)
    {
        num[str[i]-'0']++;
    }
    string sa,sb;
    int mx=-1;
    sa="";
    sb="";
    int numa[10],numb[10];
    for(i=1;i<10;i++)
    {
         string s1,s2;
         for(j=0;j<10;j++)
         {
            numa[j]=numb[j]=num[j];
         }
        s1="";
        s2="";
        int cur=0;
        if(numa[i]&&numb[10-i])
        {
            numa[i]--;
            numb[10-i]--;
            s1+='0'+i;
            s2+='0'+10-i;
            cur++;
            for(j=0;j<10;j++)
            {
                while(numa[j]&&numb[9-j])
                {
                    numa[j]--;
                    numb[9-j]--;
                    s1+='0'+j;
                    s2+='0'+9-j;
                    cur++;
                }
            }
        }
        int mi=min(numa[0],numb[0]);
        cur+=mi;
        s1=string(mi,'0')+s1;
        s2=string(mi,'0')+s2;
        numa[0]-=mi;
        numb[0]-=mi;

        for(j=0;j<10;j++)
        {
             if(numa[j]) s1+=string(numa[j],'0'+j);
             if(numb[j]) s2+=string(numb[j],'0'+j);
        }
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        if(cur>mx)
        {
            mx=cur;
            sa=s1;
            sb=s2;
        }

    }
    cout<<sa<<endl;
    cout<<sb<<endl;
   //while(1);
}

#include <bits/stdc++.h>
using namespace std;

char A[100010];
int Cnt[10];
int Cnt2[10];
int N;

char B[100010];

int f(int index){
    int used[10] = {0};
    int used2[10] = {0};
    if(Cnt[index]>0&&Cnt2[10-index]>0){
        used[index] = 1;
        used2[10-index] = 1;
    }else{
        return -1;
    }

    int ans = 1;
    for(int i=0;i<=9;++i)if(Cnt[i]-used[i]&&Cnt2[9-i]-used2[9-i]){
        int cnt = min(Cnt[i]-used[i],Cnt2[9-i]-used2[9-i]);
        used[i] += cnt;
        used2[9-i] += cnt;
        ans += cnt;
    }
    return ans;
}

char Zero[100010];
int main(){
    //freopen("1.txt","r",stdin);
	scanf("%s",A);

	N = strlen(A);
    for(char *p=A;*p;++p)++Cnt[*p-'0'];
    copy(Cnt,Cnt+10,Cnt2);

    ///找最多的0
    int idx, tmp, ans = -1;
    for(int i=1;i<=9;++i){
        if(ans<(tmp=f(i))){
            ans = tmp;
            idx = i;
        }
    }
    //printf("%d %d\n", ans, idx);

    int k = N;
    ///先写10
    if(ans!=-1){
        A[k-1] = idx + '0';
        B[k-1] = 10 - idx + '0';
        --Cnt[idx];--Cnt2[10-idx];
        --k;
        ///再写9
        for(int i=0;i<=9;++i){
            int cnt = min(Cnt[i],Cnt2[9-i]);
            fill(A+k-cnt,A+k,i+'0');
            fill(B+k-cnt,B+k,9-i+'0');
            Cnt[i]-=cnt;
            Cnt2[9-i]-=cnt;
            k -= cnt;
        }
    }

    ///再写剩下的0
    int cnt = min(Cnt[0],Cnt2[0]);
    Cnt[0]-=cnt;Cnt2[0]-=cnt;
    fill(Zero,Zero+cnt,'0');
    Zero[cnt] = '\0';

    ///再把剩下的堆上
    int k1 = k, k2 = k;
    for(int i=0;i<=9;++i){
        if(Cnt[i]){
            fill(A+k1-Cnt[i],A+k1,i+'0');
            k1 -= Cnt[i];
        }
        if(Cnt2[i]){
            fill(B+k2-Cnt2[i],B+k2,i+'0');
            k2 -= Cnt2[i];
        }
    }
    A[N] = B[N] = '\0';
    printf("%s%s\n%s%s\n",A+cnt,Zero,B+cnt,Zero);
	return 0;
}

/*
 * Digits Permutations.cpp
 *
 *  Created on: May 11, 2014
 *      Author: abdelkarim
 */
#include <bits/stdc++.h>

using namespace std;

int main() {
    vector<int> d1(10, 0), d2, d3;
    string s, res1, res2, A, B;
    int Max = -1;

    cin >> s;

    for (int i = 0; i < (int) s.size(); i++)
        d1[s[i] - '0']++;

    for (int i = 1; i <= 9; i++) {
        d3 = d2 = d1;
        int cnt0 = 0;
        A = B = "";
        if (d2[i] && d3[10 - i]) {
            A += (char) (i + '0');
            B += (char) (10 - i + '0');
            d2[i]--;
            d3[10 - i]--;
            cnt0++;
            for (int j = 0; j < 10; j++) {
                int Min = min(d2[j], d3[9 - j]);
                d2[j] -= Min;
                d3[9 - j] -= Min;
                A = string(Min, (char) (j + '0')) + A;
                B = string(Min, (char) (9 - j + '0')) + B;
                cnt0 += Min;
            }
        }

        int Min = 0;
        if (d2[0] && d3[0]) {
            Min = min(d2[0], d3[0]);
            A += string(Min, '0');
            B += string(Min, '0');
            cnt0 += Min;
            d2[0] -= Min, d3[0] -= Min;
        }

        for (int j = 0; j < 10; j++) {
            A = string(d2[j], (char) (j + '0')) + A;
            B = string(d3[j], (char) (j + '0')) + B;
        }
        if (cnt0 > Max) {
            Max = cnt0;
            res1 = A;
            res2 = B;
        }
    }
    cout << res1 << endl;
    cout << res2 << endl;
}

//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;

int num1[10], num2[10], res = -1, mx = -1;
string s;
vector <int> v1, v2;

bool sMax (int &a, int b){
    if (a < b) return a = b, 1;
    return 0;
}

void print () {
    while (num1[0] > num2[0]) num1[0] --, v1.push_back(0);
    while (num1[0] < num2[0]) num2[0] --, v2.push_back(0);
    for (int i = v1.size() - 1 ; ~i ; i --) cout << v1[i];
    while (num1[0]) cout << 0, num1[0] --;
    cout << '\n';
    for (int i = v2.size() - 1 ; ~i ; i --) cout << v2[i];
    while (num2[0]) cout << 0, num2[0] --;
    return ;
}

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> s;
    for (int i = 0 ; i < s.size() ; i ++){
        num1[s[i] - '0'] ++, num2[s[i] - '0'] ++;
    }

    for (int i = 1 ; i < 10 ; i ++){
        if (num1[i] && num2[10 - i]){
            num1[i] --, num2[10 - i] --;
            int tmp = 1;
            for (int i = 0 ; i < 5 ; i ++) tmp += min(num1[i], num2[9 - i]) + min(num2[i], num1[9 - i]);
            if (sMax(mx, tmp)){
                res = i;
            }
            num1[i] ++, num2[10 - i] ++;
        }
    }

    if (res == -1){
        for (int i = 1 ; i < 10 ; i ++){
            while (num1[i]){
                num1[i] --;
                v1.push_back(i);
            }
            while (num2[i]){
                num2[i] --;
                v2.push_back(i);
            }
        }
        print();
        return 0;
    }

    v1.push_back(res), v2.push_back(10 - res);
    num1[res] --, num2[10 - res] --;
    cerr << v1.size() << ' ' << v2.size() << ' ' << v1[v1.size() - 1] << ' ' << v2[v2.size() - 1] << '\n';
    cerr << res << ' ' << num1[res] << '\n';
    for (int i = 0 ; i < 10 ; i ++){
        while (num1[i] && num2[9 - i]){
            num1[i] --, num2[9 - i] --;
            v1.push_back(i), v2.push_back(9 - i);
        }
        while (num2[i] && num1[9 - i]){
            num2[i] --, num1[9 - i] --;
            v2.push_back(i), v1.push_back(9 - i);
        }
    }

    for (int i = 1 ; i < 10 ; i ++){
        while (num1[i]){
            num1[i] --;
            v1.push_back(i);
        }
        while (num2[i]){
            num2[i] --;
            v2.push_back(i);
        }
    }
    print();
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define Max_N 100000

static int ndigits1[10],ndigits2[10];
char DP1[Max_N+1],DP2[Max_N+1];
static int n=0;

int min(int a,int b)
{
 return (a<b)?a:b;
}

void Digits_Permutations()
{
 char digit;

 while((digit=getchar())!='\n')
 {
  ndigits1[digit-'0']++;
  ndigits2[digit-'0']++;
  n++;
 }

 int flag=0;
 int nzero=0;
 int i,j;

 for(i=1;i<10;i++)
 {
  if(!ndigits1[i]||!ndigits2[10-i])
   continue;

  int curnzero=1;

  ndigits1[i]--;
  ndigits2[10-i]--;

  for(j=0;j<10;j++)
   curnzero+=min(ndigits1[j],ndigits2[9-j]);

  curnzero+=(min(ndigits1[0]-ndigits2[9],ndigits2[0]-ndigits1[9])>0)?min(ndigits1[0]-ndigits2[9],ndigits2[0]-ndigits1[9]):0;

//  printf("%d %d\n",i,curnzero);

  if(curnzero>nzero)
  {
   flag=i;
   nzero=curnzero;
  }

  ndigits1[i]++;
  ndigits2[10-i]++;
 }

 if(flag)
 {
  ndigits1[flag]--;
  ndigits2[10-flag]--;
 }

 DP1[n]=DP2[n]='\0';

 i=n-1;

 for(j=min(ndigits1[0]-ndigits2[9],ndigits2[0]-ndigits1[9]);j>0;j--,i--,ndigits1[0]--,ndigits2[0]--)
  DP1[i]=DP2[i]='0';

 if(flag)
 {
  DP1[i]=flag+'0';
  DP2[i]=10-flag+'0';
  i--;
 }

 for(j=0;j<10;j++)
  while(ndigits1[j]&&ndigits2[9-j])
  {
   DP1[i]=j+'0';
   DP2[i]=9-j+'0';
   i--;

   ndigits1[j]--;
   ndigits2[9-j]--;
  }

 int cur=i;

 for(j=0;j<10;j++)
  while(ndigits1[j])
  {
   DP1[i--]=j+'0';
   ndigits1[j]--;
  }

 i=cur;

 for(j=0;j<10;j++)
  while(ndigits2[j])
  {
   DP2[i--]=j+'0';
   ndigits2[j]--;
  }

 printf("%s\n%s\n",DP1,DP2);

// system("pause");
}

int main()
{
 Digits_Permutations();
 return 0;
}

//CODER: Balajiganapathi
#include <algorithm>
#include <bitset>
#include <deque>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PI;
typedef vector<string> VS;

#define ST          first
#define SE          second
#define ALL(x)      (x).begin(), (x).end()
#define ini(a, v)   memset(a, v, sizeof(a))
#define RE(i,s,n)  	for(int i=s;i<(n);++i)
#define fr(i,n)     RE(i,0,n)
#define TR(i,x)     for(typeof(x.begin()) i=x.begin();i!=x.end();++i)
#define PU          push_back
#define MP          make_pair
#define sz(x)       (int)(x.size())
#define INF		2000000009

#define mx 100005
int cnt[10], cnt1[10], cnt2[10];
char num[mx];
deque<int> n1, n2;
int best, best_score, tot;

void put(int back, int a, int b) {
	//cout << a << " " << b << endl;
	if(back) {
		n1.push_back(a); n2.push_back(b);
	} else {
		n1.push_front(a); n2.push_front(b);
	}
	--cnt1[a]; --cnt2[b];
}

int solve(int d) {
	n1.clear(); n2.clear();
	fr(i, 10) cnt1[i] = cnt2[i] = cnt[i];

	int ret = 0;

	int nd = (10 - d) % 10;
	if(cnt1[d] == 0 || cnt2[nd] == 0) return -1;
	put(0, d, nd); ++ret;

	if(d == 0) {
		goto AddZeros;
		//while(cnt1[0] && cnt2[0]) {++ret; put(1, 0, 0); }
	}

	while(1) {
		int add1 = -1;
		fr(i, 10) if(cnt1[i] && cnt2[9 - i]) add1 = i;
		if(add1 == -1) break;
		put(0, add1, 9 - add1);
		++ret;
	}

	AddZeros:

	while(cnt1[0] && cnt2[0]) {++ret; put(1, 0, 0); }

	fr(i, 10) while(cnt1[i]--) n1.push_front(i);
	fr(i, 10) while(cnt2[i]--) n2.push_front(i);

	return ret;
}

int main() {
	scanf("%s", num);
	tot = strlen(num);
	fr(i, tot) cnt[num[i] - '0']++;

	best = best_score = -1;
	//init();
	//best_score = solve();
	fr(d, 10) {
		int tmp = solve(d);
		if(tmp > best_score) {
			best = d;
			best_score = tmp;
		}
	}

	if(best_score == -1) {
		printf("%s\n%s", num, num);
	} else {
		solve(best);
		assert(sz(n1) == tot && sz(n2) == tot);
		fr(i, tot) {
			printf("%d", n1.front());
			n1.pop_front();
		}
		printf("\n");
		fr(i, tot) {
			printf("%d", n2.front());
			n2.pop_front();
		}
	}
	return 0;
}

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

inline int RD(){ int x; RD(x); return x;}
template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline void RC(char &c){scanf(" %c", &c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 0x7fffffff;
const DB PI = acos(-1.0);
const DB EPS = 1e-6;
const DB OO = 1e15;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,

inline bool _1(int x, int i){return x & 1<<i;}
inline int _1(int i){return 1<<i;}
inline int _U(int i){return _1(i) - 1;};

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

int ____Case;
template<class T> inline void OT(const T &x){
    //cout << x << endl;
    printf("%d\n", x);
    //printf("%.2lf\n", x);
    //printf("Case %d: %d\n", ++____Case, x);
}

#define For_each(it, A) for (SII::iterator it = A.begin(); it != A.end(); ++it)

/* .................................................................................................................................. */

int a[10], b[10]; string s;
int r, rr, x, y, xx, yy, zero;

void calc(int x){
    int y = 10 - x; if (!a[x] || !a[y]) return;
    int r = 1; REP(i, 10) r += min(a[i] - (i == x), a[9-i] - (9-i == y));
    if (r > rr) rr = r, xx = x, yy = y;
}

int main(){

    //freopen("in.txt", "r", stdin);

    cin >> s; REP(i, SZ(s)) ++a[s[i] - '0'];

    r = -1, x = y = s[0] - '0'; FOR_1(i, 0, a[0]){
        a[0] -= i, rr = 0, xx = yy = s[0] - '0';
        calc(1), calc(2), calc(3), calc(4), calc(5);
        if (rr + i > r) r = rr + i, zero = i, x = xx, y = yy;
        a[0] += i;
    }

   // cout << r << " " << x << " " << zero << endl;

    if (!x) --zero; a[0] -= zero; CPY(b, a); --a[x], --b[y];

    REP(i, 10) REP(j, a[i] - min(a[i], b[9-i])) printf("%d", i);
    REP(i, 10) REP(j, min(a[i], b[9-i])) printf("%d", i);
    if (a[x] >= 0) printf("%d", x); REP(i, zero) putchar('0'); puts("");

    REP(i, 10) REP(j, b[9-i] - min(a[i], b[9-i])) printf("%d", 9-i);
    REP(i, 10) REP(j, min(a[i], b[9-i])) printf("%d", 9-i);
    if (b[y] >= 0) printf("%d", y); REP(i, zero) putchar('0'); puts("");
}

#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <cstdio>
using namespace std;
string s;
int a[10];
int aa[10],bb[10];
int solve(int k){
	for(int i=0;i<10;i++) aa[i] = a[i];
	for(int i=0;i<10;i++) bb[i] = a[i];

	if(aa[k]==0) return -1;
	aa[k]--;
	if(bb[(10-k)%10]==0) return  -1;
	bb[(10-k)%10]--;

	int res = 1;
	for(int i=0;i<10;i++){
		res += min(aa[i],bb[9-i]);
	}
	res += aa[0];
	return res;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
	//freopen("in","r",stdin);
	cin>>s;
	for(int i=0;i<s.length();i++){
		a[(int)s[i] - '0']++;
	}
	int ans = -1;
	int ind = 0;
	for(int i=1;i<10;i++){
	    int kek = solve(i);
		if(kek>ans){
			ans = kek;
			ind = i;
		}
	}
	if(ans == -1){
		for(int i=0;i<s.length();i++){
			if(s[i] != '0') cout<<s[i];
		}
		for(int i=0;i<a[0];i++){
			cout<<'0';
		}
		cout<<endl;
		for(int i=0;i<s.length();i++){
			if(s[i] != '0') cout<<s[i];
		}
		for(int i=0;i<a[0];i++){
			cout<<'0';
		}
	}
	else{
		for(int i=0;i<10;i++) aa[i] = a[i];
		for(int i=0;i<10;i++) bb[i] = a[i];
		string resa = "",resb = "";
		resa = (char)((int)'0'+ ind) + resa;
		aa[ind]--;

		bb[(10-ind)%10]--;
		resb = (char)((int)'0'+ 10 - ind) + resb;

		int res = 1;
		for(int i=0;i<10;i++){
			int lol = min(aa[i],bb[9-i]);
			aa[i] -= lol;
			bb[9-i] -= lol;
			for(int j=0;j<lol;j++){
				resa = (char)((int)'0'+ i) + resa;
				resb = (char)((int)'0'+ 9 - i) + resb;
			}
		}
		int s0 = min(aa[0],bb[0]);
		for(int i=0;i<10;i++){
			if(i!=0){
				for(int j=0;j<aa[i];j++){
					resa = (char)((int)'0'+ i) + resa;
				}
			}
			else{
				for(int j=0;j<aa[0]-s0;j++){
				resa = (char)((int)'0'+ i) + resa;
			}
		}

		}
		for(int i=0;i<10;i++){
			if(i!=0){
				for(int j=0;j<bb[i];j++){
					resb = (char)((int)'0'+ i) + resb;
				}
			}
			else{
				for(int j=0;j<bb[0]-s0;j++){
				resb = (char)((int)'0'+ i) + resb;
			}
		}

		}
		for(int i=0;i<s0;i++){
			resa  += '0';
			resb  += '0';
		}
		//cout<<ans<<endl;
		cout<<resa<<endl;
		cout<<resb<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

const int maxi=1e6+10;
string s, bfAns, bsAns, csAns,cfAns;
int n;
int cnt[maxi];
int cur1[maxi], cur2[maxi];
int bestZero, curZero;
void again()
{
    for (int i=0; i<=9; i++)
    {
        cur1[i]=cnt[i];
        cur2[i]=cnt[i];
    }
}

void solve(int x)
{
    curZero = 1;

    csAns = "";
    cfAns = "";

    cur1[x]--;
    cur2[10-x]--;

    int v10 = cur1[0]-cur1[9];
    int v20 = cur2[0]-cur2[9];
    for (int i=1; i<=max(0, min(v10,v20));i++)
    {
        cfAns+='0';
        csAns+='0';
        cur1[0]--;
        cur2[0]--;
        curZero++;
    }

     cfAns+='0'+x;
     csAns+='0'+(10-x);

        for (int i=0; i<=9; i++)
        {
            while(cur1[i] && cur2[9-i])
            {
                cur1[i]--;
                cur2[9-i]--;
                curZero++;
                cfAns+='0'+i;
                csAns+='9'-i;
            }
        }

    for (int i=0; i<=9; i++)
        for (int j=1; j<=cur1[i]; j++)
            cfAns+='0'+i;

    for (int i=0; i<=9; i++)
        for (int j=1; j<=cur2[i]; j++)
            csAns+='0'+i;

    reverse(csAns.begin(),csAns.end());
    reverse(cfAns.begin(),cfAns.end());

    return;
}
int main()
{
    cin>>s;

    n =s.size();

    for (int i=0; i<n; i++)
        cnt[s[i]-'0']++;

    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());

    bfAns = s;
    bsAns = s;
    bestZero = cnt[0];

    for (int i=1; i<=9; i++){
        again();
        if (cnt[i] && cnt[10-i])
        {
            solve(i);
            if (bestZero<curZero)
            {
                bestZero = curZero;
                bfAns = cfAns;
                bsAns = csAns;
            }
        }
    }
     cout<<bfAns<<endl;
     cout<<bsAns<<endl;
    return 0;
}
//stvari lagane

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define ld long double
#define FOR(n) for(int i=0;i<n;i++)
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{
    string a;
    cin>>a;
    ll n = a.size();
    ll cnt[10];
    memset(cnt , 0 , sizeof(cnt));
    for(ll i=0;i<n;i++) cnt[a[i] - '0']++;
    ll mx = 0;
    string ans1 , ans2;
    for(ll i=1;i<10;i++)
    {
        ll x = i , y = 10 - i;
        if(cnt[x]==0 || cnt[y]==0) continue;
        ll cnt1[10] , cnt2[10];
        for(ll j=0;j<10;j++) cnt1[j] = cnt[j];
        for(ll j=0;j<10;j++) cnt2[j] = cnt[j];
        cnt1[x]--;
        cnt2[y]--;
        ll c = 0;
        for(ll j=0;j<10;j++)
        {
            c+=min(cnt1[j] , cnt2[9-j]);
        }
        c++;
        if(c > mx)
        {
            mx = c;
            ans1.clear();
            ans2.clear();
            ans1.pb('0' + x);
            ans2.pb('0' + y);
            for(ll j=0;j<10;j++)
            {
                ll mn = min(cnt1[j] , cnt2[9-j]);
                if(mn==0) continue;
                for(ll k=0;k<mn;k++)
                {
                    ans1.pb('0' + j);
                }
                for(ll k=0;k<mn;k++)
                {
                    ans2.pb('0' + (9 - j));
                }
                cnt1[j]-=mn;
                cnt2[9-j]-=mn;
            }
            string res = "";
            for(ll j=0;j<min(cnt1[0] , cnt2[0]);j++)
            {
                res+='0';
            }
            ll mm = min(cnt1[0] , cnt2[0]);
            cnt1[0]-=mm;
            cnt2[0]-=mm;
            for(ll j=0;j<10;j++)
            {
                while(cnt1[j] > 0)
                {
                    ans1.pb('0' + j);
                    cnt1[j]--;
                }
                while(cnt2[j] > 0)
                {
                    ans2.pb('0' + j);
                    cnt2[j]--;
                }
            }
            reverse(all(ans1));
            reverse(all(ans2));
            ans1+=res;
            ans2+=res;
        }
    }
    ll sz = ans1.size();
    if(sz==0)
    {
        sort(rall(a));
        for(ll i=0;i<n;i++)
        {
            ans1.pb(a[i]);
            ans2.pb(a[i]);
        }
    }
    cout<<ans1<<endl<<ans2;
}

int main()
{
	FIO;
	ll t;
	//cin>>t;
	t = 1;
	while(t--) solve();
}

//#include "stdafx.h"

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define fo(i,j,n) for(i=j;i<n;++i)
#define Fo(i,j,n) for(i=n-1;i>=j;--i)
#define foo(i,j,v) fo(i,j,sz(v))
#define Foo(i,j,v) Fo(i,j,sz(v))
#define li(v) v.begin(),v.end()
#define sz(v) ((int)v.size())
#define CLR(a,v) memset((a),(v),sizeof(a))
#define inf 1000000001
//typedef long long Long;
typedef __int64 Long;
#define pi (2*acos(0))
#define eps 1e-9

#define two(X) (1<<(X))
#define twoL(X) (((Long)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)

char BUFFER[100000 + 5];
bool readn(int &n)	{ return scanf("%d",&n) == 1; }
bool readl(Long &n)	{ return scanf("%I64d",&n) == 1; }
bool readd(double &n){ return scanf("%lf",&n) == 1; }
bool reads(string &s){ s = ""; int n = scanf("%s",BUFFER); if(n == 1)s = BUFFER; return n == 1; }
bool readln(string &s){ char *valid = gets(BUFFER); if(valid)s = BUFFER; return ((bool)valid); }

string s,s1,s2;

int getv(vector<int> d1,vector<int> d2)
{
	int su = 1,i,j,mi;
	fo(i,0,10)
	{
		j = 9 - i; if(d1[i] && d2[j]){ mi = min(d1[i],d2[j]); su += mi;  d1[i] -= mi; d2[j] -= mi; }
	}
	su += min(d1[0],d2[0]);
	return su;
}

vector<int> d1(10,0),d2(10,0);

int main()
{
	//freopen("D://input.txt","r",stdin);
	reads(s); int ii,jj,i,j,k,carry = 0,mi,su,ma = 0; foo(i,0,s){ d1[s[i]-'0']++; d2[s[i]-'0']++; } s1 = s2 = "";
	fo(i,0,10)fo(j,0,10)if(d1[i] && d2[j])if((i+j) == 10)
		{ d1[i]--; d2[j]--; su = getv(d1,d2); if(su > ma){ ma = su; ii = i; jj = j; } d1[i]++; d2[j]++; }

	if(ma == 0)
	{
		sort(li(s)); reverse(li(s)); cout << s << endl << s << endl; return 0;
	}
	carry = 1; s1 += (ii+'0'); s2 += (jj+'0'); d1[ii]--; d2[jj]--;
	foo(k,1,s)
	{
		Fo(i,0,6)
		{
			j = (10-(i+carry)); if(j > 9)continue;
			if(d1[i] > 0 && d2[j] > 0)
			{
				d1[i]--; d2[j]--; s1 += (i+'0'); s2 += (j+'0'); carry = 1; break;
			}

			if(d2[i] > 0 && d1[j] > 0)
			{
				d2[i]--; d1[j]--; s2 += (i+'0'); s1 += (j+'0'); carry = 1; break;
			}
		}
		if(i < 0)break;
	}
	mi = min(d1[0],d2[0]); d1[0] -= mi; d2[0] -= mi;
	fo(i,0,10)
	{
		while(d1[i] > 0){ s1 += (i+'0'); d1[i]--; }
		while(d2[i] > 0){ s2 += (i+'0'); d2[i]--; }
	}
	reverse(li(s1)); reverse(li(s2));
	s = string(mi,'0'); s1 += s; s2 += s;

	cout << s1 << endl << s2;

	printf("\n");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <complex>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
void chmin(T &x, T y) {
    x = min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
    x = max(x, y);
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}

//-----------------------------------------------------------------------------

int main() {
    //srand(time(NULL));

    retry:

#ifdef LOCAL
    // gen();
    //cerr << 1 << endl;
    freopen("a.in", "r", stdin);
#else
    //freopen("fract.in", "r", stdin);
    //freopen("fract.out", "w", stdout);
#endif

    int cnt[2][10];
    memset(cnt, 0, sizeof cnt);

    string s;
    cin >> s;

    for (char c : s) {
        cnt[0][c - '0']++;
        cnt[1][c - '0']++;
    }

    string ans[2];

    pair<int,int> bst(-1, -1);

    for (int i = 1; i <= 9; i++) {
        int j = 10 - i;

        if (cnt[0][i] && cnt[1][j]) {
            cnt[0][i]--;
            cnt[1][j]--;

            int res = 0;
            for (int h = 0; h <= 9; h++) {
                res += min(cnt[0][h], cnt[1][9 - h]);
            }

            chmax(bst, mp(res, i));

            cnt[0][i]++;
            cnt[1][j]++;
        }
    }

    if (bst.fst != -1) {

        cnt[0][bst.snd]--;
        cnt[1][10 - bst.snd]--;

        ans[0] += '0' + bst.snd;
        ans[1] += '0' + 10 - bst.snd;

        while (true) {
            bool found = false;
            for (int i = 0; i <= 9; i++) {
                int j = 9 - i;
                if (cnt[0][i] && cnt[1][j]) {
                    cnt[0][i]--;
                    cnt[1][j]--;
                    ans[0] += '0' + i;
                    ans[1] += '0' + j;
                    found = true;
                    break;
                }
            }
            if (!found) {
                break;
            }
        }
    }

    reverse(ans[0].begin(), ans[0].end());
    reverse(ans[1].begin(), ans[1].end());

    while (cnt[0][0] && cnt[1][0]) {
        ans[0] += '0';
        ans[1] += '0';
        cnt[0][0]--;
        cnt[1][0]--;
    }

    reverse(ans[0].begin(), ans[0].end());
    reverse(ans[1].begin(), ans[1].end());

    for (int i = 0; i < 10; i++) {
        while (cnt[0][i]) {
            ans[0] += '0' + i;
            cnt[0][i]--;
        }

        while (cnt[1][i]) {
            ans[1] += '0' + i;
            cnt[1][i]--;
        }
    }

    reverse(ans[0].begin(), ans[0].end());
    reverse(ans[1].begin(), ans[1].end());

    cout << ans[0] << endl;
    cout << ans[1] << endl;

    return 0;
}

#include <string>
#include <vector>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

string s;
int n;
int count1[10];
int count2[10];
int backup[10];
int res;

int main() {
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i ++) {
    count1[s[i] - '0'] ++;
    count2[s[i] - '0'] ++;
  }
  for (int i = 0; i < 10; i ++)
    backup[i] = count1[i];

  string res1, res2;
  string per1, per2;
  res = 0;
  for (int i = 1; i < 10; i ++) {
    if (count1[i] > 0 && count2[10 - i] > 0) {
      count1[i] --;
      count2[10 - i] --;
      per1 = "";
      per2 = "";
      per1 = per1 + char(i + '0');
      per2 = per2 + char(10 - i + '0');
      int sum = 1;

      for (int j = 0; j < 10; j ++) {
	int t = min(count1[j], count2[9 - j]);
	sum += t;
	per1.insert(0, t, char(j + '0'));
	per2.insert(0, t, char(9 - j + '0'));
	count1[j] -= t;
	count2[9 - j] -= t;
      }
      int t = min(count1[0], count2[0]);
      per1.insert(per1.length(), t, '0');
      per2.insert(per2.length(), t, '0');
      sum += t;
      count1[0] -= t;
      count2[0] -= t;
      for (int j = 0; j < 10; j ++) {
	per1.insert(0, count1[j], char(j + '0'));
	per2.insert(0, count2[j], char(j + '0'));
      }

      if (res < sum) {
	res = sum;
	res1 = per1;
	res2 = per2;
      }
    }
    for (int j = 0; j < 10; j ++) {
      count1[j] = backup[j];
      count2[j] = backup[j];
    }
  }
  // for (int i = 1; i < 10; i ++) {
  //   if (count1[i] > 0 && count2[10 - i] > 0) {
  //     count1[i] --;
  //     count2[10 - i] --;
  //     per1 = "";
  //     per2 = "";
  //     per1 = per1 + char(i + '0');
  //     per2 = per2 + char(10 - i + '0');
  //     int sum = 1;

  //     for (int j = 1; j < 9; j ++) {
  // 	int t = min(count1[j], count2[9 - j]);
  // 	sum += t;
  // 	per1.insert(0, t, char(j + '0'));
  // 	per2.insert(0, t, char(9 - j + '0'));
  // 	count1[j] -= t;
  // 	count2[9 - j] -= t;
  //     }

  //     for (int j = 1; j < 10; j ++) {
  // 	per1.insert(0, count1[j], char(j + '0'));
  // 	per2.insert(0, count2[j], char(j + '0'));
  //     }

  //     per1.insert(per1.length(), count1[0], '0');
  //     per2.insert(per2.length(), count2[0], '0');

  //     sum += count1[0];
  //     if (res < sum) {
  // 	res = sum;
  // 	res1 = per1;
  // 	res2 = per2;
  //     }
  //   }
  //   for (int j = 0; j < 10; j ++) {
  //     count1[j] = backup[j];
  //     count2[j] = backup[j];
  //   }
  // }
  if (res == 0) {
    res1.insert(0, count1[0], '0');
    res2.insert(0, count2[0], '0');
    for (int j = 1; j < 10; j ++) {
      res1.insert(0, count1[j], char(j + '0'));
      res2.insert(0, count2[j], char(j + '0'));
    }
  }
  cout << res1 << endl << res2 << endl;
  return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int cnt[10];
int used[2][10];

bool better(int a1, int a2, int b1, int b2)
{
	int c1 = 0;
	int c2 = 0;
	if (cnt[a1] > cnt[9 - a1]) {
		++c1;
	}
	if (cnt[a2] > cnt[9 - a2]) {
		++c1;
	}
	if (cnt[b1] > cnt[9 - b1]) {
		++c2;
	}
	if (cnt[b2] > cnt[9 - b2]) {
		++c2;
	}
	return c1 > c2;
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		++cnt[s[i] - '0'];
	}
	int j = 0;
	pair<int, int> best;
	for (int i = 1; i <= 5; ++i) {
		if (cnt[i] && cnt[10 - i]) {
			if (!best.first || better(i, 10 - i, best.first, best.second)) {
				best = {i, 10 - i};
			}
		}
	}
	if (!best.first) {
		string ss(cnt[0], '0');
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] != '0') {
				ss += s[i];
			}
		}
		reverse(ss.begin(), ss.end());
		cout << ss << endl;
		cout << ss << endl;
	} else {
		string s1;
		string s2;
		s1 += '0' + best.first;
		s2 += '0' + best.second;
		++used[0][best.first];
		++used[1][best.second];
		int bad1 = -1;
		int bad2 = -1;
		if (cnt[best.first] <= cnt[9 - best.first]) {
			bad1 = best.first;
		}
		if (cnt[best.second] <= cnt[9 - best.second]) {
			bad2 = best.second;
		}
		//cout << "bad: " << bad1 << ' ' << bad2 << endl;
		for (int i = 0; i <= 9; ++i) {
			//cout << "strings: " << i << ": " << s1 << ' ' << s2 << endl;
			int add1 = min(cnt[i], cnt[9 - i]);
			int add2 = min(cnt[i], cnt[9 - i]);
			if (i == bad1) {
				--add1;
			}
			if (9 - i == bad2) {
				--add2;
			}
			int add = min(add1, add2);
			used[0][i] += add;
			used[1][9 - i] += add;
			//cout << char('0' + i) << ' ' << char('0' + (9 - i)) << endl;
			s1 += string(add, '0' + i);
			s2 += string(add, '0' + (9 - i));
		}
		for (int i = 1; i <= 9; ++i) {
			s1 += string(cnt[i] - used[0][i], '0' + i);
			s2 += string(cnt[i] - used[1][i], '0' + i);
		}
		if (used[0][0] > used[1][0]) {
			s2 += string(used[0][0] - used[1][0], '0');
		} else if (used[1][0] > used[0][0]) {
			s1 += string(used[1][0] - used[0][0], '0');
		}
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
		s1 += string(cnt[0] - max(used[0][0], used[1][0]), '0');
		s2 += string(cnt[0] - max(used[0][0], used[1][0]), '0');
		cout << s1 << endl;
		cout << s2 << endl;
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string n;
    cin >> n;
    vector<int> a(10);
    for (int i = 0; i < (int)n.length(); ++ i) {
        ++ a[n[i]-'0'];
    }
    int r = a[0];
    int ry = 0, rz = a[0];
    for (int z = 0; z <= a[0]; ++ z) {
        for (int y = 1; y <= 9; ++ y) {
            if (a[y] && a[10-y]) {
                vector<int> X = a, Y = a;
                X[0] -= z; Y[0] -= z;
                -- X[y]; -- Y[10-y];
                int rr = z+1;
                for (int x = 0; x <= 9; ++ x) {
                    rr += min(X[x], Y[9-x]);
                }
                if (rr > r) { r = rr; rz = z; ry = y; }
            }
        }
    }
    vector<int> X = a;
    vector<int> Y = a;
    string sx(rz, '0');
    string sy(rz, '0');
    X[0] -= rz; Y[0] -= rz;
    if (ry) {
        sx += (char)('0'+ry);
        sy += (char)('0'+10-ry);
        -- X[ry]; -- Y[10-ry];
        for (int x = 0; x <= 9; ++ x) {
            int nx = min(X[x], Y[9-x]);
            sx += string(nx, (char)('0'+x));
            sy += string(nx, (char)('0'+9-x));
            X[x] -= nx; Y[9-x] -= nx;
        }
    }
    for (int i = 0; i < 10; ++ i) {
        for (int j = 0; j < X[i]; ++ j) sx += (char)('0'+i);
        for (int j = 0; j < Y[i]; ++ j) sy += (char)('0'+i);
    }
    reverse(sx.begin(),sx.end());
    reverse(sy.begin(),sy.end());
    cout << sx << endl;
    cout << sy << endl;
}

#include <sstream>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set>

using namespace std;

string s;
int n;
int a[10], b[10];
int a1[10], b1[10];

int main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++) {
		a[s[i] - '0']++;
		b[s[i] - '0']++;
	}
	long long ans = -1;
	int count = -1, pos = -1;
	for (int i = 0; i <= a[0]; i++) {
		for (int j = 0; j < 10; j++) {
			a1[j] = a[j];
			b1[j] = b[j];
		}
		a1[0] -= i;
		b1[0] -= i;
		for (int j = 1; j < 10; j++) {
			long long s1 = i;
			if (a1[j] > 0 && b1[10 - j] > 0) {
				a1[j]--;
				b1[10 - j]--;
				for (int k = 0; k < 10; k++) {
					s1 += min(a1[k], b1[9 - k]);
				}
				if (ans <= s1) {
					ans = s1;
					count = i;
					pos = j;
				}
				a1[j]++;
				b1[10 - j]++;
			}
		}
	}
	vector<int> v;
	vector<int> v1;
	if (count > 0) {
		for (int i = 0; i < count; i++) {
			v.push_back(0);
			v1.push_back(0);
		}
		a[0] -= count;
		b[0] -= count;
	}
	if (pos >= 0) {
		v.push_back(pos);
		v1.push_back(10 - pos);
		a[pos]--;
		b[10 - pos]--;
	}
	for (int i = 0; i < 10; i++) {
		while (min(a[i], b[9 - i]) > 0) {
			a[i]--;
			b[9 - i]--;
			v.push_back(i);
			v1.push_back(9 - i);
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < a[i]; j++) {
			v.push_back(i);
		}
		for (int j = 0; j < b[i]; j++) {
			v1.push_back(i);
		}
	}
	for (int i = v.size() - 1; i >= 0; i--) {
		cout << v[i];
	}
	cout << endl;
	for (int i = v1.size() - 1; i >= 0; i--) {
		cout << v1[i];
	}
	cout << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n,tmp,cnt1[10],cnt2[10],dig[10],ans,po,zero;
char s[101000];

int main()
{
  //  freopen("input.txt","r",stdin);

    cin>>s;
    n=strlen(s);
    ans=-1;
    for (int i=0;i<n;i++) { cnt1[int(s[i])-48]++;cnt2[int(s[i])-48]++; }
    for (int dif=1;dif<=5;dif++)
    {
  		if (cnt1[dif]==0 || cnt2[(10-dif)%10]==0) continue;
        tmp=0;
        cnt1[dif]--;cnt2[(10-dif)%10]--;
        for (int i=0;i<10;i++) tmp+=min(cnt1[i],cnt2[9-i]);
        if (tmp>ans) { ans=tmp;po=dif; }
        cnt1[dif]++;cnt2[(10-dif)%10]++;
    }
 //   if (ans==-1) cout<<s<<endl<<s<<endl;
  //  else {
    if (ans>=0) {  cnt1[po]--;cnt2[(10-po)%10]--;
    		for (int i=0;i<10;i++) { tmp=min(cnt1[i],cnt2[9-i]); cnt1[i]-=tmp; cnt2[9-i]-=tmp; dig[i]=tmp; }
    }
    zero=min(cnt1[0],cnt2[0]);
    cnt1[0]-=zero; cnt2[0]-=zero;

    for (int i=9;i>=0;i--) while (cnt1[i]) { cout<<i;cnt1[i]--; }
    for (int i=9;i>=0;i--) for (int j=1;j<=dig[i];j++) cout<<i;
    if (ans>=0) cout<<po;
    for (int i=1;i<=zero;i++) cout<<0;
    cout<<endl;

    for (int i=9;i>=0;i--) while (cnt2[i]) { cout<<i;cnt2[i]--; }
    for (int i=0;i<10;i++) for (int j=1;j<=dig[9-i];j++) cout<<i;
    if (ans>=0) cout<<(10-po)%10;
    for (int i=1;i<=zero;i++) cout<<0;
    cout<<endl;
   // }

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;

char s[100005], res1[100005], res2[100005];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    vi d1(10);
    for (int i = 0; i < n; ++i)
        d1[s[i] - '0']++;
    vi d2 = d1;
    int it = 0;
    res1[n] = res2[n] = '\0';
    int best = 1, bestzer = 0, ma = 0;
    for (int i = 1; i <= 5; ++i) if (d1[i] && d2[(10 - i) % 10]) {
        --d1[i]; --d2[(10 - i) % 10];
        int cnt = 1;
        for (int j = 0; j < 10; ++j)
            cnt += min(d1[j], d2[9 - j]);
        cnt += min(d1[0] - min(d1[0], d2[9]), d2[0] - min(d2[0], d1[9]));
        if (cnt > ma) {
            ma = cnt;
            best = i;
            bestzer = min(d1[0] - min(d1[0], d2[9]), d2[0] - min(d2[0], d1[9]));
        }
        ++d1[i]; ++d2[(10 - i) % 10];
    }
    bool ok = 0;
    for (; it < bestzer; ++it) {
        res1[n - 1 - it] = res2[n - 1 - it] = '0';
        --d1[0]; --d2[0];
    }
    for (int i = 0; i <= 5; ++i) if (d1[i] && d2[(10 - i) % 10] && i == best) {
        res1[n - 1 - it] = '0' + i;
        res2[n - 1 - it] = '0' + (10 - i) % 10;
        d1[i]--; d2[(10 - i) % 10]--;
        ok = 1;
        ++it;
        break;
    }
    if (ok) {
        for (int i = 0; i < 10; ++i) {
            while (d1[i] && d2[9 - i]) {
                res1[n - 1 - it] = '0' + i;
                res2[n - 1 - it] = '0' + 9 - i;
                d1[i]--; d2[9 - i]--;
                ++it;
            }
        }
    }
    int it2 = it;
    for (int i = 0; i < 10; ++i) {
        while (d1[i]) {
            res1[n - 1 - it] = '0' + i;
            d1[i]--;
            ++it;
        }
    }
    for (int i = 0; i < 10; ++i) {
        while (d2[i]) {
            res2[n - 1 - it2] = '0' + i;
            d2[i]--;
            ++it2;
        }
    }
    printf("%s\n%s\n", res1, res2);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define SZ(a) ((int)(a).size())
#define mset(a,b) memset(a,b,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define fst first
#define snd second

const int N=256;
int n,a[N],b[N],c[N],d[N];
string s;

void setup(string &s) {
  memset(a,0,sizeof(a));
  memset(b,0,sizeof(b));
  memset(c,0,sizeof(c));
  memset(d,0,sizeof(d));
  for(char k:s)a[k-'0']++,b[k-'0']++;
}

int get(string s,string t) {
  ll x=stoi(s);
  ll y=stoi(t);
  ll z=x+y;
  ll res=0;
  while(!(z%10))res++,z/=10;
  return res;
}
int brute(string s) {
  sort(s.begin(),s.end());
  int res=0;
  string t=s;
  do {
    do {
      res=max(res,get(s,t));
    } while (next_permutation(ALL(s)));
  }while(next_permutation(ALL(t)));
  return res;
}

pair<string,string>solve(string &s) {
  vector<pair<int,int>>v;
  pair<int,int>en={-1,-1};
  setup(s);
  fore(i,0,10)while(a[i]&&b[9-i])a[i]--,c[i]++,b[9-i]--,d[9-i]++;
  fore(i,0,10)if(a[i]&&b[10-i])en={i,10-i};
  if(en.fst<0) {
    fore(i,0,10)if(a[i]&&d[10-i])en={i,10-i};
    fore(i,0,10)if(b[i]&&c[10-i])en={i,10-i};
  }
  if(en.fst<0) {
    fore(i,0,10)if(c[i]&&d[10-i])en={i,10-i};
  }
  if(en.fst<0){sort(ALL(s));reverse(ALL(s));return {s,s};}
  setup(s);
  vector<pair<int,int>>res;
  vector<pair<int,int>>zero;
  res.pb({en.fst,en.snd});
  a[en.fst]--;
  b[en.snd]--;
  fore(i,0,10)while(a[i]&&b[9-i])a[i]--,b[9-i]--,res.pb({i,9-i});
  while(a[0]&&b[0])zero.pb({0,0}),a[0]--,b[0]--;
  fore(i,0,10)fore(j,0,10)while(a[i]&&b[j])res.pb({i,j}),a[i]--,b[j]--;
  reverse(res.begin(),res.end());
  for(auto it:zero)res.pb(it);
  // cout<<"a: ";for(auto it:res)cout<<it.fst<<" ";cout<<endl;
  // cout<<"b: ";for(auto it:res)cout<<it.snd<<" ";cout<<endl;
  string l="",r="";
  for(auto it:res){
    l+=('0'+it.fst);
    r+=('0'+it.snd);
  }
  return {l,r};
}

bool check(string &s) {
  pair<string,string>res=solve(s);
  string l=res.fst;
  string r=res.snd;
  int xx=get(l,r);
  int yy=brute(s);
  if(xx!=yy) {
    cout<<"Fail at: "<<s<<endl;
    cout<<"Expected "<<yy<<" got "<<xx<<" ("<<l<<","<<r<<")"<<endl;
    return 0;
  }
  return 1;
}
bool BRUTE=0;
int main() {
  ios::sync_with_stdio(false);
  if(BRUTE) {
    fore(i,1,10000){
      string s=to_string(i);
      check(s);
    }
  } else {
    cin>>s;
    pair<string,string>res=solve(s);
    cout<<res.fst<<endl<<res.snd<<endl;
  }
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

string s;
int cnt[10], cnt1[10];

void solveProblem() {
    for (auto it : s) {
        ++cnt[it - '0'];
        ++cnt1[it - '0'];
    }

    int ans = 0;
    pii last = {0, 0};
    REP(i, 1, 9) {
        int j = 10 - i;
        int cur = 0;
        if (cnt[i] && cnt1[j]) {
            cur = 1;
            REP(k, 0, 9) {
                int l = cnt[k];
                int r = cnt1[9 - k];
                if (k == i) --l;
                if (9 - k == j) --r;

                cur += min(l, r);
            }
        }

        if (cur > ans) {
            ans = cur;
            last = {i, j};
        }
    }

    string s1 = "", s2 = "";

    if (last.fi && last.se) {
        --cnt[last.fi], --cnt1[last.se];
        s1 += last.fi + '0', s2 += last.se + '0';

        REP(k, 0, 9) {
            REP(i, 1, min(cnt[k], cnt1[9 - k])) s1 += k + '0';
            REP(i, 1, min(cnt1[9 - k], cnt[k])) s2 += 9 - k + '0';
            int t = min(cnt[k], cnt1[9 - k]);
            cnt[k] -= t;
            cnt1[9 - k] -= t;
        }
    }

    REP(i, 1, 9) {
        REP(j, 1, cnt[i]) s1 += i + '0';
        REP(j, 1, cnt1[i]) s2 += i + '0';
    }

    while (s1.length() < s2.length()) s1 += '0', --cnt[0];
    while (s2.length() < s1.length()) s2 += '0', --cnt1[0];

    reverse(all(s1)); reverse(all(s2));

    REP(i, 1, cnt[0]) s1 += '0';
    REP(i, 1, cnt1[0]) s2 += '0';

    cout << s1 << endl;
    cout << s2 << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> s;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}

// God & me
// Don't forget me ...
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
template <class T, class L> inline bool smax(T &x, L y){  return x < y ? ( x = y, 1) : 0;  }
template <class T, class L> inline bool smin(T &x, L y){  return y < x ? ( x = y, 1) : 0;  }
typedef pair <int, int> pii;
typedef long long ll;
typedef double ld;

const int maxn = 5e5 + 17, z = 10;

string s, a, b;
int n, cnt[z], cp[z];
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> s, n = s.size();
    for(auto c : s)  cnt[c - '0'] ++;
    memcpy(cp, cnt, sizeof cnt);
    int mx = 0, cer = -1;
    for(int i = 1; i < z; i++){
	if(cnt[i] == 0 || cnt[10 - i] == 0)  continue;
	cnt[i]--, cp[10 - i]--;
	int c = 1;
	for(int i = 0; i < z; i++)
	    c += min(cnt[i], cp[9 - i]);
	if(smax(mx, c))  cer = i;
	cnt[i]++, cp[10 - i]++;
    }
    if(mx){
	cnt[cer]--, cp[10 - cer]--;
	a += cer + '0', b += 10 - cer + '0';
	for(int i = 0; i < z; i++){
	    int mn = min(cnt[i], cp[9 - i]);
	    a += string(mn, i + '0');
	    b += string(mn, 9 - i + '0');
	    cnt[i] -= mn, cp[9 - i] -= mn;
	}
	reverse(a.begin(), a.end()), reverse(b.begin(), b.end());
    }
    int lz = min(cnt[0], cp[0]);
    cout << string(cnt[0] - lz, '0');
    for(int i = 1; i < z; i++)  cout << string(cnt[i], i + '0');
    cout << a << string(lz, '0') << '\n';
    cout << string(cp[0] - lz, '0');
    for(int i = 1; i < z; i++)  cout << string(cp[i], i + '0');
    cout << b << string(lz, '0') << '\n';
    return 0;
}

#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI
const double eps = 1e-9;

string s;
int frq[12], frq2[12];
int frq3[12], frq4[12];
string s2, s3;
int mxcnt = -1;
void tri(int a, int b)
{
	string s4, s5;
	int cnt = 0;
	for(int i = 0; i <= 9; ++i)
		frq3[i] = frq[i], frq4[i] = frq2[i];
	while(frq3[0] > 0 && frq4[0] > 0)
		s4 += '0', s5 += '0', --frq3[0], --frq4[0], ++cnt;
	if(a != 0)
	{
		s4 += ('0' + a);
		s5 += ('0' + b);
		++cnt;
		--frq3[a], --frq4[b];
	}
	for(int i = 0; i <= 9; ++i)
		while(frq3[i] > 0 && frq4[9 - i] > 0)
		{
			s4 += ('0' + i);
			s5 += ('0' + 9 - i);
			++cnt;
			--frq3[i];
			--frq4[9 - i];
		}
	for(int i = 0; i <= 9; ++i)
		while(frq3[i] > 0)
			s4 += ('0' + i), --frq3[i];

	for(int i = 0; i <= 9; ++i)
		while(frq4[i] > 0)
			s5 += ('0' + i), --frq4[i];

	if(cnt > mxcnt)
	{
		mxcnt = cnt;
		s2 = s4;
		s3 = s5;
	}
}

void tri2(int a, int b)
{
	string s4, s5;
	int cnt = 0;
	for(int i = 0; i <= 9; ++i)
		frq3[i] = frq[i], frq4[i] = frq2[i];
	s4 += ('0' + a);
	s5 += ('0' + b);
	++cnt;
	--frq3[a], --frq4[b];
	for(int i = 0; i <= 9; ++i)
		while(frq3[i] > 0 && frq4[9 - i] > 0)
		{
			s4 += ('0' + i);
			s5 += ('0' + 9 - i);
			++cnt;
			--frq3[i];
			--frq4[9 - i];
		}
	if(frq3[0] > 0 && frq4[0] > 0)
	{
		string s6, s9;
		while(frq3[0] > 0 && frq4[0] > 0)
		{
			--frq3[0];
			--frq4[0];
			s6 += '0';
			s9 += '0';
			++cnt;
		}
		s4 = s6 + s4;
		s5 = s9 + s5;
	}
	for(int i = 0; i <= 9; ++i)
		while(frq3[i] > 0)
			s4 += ('0' + i), --frq3[i];

	for(int i = 0; i <= 9; ++i)
		while(frq4[i] > 0)
			s5 += ('0' + i), --frq4[i];
	if(cnt > mxcnt)
	{
		mxcnt = cnt;
		s2 = s4;
		s3 = s5;
	}
}
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> s;
	for(int i = 0; i < s.size(); ++i)
	{
		frq[s[i] - '0']++;
		frq2[s[i] - '0']++;
	}
	for(int i = 1; i <= 9; ++i)
		if(frq[i] && frq[10 - i])
			tri(i, 10 - i);
	if(frq[0])
		tri(0, 0);
	for(int i = 1; i <= 9; ++i)
		if(frq[i] && frq[10 - i])
			tri2(i, 10 - i);
	if(mxcnt == -1)
	{
		cout << s << '\n';
		cout << s << '\n';
		return 0;
	}
	reverse(s2.begin(), s2.end());
	reverse(s3.begin(), s3.end());
	cout << s2 << '\n';
	cout << s3 << '\n';
    return 0;
}

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(v)           ((v).begin()), ((v).end())
#define sz size()
#define clr(v,d)         memset(v,d,sizeof(v))
#define rep(i, v)        for(int i=0;i<(v).sz;++i)
#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define sci(a)	scanf("%d",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prii(a, b)	printf("%d %d\n",a, b)
#define DB1(a)          std::cout<<#a<<"="<<(a)<<endl
#define DB2(a,b)        std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<endl
#define DB3(a,b,c)      std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<endl
#define DB4(a,b,c,d)    std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<endl
#define DB5(a,b,c,d,e)  std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<endl
typedef pair<int, int> pii;
typedef long long ll;
const ll  inf = 1000000000000000000LL;
const double EPS = 1e-9;
const ll mod = 1000000007ll;
#define PI acos(-1)

const int maxn = 300500;

char st[maxn];
int cnt[10], cnt2[10];
int tcnt[10], tcnt2[10];

int main(){
#ifndef ONLINE_JUDGE
	freopen("CF.in", "rt", stdin);
#endif
	scanf("%s", st);
	int n = strlen(st);
	int be = -1;
	vector<int> br1, br2;
	for (int i = 0; i < n; i++) cnt[st[i] - '0']++, cnt2[st[i] - '0']++;
	bool c = 0;
	for (int a = 0; a < 10; a++) for (int b = 0; b < 10; b++) if (a + b == 10 && cnt[a] > 0 && cnt2[b] > 0){
		c = 1;
		deque<int> r1, r2;
		for (int i = 0; i < 10; i++) tcnt[i] = cnt[i], tcnt2[i] = cnt2[i];
		r1.push_back(a), r2.push_back(b), tcnt[a]--, tcnt2[b]--;
		int cur = 0;
		for (int i = 9; i >= 0; i--) for (int j = 9; j >= 0; j--) if (i + j == 9){
			while (tcnt[i] > 0 && tcnt2[j] > 0)
				r1.push_back(i), r2.push_back(j), tcnt[i]--, tcnt2[j]--, cur++;
		}
		while (tcnt[0] && tcnt2[0]) r1.push_front(0), r2.push_front(0), tcnt[0]--, tcnt2[0]--;
		if (cur > be){
			be = cur;
			br1.assign(r1.begin(), r1.end());
			br2.assign(r2.begin(), r2.end());
			for (int i = 0; i < 10; i++) {
				while (tcnt[i] > 0)	{
					br1.push_back(i);
					tcnt[i]--;
				}
				while (tcnt2[i] > 0)	{
					br2.push_back(i);
					tcnt2[i]--;
				}
			}
		}
	}
	if (!c){
		for (int i = 0; i < 10; i++) while(cnt[i] > 0) br1.push_back(i), cnt[i]--;
		for (int i = 0; i < 10; i++) while (cnt2[i] > 0) br2.push_back(i), cnt2[i]--;
	}
	reverse(br1.begin(), br1.end());
	reverse(br2.begin(), br2.end());
	for (int i : br1) printf("%d", i);
	puts("");
	for (int i : br2) printf("%d", i);
}

// ICPC champion is here
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<map>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<long double>
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-10);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}

deque< int >x  , y;
int cal(vector < int > A , vector < int > B , int beg)
{
	x.clear();
	y.clear();
	int cnt = 0;
	int start = 0;
	for(int i = beg; i < 10 ;i ++)
	{
		if(A[i] && B[10 - i])
        {
			A[i] --;
			B[10 - i] --;
			x.push_front(i);
			y.push_front(10 - i);
			start = 1;
			cnt ++;
			break;
		}
	}
	if(!start)
        return -1;
	for(int i = 0 ; i < 10; i ++)
	{
		while(A[i] && B[9 - i])
        {
			A[i] --;
			B[9 - i] --;
			x.push_front(i);
			y.push_front(9 - i);
			cnt ++;
		}
	}
	while(A[0] && B[0])
    {
		A[0] --;
		B[0] --;
		x.push_back(0);
		y.push_back(0);
		cnt ++;
	}
	for(int i = 0 ;i < 10 ;i ++)
    {
		while(A[i])
			x.push_front(i) , A[i] --;
		while(B[i])
			y.push_front(i) , B[i] --;
	}
	return cnt;
}
int main()
{

	string s ;
	cin >> s;
	vector< int > A(10), B(10);

	for(int i = 0 ;i < s.size() ;i ++)
		A[s[i] - '0'] ++ , B[s[i] - '0'] ++;

	bool start = 0;
	for(int i = 1; i < 10 ;i ++)
    {
		if(A[i] && B[10 - i])
			start = 1;
	}
	if(!start)
    {
		sort(s.rbegin() , s.rend());
		cout << s << endl << s << endl;
	}
	else
    {
		deque< int > a , b;
		int res = 0;
		for(int i = 1; i < 10 ; i ++)
        {
			int r = cal(A  , B , i);
			if(r > res)
			{
				res = r;
				a = x;
				b = y;
			}
		}
		for(int i = 0 ;i < a.size() ;i ++)
			cout << a[i] ;
		cout << endl;
		for(int i = 0 ;i < b.size() ;i ++)
			cout << b[i];
		cout << endl;
	}
}

/// *********************************************** K
/// B *                                           * H
/// I *    Solved By : Bir Bahadur Khatri(B'ru)   * A
/// R *      Be Positive,be Happy.                * T
/// U *                                           * R
/// *********************************************** I

#include<bits/stdc++.h>

#define LL long long int
#define ULL unsigned LL
#define PI 2.0*acos(0.0)
#define D double
#define sz size()
#define PB push_back
#define cp printf("***** here here here here *****\n");
#define NL printf("\n")
#define CHR getchar()
#define SQR(n) (n*n)
#define xx first
#define yy second
#define MEM(a,val) memset(a,val,sizeof(a))
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define S1(a) a=in<int>()
#define S2(a,b) a=in<int>(),b=in<int>()
#define S3(a,b,c) a=in<int>(),b=in<int>(),c=in<int>()
#define SL1(a) a=in<LL>()
#define SL2(a,b) a=in<LL>(),b=in<LL>()
#define SL3(a,b,c) a=in<LL>(),b=in<LL>(),c=in<LL>()
#define F(i,a,b) for(int i=a;i<b; i++)
#define R(i,a,b) for(int i=a-1;i>=b; i--)
#define all(a) a.begin(),a.end()
#define BitCnt(a) __builtin_popcountll(a)
#define InpOut freopen("A.in","r",stdin),freopen("A1.out","w",stdout)
#include <time.h>

using namespace std;
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T Dist(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template<typename T>inline T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
long long Bigmod(long long base, long long power, long long MOD){long long ret=1;while(power){if(power & 1)ret=(ret*base)%MOD;base=(base*base)%MOD;power>>=1;}return ret;}
long long ModInverse(long long number, long long MOD){return Bigmod(number, MOD-2, MOD);}
int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Chkbit(int N,int pos){return (bool)(N & (1<<pos));}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
long long int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}

///**********************************************************//

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<28)
/// ==========================================////

int a[12],b[12],c[12],d[12];

int Solve()
{
    int ans=1;
    for(int i=0;i<=4;i++) {
        int tp=9-i;
       //cout<<i<< " "<<tp<< " "<<b[i]<< " . "<<d[tp]<<endl;
        while(b[i]&&d[tp]) {
            ans++,b[i]--,d[tp]--;
            //cout<<i<< " ** "<<tp<<endl;
        }
    }
//    cout<<ans<<endl;
    return ans;
}

int cnt;

void Prnt(int l,int r)
{
//    cout<<Cl<< " "<<r<<endl;
    string A,B;
    while(cnt--) {
        A+='0'; B+='0';
    }
    A+=(l+'0'),B+=(r+'0');
    for(int i=0;i<=4;i++) {
        int tp=9-i;
//        cout<<i<< " "<<tp<< " "<<b[i]<< " . "<<d[tp]<<endl;
        while(b[i]&&d[tp]) {
            b[i]--,d[tp]--;
//            cout<<i<< " , "<<tp<<endl;
            A+=(i+'0'),B+=(tp+'0');
        }
    }
//    cout<<A<< " "<<B<<endl;

    for(int i=0;i<10;i++) {
        while(b[i]--) {
            A+=(i+'0');
        }
    }

    for(int i=0;i<10;i++) {
        while(d[i]--) {
            B+=(i+'0');
        }
    }
    reverse(all(A));
    reverse(all(B));
    cout<<A<<endl;
    cout<<B<<endl;
    return;
}

int main()
{
    string s;
    cin>>s;

    F(i,0,s.sz) {
        a[ s[i]-'0' ]++;
    }
    for(int i=0;i<10;i++) c[i]=a[i];
//    F(i,0,10) cout<<c[i]<< " "; NL;

    cnt=(a[0]);
    a[0]=c[0]=0;
    vector<int> v;
    int ans=-1;
    for(int i=1;i<=5;i++) {
        int tp=10-i;
        for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
        //cout<<i<< " "<<tp<< " "<<b[i]<< " "<<d[tp]<<endl;
        if(b[i]&&d[tp]) {
            b[i]--;
            d[tp]--;
            ans=max(ans,Solve());
        }
    }
//    F(i,0,10) cout<<a[i]<< " "; NL;

    for(int i=1;i<=5;i++) {
        int tp=10-i;
        for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
        if(b[i]&&d[tp]) {
            b[i]--;
            d[tp]--;
            if(ans==Solve()) {
                for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
                b[i]--;
                d[tp]--;
                Prnt(i,tp); return 0;
            }
        }
    }
    sort(all(s),greater<char>());
    cout<<s<<endl;
    cout<<s<<endl;

    return 0;
}

///============= Thank You ===================///

#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#define sqr(x) ((x) * (x))
using namespace std;

typedef	long long	int64;

string	a, s, t;
int	c[10], d[10], e[10], ans;

void	check(int p, int q)
{
	for (int i = 0; i <= 9; ++ i) d[i] = e[i] = c[i];

	if (!d[p]) return;
	if (!e[q]) return;
	d[p] --;
	e[q] --;

	string	x = "";
	string	y = "";
	int	now = 1;

	x += (char)(p + '0');
	y += (char)(q + '0');

	for (int i = 0; i <= 9; ++ i)
		for (; d[i] && e[9 - i]; -- d[i], -- e[9 - i])
		{
			x += (char)(i + '0');
			y += (char)(9 - i + '0');
			++ now;
		}

	now += d[0];
	if (now <= ans) return;
	ans = now;

	for (int i = 1; i <= 9; ++ i)
	{
		for (; d[i]; -- d[i]) x += (char)(i + '0');
		for (; e[i]; -- e[i]) y += (char)(i + '0');
	}

	reverse(x.begin(), x.end());
	reverse(y.begin(), y.end());

	for (; d[0]; -- d[0]) x += "0";
	for (; e[0]; -- e[0]) y += "0";

	s = x;
	t = y;
}

int	main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);

	cin >> a;
	for (int i = 0; i < a.size(); ++ i) c[a[i] - '0'] ++;

	ans = c[0];
	for (int i = 1; i <= 9; ++ i)
		for (int j = 1; j <= c[i]; ++ j)
			s += (char)(i + '0'), t += (char)(i + '0');
	for (int j = 1; j <= c[0]; ++ j)
		s += "0", t += "0";

	check(5, 5);
	check(4, 6);
	check(3, 7);
	check(2, 8);
	check(1, 9);

	cout << s << endl << t << endl;

	return 0;
}

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <numeric>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <fstream>
#include <list>
#include <sstream>
#include <iostream>
#include <iomanip>

using namespace std;
#define MAX 100005
int main(){

    char s[ MAX ];
    int l;
    scanf("%s" , &s );
    l = strlen( s );
    int a[ 15 ] = { 0 }, a2[ 15 ] = { 0 };
    string n1 = "" , n2 = "";
    for( int i = 0 ; s[ i ] ; ++i ){
        a[ s[ i ] - '0' ]++;
        a2[ s[ i ] - '0' ]++;
    }

    int v1 = 0, v2 = 0, nueves = 0;
    //for( int i = 0 ; i < 10 ; ++i ) nueves += min( a[ i ] , a2[ 9 - i ] );
    //cout<<nueves<<endl;
    int maxi = 0, mini = 1<<30;
    for( int i = 0 ; i < 10 ; ++i ){
        //cout<<a[ i ]<<endl;
        int t = min( a[ i ] , a2[ 10 - i ] );
        int nv = min( a[ i ] , a2[ 9 - i ] );
        //cout<<nv<<" ten "<<t<<endl;
        if( t != 0 && nv == 0 ){
            v1 = i;
            v2 = 10 - i;
            break;
        }
        else if( t != 0 && nv != 0 ){
            if( nv < mini ){
                v1 = i;
                v2 = 10 - i;
                mini = nv;
            }
        }
    }
    cout<<v1<<" "<<v2<<endl;
    if( v1 != 0 ){
        n1 += (char)( v1 + '0');
        n2 += (char)( v2 + '0');
        a[ v1 ]--;
        a2[ v2 ]--;
    }
    //nueves despues del 1er 10
    for( int i = 0 ; i < 10 ; ++i ){
        int nv = min( a[ i ] , a2[ 9 - i ] );
        for( int j = 0 ; j < nv; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 9 - i + '0');
        }
        a[ i ] -= nv;
        a2[ 9 - i ] -= nv;
    }
    //zeros sobrantes al final
    int z = min( a[ 0 ] , a2[ 0 ] );
    for( int i = 0 ; i < z ; ++i ){
        n1 = "0" + n1;
        n2 = "0" + n2;
    }
    a[ 0 ] -= z;
    a2[ 0 ] -= z;
    //dieces
    for( int i = 1 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        for( int j = 0 ; j < t ; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 10 - i + '0');
        }
        a[ i ] -= t;
        a2[ 10 - i ] -= t;
    }

    for( int i = 0 ; i < 10 ; ++i ){
        for( int j = 0 ; j < a[ i ] ; ++j ) n1 += (char)( i + '0');
        for( int j = 0 ; j < a2[ i ] ; ++j ) n2 += (char)( i + '0');
    }

    reverse( n1.begin() , n1.end() );
    reverse( n2.begin() , n2.end() );
    printf("%s\n%s\n" , n1.c_str() , n2.c_str() );

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
int num1[10],num2[10],a1[10],a2[10];
int g1[1000000],g2[1000000];
int tot;

int getmin(int u,int v){
    if (u<v)   return u;    else    return v;
}

int main(){

    for (char c=getchar();c>='0' && c<='9';c=getchar())
        num1[c-'0']++,num2[c-'0']++;

    int max=0;                      int len=0;         int x=-1;
    memcpy(a1,num1,sizeof(a1));
    memcpy(a2,num2,sizeof(a2));
    for (int i=0;i<=num1[0];i++){
        for (int j=1;j<=5;j++){
            num1[0]-=i;              num2[0]-=i;

            int ans=i;
            if (num1[j] && num2[10-j]){
               ans++;   num1[j]--;     num2[10-j]--;
               for (int k=0;k<=9;k++){
                   int inc=getmin(num1[k],num2[9-k]);
                   ans+=inc;                     num1[k]-=inc;   num2[9-k]-=inc;
               }

               if (ans>max)                         max=ans,len=i,x=j;
            }
            memcpy(num1,a1,sizeof(num1));           memcpy(num2,a2,sizeof(num2));
        }
    }

    num1[0]-=len;                                num2[0]-=len;
    if (x!=-1)                                   num1[x]--,num2[10-x]--;

    for (int i=1;i<=len;i++)                     g1[++tot]=0,g2[tot]=0;

    if (x!=-1){
       g1[++tot]=x;                              g2[tot]=10-x;

       for (int i=0;i<=8;i++){
           int inc=getmin(num1[i],num2[9-i]);
           for (int j=1;j<=inc;j++)          g1[++tot]=i,g2[tot]=9-i;
           num1[i]-=inc;                     num2[9-i]-=inc;
        }
    }

    int tot1=tot;                         int tot2=tot;
    for (int i=0;i<=9;i++){
        if (num1[i])                      for (int j=1;j<=num1[i];j++) g1[++tot1]=i;
        if (num2[i])                      for (int j=1;j<=num2[i];j++) g2[++tot2]=i;
    }

    for (int i=tot1;i>=1;i--)             printf("%d",g1[i]);          printf("\n");
    for (int i=tot2;i>=1;i--)             printf("%d",g2[i]);          printf("\n");
}

#include <string>
#include <vector>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

string s;
int n;
int count1[10];
int count2[10];
int res;

int main() {
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i ++) {
    count1[s[i] - '0'] ++;
    count2[s[i] - '0'] ++;
  }
  string per1, per2;
  per1 = per2 = "";
  res = 0;
  int ii = -1;
  for (int i = 0; i < 10; i ++)
    if (count1[i] > 0) {
      count1[i] --;
      if (count2[(10 - i) % 10] > 0) {
	count2[(10 - i) % 10] --;
	int sum = 1;
	for (int j = 0; j < 10; j ++)
	  sum += min(count1[j], count2[9-j]);
	if (res < sum) {
	  res = sum;
	  ii = i;
	}
	count2[(10 - i) % 10] ++;
      }
      count1[i] ++;
    }
  if (ii != -1) {
    per1 = char(ii + '0') + per1;
    per2 = char((10 - ii) % 10 + '0') + per2;
    count1[ii] --;
    count2[(10-ii) % 10] --;
  }
  //cout << per1 << endl << per2 << endl;
  for (int i = 0; i < 10; i ++)
    if (count1[i] > 0) {
      int t = min(count1[i], count2[9-i]);
      per1.insert(0, t, char(i + '0'));
      per2.insert(0, t, char(9 - i + '0'));
      count1[i] -= t;
      count2[9-i] -= t;
    }
  for (int i = 0; i < 10; i ++) {
    per1.insert(0, count1[i], char(i + '0'));
    per2.insert(0, count2[i], char(i + '0'));
  }

  cout << per1 << endl << per2 << endl;

  return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define pb push_back
const int maxi=1e6+10;
string s;
int cnt[20], cur1[20],cur2[20];
int curAns;
string curFirst, curSecond, bestFirst, bestSecond;
int length;
void again()
{
    for (int i=1; i<10; i++)
    {
        cur1[i]=cnt[i];
        cur2[i]=cnt[i];
    }

    curFirst = "";
    curSecond = "";
    for (int i=0;i<cnt[0];i++)
    {
        curFirst+='0';
        curSecond+='0';
    }
    return ;
}

void solve(int carry, int ostalo)
{
    if (!ostalo)
        return;

    if (carry==1)
    {
        for (int i=0; i<=9; i++)
            if (cur1[i] && cur2[9-i])
            {
                cur1[i]--;
                curFirst+='0'+i;
                cur2[9-i]--;
                curSecond+='0'+(9-i);
                curAns++;
                solve(1,ostalo-1);
                return;
            }
    }

  int nasaoFirst = -1;
  int nasaoSecond = -1;

  for (int i=1;i<=9;i++){
    if (cur1[i] && nasaoFirst == -1) nasaoFirst = i;
    if (cur2[i] && nasaoSecond== -1) nasaoSecond = i;
  }

  curFirst+=nasaoFirst+'0';
  curSecond+=nasaoSecond+'0';

  cur1[nasaoFirst]--;
  cur2[nasaoSecond]--;

  if (nasaoFirst+nasaoSecond>9) solve(1,ostalo-1);
  else
    solve(0,ostalo-1);
}
int main()
{
    cin>>s;

    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());

    int n=s.size();

    for (int i=0; i<n; i++)
        cnt[s[i]-'0']++;

    int best = 0;

    length = n - cnt[0];

    for (int i=0; i<=9; i++)
    {
        again();
        int fir = i;
        int sec = (10-i)%10;

        if (cur1[fir] && cur2[sec])
        {
            cur1[fir]--;
            cur2[sec]--;
            curAns = 1;
            curFirst += '0'+fir;
            curSecond += '0'+sec;

            if (i)
                solve(1, length-1);
            else
                solve(0,length-1);

            if (curAns>best)
            {
                best = curAns;
                reverse(curFirst.begin(),curFirst.end());
                reverse(curSecond.begin(),curSecond.end());
                bestFirst = curFirst;
                bestSecond = curSecond;
            }
        }
    }

    if (best==0)
    {
        cout<<s<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<bestFirst<<endl;
        cout<<bestSecond<<endl;
    }

    return 0;
}

// ICPC champion is here
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<map>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<long double>
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-10);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
vector< pair<int,int> > nineless,ans,extra,Zero;
vector< pair< pair<int,int> ,int> > ten,nine;
string st;
int vis1[10],vis2[10],tvis1[10],tvis2[10];
int main()
{

    cin>>st;
    for(int i=0;i<sz(st);i++)
    {
        int val=st[i]-'0';
        vis1[val]++;
        vis2[val]++;
        tvis1[val]++;
        tvis2[val]++;
    }

    for(int i=0,j=9;i<=4;i++,j--)
    {
        if(vis1[i]>0&&vis2[j]>0)
        {
            int V=min(vis1[i],vis2[j]);
            vis1[i]-=V;
            vis2[j]-=V;
            while(V--)
                nine.pb(mp(mp(i,j),1));

        }

        if(vis2[i]>0&&vis1[j]>0)
        {
            int V=min(vis2[i],vis1[j]);
             vis2[i]-=V;
            vis1[j]-=V;
            while(V--)
                nine.pb(mp(mp(j,i),1));

        }
    }
    int fl=0,F,S;
    for(int i=1,j=9;i<=5&&!fl;i++,j--)
    {
        if(vis1[i]>0&&vis2[j]>0)
        {
            fl=1;
            F=i;
            S=j;
            vis1[i]--;
            vis2[j]--;
        }
        else if(vis2[i]>0&&vis1[j]>0)
        {
             fl=1;
            F=j;
            S=i;
            vis2[i]--;
            vis1[j]--;
        }
    }

    if(!fl)
    {

    for(int i=0;i<=9&&!fl;i++)
    {
        for(int j=0;j<=9&&!fl;j++)
        {
            if(i+j>=10&&vis1[i]>0&&vis2[j]>0)
            {
                F=i;
                S=j;
                fl=1;
                vis1[i]--;
                vis2[j]--;
            }
        }
    }
    }

    if(!fl&&sz(nine)>2)
    {
       for(int i=0;i<sz(nine)&&!fl;i++)
       {
           for(int j=i+1;j<sz(nine)&&!fl;j++)
           {
               pair< pair<int,int>,int> a=nine[i];
               pair<pair<int,int>,int> b=nine[j];

               if(a.first.first+b.first.first==10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.first;
                   S=b.first.first;
                   fl=1;
               }
               else if(a.first.first+b.first.second==10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.first;
                   S=b.first.second;
                   fl=1;
               }
               else if(a.first.second+b.first.second==10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.second;
                   S=b.first.second;
                   fl=1;
               }
               else if(a.first.second+b.first.first==10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.second;
                   S=b.first.first;
                   fl=1;
               }

           }
       }

    }

    if(!fl&&sz(nine)>2)
    {
       for(int i=0;i<sz(nine)&&!fl;i++)
       {
           for(int j=i+1;j<sz(nine)&&!fl;j++)
           {
               pair< pair<int,int>,int> a=nine[i];
               pair<pair<int,int>,int> b=nine[j];

               if(a.first.first+b.first.first>=10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.first;
                   S=b.first.first;
                   fl=1;
               }
               else if(a.first.first+b.first.second>=10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.first;
                   S=b.first.second;
                   fl=1;
               }
               else if(a.first.second+b.first.second>=10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.second;
                   S=b.first.second;
                   fl=1;
               }
               else if(a.first.second+b.first.first>=10)
               {
                   nine[i].second=0;
                   nine[j].second=0;
                   F=a.first.second;
                   S=b.first.first;
                   fl=1;
               }

           }
       }

    }

    if(fl)
    {
        ans.pb(mp(F,S));
        for(int i=0;i<sz(nine);i++)
            ans.pb(mp(nine[i].first.first,nine[i].first.second));

        for(int i=1,j=9;i<=5;i++,j--)
       {
           if(vis1[i]>0&&vis2[j]>0)
          {

              int V=min(vis1[i],vis2[j]);

              vis1[i]-=V;
              vis2[j]-=V;
              while(V--)
                ten.pb(mp(mp(i,j),1));

          }
       }

      if(vis1[0]>0&&vis2[0]>0)
      {
          int V=min(vis1[0],vis2[0]);
          vis1[0]-=V;
          vis2[0]-=V;
          while(V--)
            Zero.pb(mp(0,0));

      }

       for(int i=0;i<=9;i++)
       {
           for(int j=0;j<=9;j++)
           {
               if(i+j<9&&vis1[i]>0&&vis2[j]>0)
               {

                   int V=min(vis1[i],vis2[j]);
                   vis1[i]-=V;
                   vis2[j]-=V;
                   while(V--)
                    nineless.pb(mp(i,j));

               }
           }
       }
       int sizezero=sz(Zero);
       if(sz(nineless)<sz(ten))
       {
           int id=0;
           while(sz(nineless)<sz(ten)&&id<sz(Zero))
           {
               nineless.pb(Zero[id++]);
               sizezero--;
           }
       }

       if(sz(ten)>2&&sz(nineless)<sz(ten))
       {
           int id=0;
           int sizeten=sz(ten);
           int lessnine=sz(nineless);

           while(sizeten>2&&lessnine<sizeten)
           {

               pair<pair<int,int>,int> a=ten[id];
               pair<pair<int,int>,int> b=ten[id+1];

               if(a.first.first+b.first.first < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.second,b.second));
                   nineless.pb(mp(a.first.first,b.first.first));
               }
               else if(a.first.first+b.first.second < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.second,b.first.first));
                   nineless.pb(mp(a.first.first,b.first.second));
               }
               else if(a.first.second+b.first.second < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.first,b.first.first));
                   nineless.pb(mp(a.first.second,b.first.second));
               }
               else if(a.first.second+b.first.first < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.first,b.first.second));
                   nineless.pb(mp(a.first.second,b.first.first));
               }

               id+=2;
               lessnine++;
               sizeten-=2;
           }
       }
       int id=0;

       for(int i=0;i<sz(ten);i++)
       {
           if(ten[i].second==0)
            continue;
            if(id<sz(nineless))
           ans.pb(nineless[id++]);
           ans.pb(mp(ten[i].first.first,ten[i].first.second));
       }

        for(int i=0;i<=9;i++)
        {
            for(int j=0;j<=9;j++)
            {
                if(vis1[i]>0&&vis2[j]>0)
                    ans.pb(mp(i,j));
            }
        }
        for(int i=0;i<sz(extra);i++)
            ans.pb(extra[i]);

        for(int i=sz(ans)-1;i>=0;i--)
            cout<<ans[i].first;

        for(int i=0;i<sizezero;i++)
          cout<<"0";
        cout<<endl;
        for(int i=sz(ans)-1;i>=0;i--)
            cout<<ans[i].second;

        for(int i=0;i<sizezero;i++)
          cout<<"0";
        cout<<endl;
        return 0;
    }

// ----------------------------------------------------------------------------------------

    for(int i=1,j=9;i<=5;i++,j--)
    {
        if(tvis1[i]>0&&tvis2[j]>0)
        {
            int V=min(tvis1[i],tvis2[j]);

            tvis1[i]-=V; tvis2[j]-=V;
            while(V--)
                ten.pb(mp(mp(i,j),1));
        }
        if(tvis1[j]>0&&tvis2[i]>0)
        {
            int V=min(tvis1[j],tvis2[i]);

            tvis1[j]-=V; tvis2[i]-=V;
            while(V--)
                ten.pb(mp(mp(j,i),1));
        }

    }

      if(tvis1[0]>0&&tvis2[0]>0)
      {
          int V=min(tvis1[0],tvis2[0]);
          tvis1[0]-=V;
          tvis2[0]-=V;
          while(V--)
            Zero.pb(mp(0,0));

      }

       for(int i=0;i<=9&&sz(ten)>0;i++)
       {
           for(int j=0;j<=9;j++)
           {
               if(i+j<9&&tvis1[i]>0&&tvis2[j]>0)
               {

                   int V=min(tvis1[i],tvis2[j]);
                   tvis1[i]-=V;
                   tvis2[j]-=V;
                   while(V--)
                    nineless.pb(mp(i,j));

               }
           }
       }
       int sizezero=sz(Zero);
       if(sz(ten)>0&&sz(nineless)<sz(ten)-1)
       {
           int id=0;

           while(sz(nineless)<sz(ten)-1&&id<sz(Zero))
           {
               nineless.pb(Zero[id++]);
               sizezero--;
           }
       }

       if(sz(ten) > 2&&sz(nineless)<sz(ten)-1)
       {
           int id=0;
           int sizeten=sz(ten);
           int lessnine=sz(nineless);

           while(sizeten >2&&lessnine<sizeten-1)
           {

               pair<pair<int,int>,int> a=ten[id];
               pair<pair<int,int>,int> b=ten[id+1];

               if(a.first.first+b.first.first < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.second,b.second));
                   nineless.pb(mp(a.first.first,b.first.first));
               }
               else if(a.first.first+b.first.second < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.second,b.first.first));
                   nineless.pb(mp(a.first.first,b.first.second));
               }
               else if(a.first.second+b.first.second < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.first,b.first.first));
                   nineless.pb(mp(a.first.second,b.first.second));
               }
               else if(a.first.second+b.first.first < 9)
               {
                   ten[id].second=0;
                   ten[id+1].second=0;
                   extra.pb(mp(a.first.first,b.first.second));
                   nineless.pb(mp(a.first.second,b.first.first));
               }

               id+=2;
               lessnine++;
               sizeten-=2;
           }
       }
       int id=0;

       for(int i=0;i<sz(ten);i++)
       {
           if(ten[i].second==0)
            continue;

           ans.pb(mp(ten[i].first.first,ten[i].first.second));
           if(id<sz(nineless)&&i!=sz(ten)-1)
           ans.pb(nineless[id++]);
       }

        for(int i=0;i<=9;i++)
        {
            for(int j=0;j<=9;j++)
            {
                if(tvis1[i]>0&&tvis2[j]>0)
                {
                     tvis1[i]--;
                     tvis2[j]--;
                    ans.pb(mp(i,j));
                }
            }
        }
        for(int i=0;i<sz(extra);i++)
            ans.pb(extra[i]);

//cout<<sz(extra)<<" "<<sz(nineless)<<endl;
        for(int i=sz(ans)-1;i>=0;i--)
            cout<<ans[i].first;

        for(int i=0;i<sizezero;i++)
          cout<<"0";
        cout<<endl;
        for(int i=sz(ans)-1;i>=0;i--)
            cout<<ans[i].second;

        for(int i=0;i<sizezero;i++)
          cout<<"0";
        cout<<endl;
        return 0;

}

#pragma comment(linker, "/STACK:16777216")

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <climits>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

using namespace std;

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }

typedef long long ll;
typedef pair<int,int> pii;

const double eps = 1e-10;
const int inf  = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;

#define fr(x,y,z) for(int(x)=(y);(x)<(z);(x)++)
#define rep(x,n) fr(x,0,n)
#define cast(x,t) *({stringstream ss;static t __ret;ss<<x,ss>>__ret;&__ret;})
#define dbg(x) cout << #x << " == " << x << endl
#define _ << " , " <<
#define print(x) cout << x << endl
#define mp make_pair
#define X first
#define Y second

int conta[20], n;

int main() {
	string v;
	cin >> v;

	n = v.size();
	rep(i,n) conta[ v[i]-'0' ]++;

	int f[10]={0}, best=0;

	for(int i = 1; i <= 5; i++) if(conta[i] > 0) {
		conta[i]--;
		int falta = 10 - i;
		if(conta[falta]) {
			int res = 1;
			for(int j = 0; j <= 4; j++) {
				res += min( conta[j], conta[9-j] );
			}
			if(res >= best) {
				memset(f,0,sizeof f);
				f[i] = 1;
				best = res;
			}
		}
		conta[i]++;
	}

	if(!best) {
		print(v);
		print(v);
		return 0;
	}

	int conta2[10]; rep(i,10) conta2[i] = conta[i];

	string a, b;
	for(int i = 1; i <= 5; i++) if(f[i]) {
		a.push_back( i + '0' ); conta[i]--;
		b.push_back( 10-i + '0'); conta2[10-i]--;
		for(int j = 0; j <= 4; j++) {
			while(conta[j] && conta2[9-j]) {
				a.push_back(j+'0'); conta[j]--;
				b.push_back(9-j+'0'); conta2[9-j]--;
			}
		}
		rep(j,10) while(conta[j]--) a.push_back(j+'0');
		rep(j,10) while(conta2[j]--) b.push_back(j+'0');
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		print(a);
		print(b);
		break;
	}

	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <iterator>
#include <set>
#include <map>

// ������ set, � �� multiset?
// ��� EPS?
// --u, --v?

using namespace std;

enum
{
    N = 10,
    K = 100000
};

string n;
int kd1[N], kd2[N], nd1[N], nd2[N];
int used1[N], used2[N];
int s1[K], s2[K];
int k1 = 0, k2 = 0;

int
pairs(void)
{
    int i, j;
    int res = 0;
    for (i = 0; i < 10; ++i) {
        nd1[i] = kd1[i];
        nd2[i] = kd2[i];
    }
    for (i = 1; i <= 8; ++i) {
        j = 9 - i;
        int m = min(kd1[i], kd2[j]);
        used1[i] = used2[j] = m;
        nd1[i] = kd1[i] - m;
        nd2[j] = kd2[j] - m;
        res += m;
    }
    return res;
}

void
add(int *s, int x)
{
    if (s == s1) {
        s1[k1++] = x;
    } else if (s == s2) {
        s2[k2++] = x;
    }
}

int
main(void)
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;
    for (char c : n) {
        ++kd1[c - '0'];
    }
    int i, j;
    for (i = 0; i < N; ++i) {
        kd2[i] = kd1[i];
    }
    int p = -1, max = -1;
    for (i = 1; i <= 5; ++i) {
        j = 10 - i;
        if (!kd1[i] || !kd1[j]) {
            continue;
        }
        --kd1[i];
        --kd2[j];
        int kp = pairs();
        ++kd1[i];
        ++kd2[j];
        if (kp > max) {
            p = i;
            max = kp;
        }
    }
    if (p >= 0) {
        --kd1[p];
        --kd2[10 - p];
    }

    pairs();
    //cerr << "p = " << p << "\n";
    //cerr << "kd1[9] = " << kd1[9] << "\n";

    for (i = 1; i < 10; ++i) {
        for (j = 0; j < nd1[i]; ++j) {
            add(s1, i);
        }
        for (j = 0; j < nd2[i]; ++j) {
            add(s2, i);
        }
    }
    for (i = 1; i <= 8; ++i) {
        for (j = 0; j < used1[i]; ++j) {
            add(s1, i);
            add(s2, 9 - i);
        }
    }
    if (p >= 0) {
        add(s1, p);
        add(s2, 10 - p);
    }
    for (i = 0; i < kd1[0]; ++i) {
        add(s1, 0);
        add(s2, 0);
    }

    for (i = 0; i < k1; ++i) {
        cout << s1[i];
    }
    cout << "\n";
    for (i = 0; i < k2; ++i) {
        cout << s2[i];
    }
    cout << "\n";

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             1e9
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 100005;
string str;
int cnt[11],t1[11],t2[11];
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> str;
    for(int i = 0;i < str.size();i++){
        int d = str[i] - '0';
        cnt[d]++;
    }
    int mx = -1;
    string S1,S2;
    for(int num = 1;num <= 9;num++){
        for(int iter = 0;iter <= 9;iter++)t1[iter] = t2[iter] = cnt[iter];
        string s1, s2;
        int counter = 0;
        while(t1[0]--)s1 += '0';
        while(t2[0]--)s2 += '0';

        if(t1[num] > 0 and t2[10 - num] > 0){
            counter++;
            t1[num]--;
            t2[10 - num]--;

            s1 += char(num + '0');
            s2 += char(10 - num + '0');

            for(int i = 1;i <= 9;i++){
                while(t1[i] > 0 and t2[9 - i] > 0){
                    t1[i]--;
                    t2[9 - i]--;
                    s1 += char(i + '0');
                    s2 += char(9 - i + '0');
                    counter++;
                }
            }
        }
        for(int i = 1;i <= 9;i++){
            while(t1[i]--)s1 += char(i + '0');
            while(t2[i]--)s2 += char(i + '0');
        }
        if(counter > mx){
            mx = counter;
            S1 = s1;
            S2 = s2;
        }
    }
    REV(S1);REV(S2);
    cout << S1 << "\n";
    cout << S2 << "\n";

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int inf = 0x3f3f3f3f;
const int maxn = 1009;
const double esp = 1e-6;

char s[100009];
char s1[100009], s2[100009];
int bit[20], b2[20];
int zr;

int solve()
{
    zr = bit[0];
    int ans = 0;
    int tmp = min(bit[0], bit[9]);
    ans += tmp<<2;
    zr -= tmp;
    for(int i=1; i<=8; i++) ans+=min(bit[i], bit[9-i]);
    //ans+=bit[5]/2;
    return ans;
}

int main()
{
    scanf("%s", s);
    memset(bit, 0, sizeof(bit));
    for(int i=0; s[i]; i++) bit[ s[i]-'0' ]++;
    for(int i=0; i<10; i++) b2[i] = bit[i];
    int ans = bit[0];
    int a2;
    int a0 = bit[0];  //0的个数
    for(int i=1; i<=5; i++)
    if(bit[i]>0 && bit[10-i]>0)
    {
        bit[i]--;
        bit[10-i]--;
        int tmp = 1+solve();
        tmp += zr;
        if(ans<tmp)
        {
            ans = tmp;
            a2 = i;
            a0 = zr;
        }
        bit[i]++;
        bit[10-i]++;
    }
    int cnt = -1;
    for(int i=0; i<a0; i++) s1[++cnt] = s2[cnt] = '0';
    if(ans>bit[0])
    {
        s1[++cnt] = a2+'0';
        s2[cnt] = 10-a2+'0';
        bit[a2]--;
        b2[10-a2]--;
    }
    bit[0] -= a0;
    b2[0] -= a0;
    //1099 cout<<"  --- "<<cnt<<endl;
    for(int i=0; i<=9; i++)
    {
        int nn = min(bit[i], b2[9-i]);
        bit[i] -= nn;
        b2[9-i] -= nn;
        for(int j=0; j<nn; j++)
        {
            s1[++cnt] = i+'0';
            s2[cnt] = 9-i+'0';
        }
    }
    int c1 = cnt;
    for(int i=0; i<=9; i++)
    {
        for(int j=0; j<bit[i]; j++) s1[++c1] = i+'0';
        for(int j=0; j<b2[i]; j++) s2[++cnt] = i+'0';
    }
    for(int i=cnt; i>=0; i--) putchar(s1[i]);
    puts("");
    for(int i=cnt; i>=0; i--) putchar(s2[i]);
    puts("");
	return 0;
}

/*qnittrlqomthdnjnnseckephshqaqcleqldpiodcscbbpcpbnl*/

/*input
1061

*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N
#define bit(x,y) ((x>>y)&1LL)
#define For(i,l,r) for(int i=l; i<r; i++)

string s;
int cnt[2][10];
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cnt[0][s[i] - '0']++;
		cnt[1][s[i] - '0']++;
	}
	int preans = cnt[0][0];
	cnt[0][0] = 0; cnt[1][0] = 0;
	pair<int, int> ans = mp(0, -1);
	for (int i = 1; i <= 5; i++) {
		cnt[0][i]--; cnt[1][10 - i]--;
		if (cnt[0][i] < 0 || cnt[1][10 - i] < 0) {
			cnt[0][i]++; cnt[1][10 - i]++;
			continue;
		}
		int cur = 0;
		for (int j = 1; j <= 9; j++) {
			cur += min(cnt[0][j], cnt[1][9 - j]);
		}
		ans = max(ans, mp(cur, i));
		cnt[0][i]++; cnt[1][10 - i]++;
	}
	if (ans.se == -1) {
		for (int i = 9; i >= 0; i--) {
			while (cnt[0][i]--)
				cout << i;
		}
		for (int j = 1; j <= preans; j++) cout << 0;
		cout << endl;
		for (int i = 9; i >= 0; i--) {
			while (cnt[1][i]--)
				cout << i;
		}
		for (int j = 1; j <= preans; j++) cout << 0;
		cout << endl;
		return 0;
	}
	string perm1, perm2;
	for (int i = 1; i <= preans; i++) perm1 += "0", perm2 += "0";
	for (int i = ans.se; i <= ans.se; i++) {
		cnt[0][i]--; cnt[1][10 - i]--;
		perm1 += i + '0'; perm2 += (10 - i) + '0';
		for (int j = 1; j <= 9; j++) {
			int mn = min(cnt[0][j], cnt[1][9 - j]);
			cnt[0][j] -= mn; cnt[1][9 - j] -= mn;
			while (mn--) {
				perm1 += j + '0';
				perm2 += 9 - j + '0';
			}
		}
		for (int j = 0; j <= 9; j++) {
			while (cnt[0][j]--) {
				perm1 += j + '0';
			}
			while (cnt[1][j]--) {
				perm2 += j + '0';
			}
		}
	}
	reverse(perm1.begin(), perm1.end()); reverse(perm2.begin(), perm2.end());
	cout << perm1 << endl << perm2 << endl;
}

//#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define infll 0x3f3f3f3f3f3f3f3f
#define il inline
#define re register
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define MP make_pair
#define lowbit(x) x&(-x)
#define fi first
#define se second
il ll read()
{
	char ch = getchar();
	ll 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;
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
void exgcd(ll a, ll b, ll &x,ll &y)
{
	if(!b) x = 1, y = 0;
	else
	{
		exgcd(b, a % b, y, x);
		y -= x * (a / b);
	}
}
const int mod = 1e9+7;
char s[10];
int num[10],a[10];
il int cal(int x)
{
	int ret = 0;
	while(x)
	{
		int t = x%10;
		ret += t==0;
		x /= 10;
	}
	return ret;
}
int main()
{
	scanf("%s",s+1);
	int n = strlen(s+1);
	for(int i = 1; i <= n; i++)
		num[s[i]-'0']++;
	int l = 0;
	for(int i = 0; i <= 9; i++)
		while(num[i])
		{
			num[i]--;
			s[++l] = i;
		}
	vector<int> v;
	do
	{
		int t = 0;
		for(int i = 1; i <= n; i++)
			t = t*10+s[i];
//		cout<<t<<endl;
		v.pb(t);
	}
	while(next_permutation(s+1,s+1+n));
	sort(v.begin(),v.end());
	int m = v.size(),mx = 0,t1,t2;
	for(int i = 0; i < m; i++)
	{
		for(int j = i; j < m; j++)
		{
			int t = v[i]+v[j];
			int now = cal(t);
			if(now >= mx)
			{
				mx = now;
				t1 = v[i];
				t2 = v[j];
			}
		}
	}
	if(n == 1)
		printf("%1d\n%1d",t1,t2);
	else if(n == 2)
		printf("%2d\n%2d",t1,t2);
	else if(n == 3)
		printf("%3d\n%3d",t1,t2);
	else if(n == 4)
		printf("%4d\n%4d",t1,t2);
	else if(n == 5)
		printf("%5d\n%5d",t1,t2);
	else
		printf("%6d\n%6d",t1,t2);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define ld long double
#define FOR(n) for(int i=0;i<n;i++)
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{
    string a;
    cin>>a;
    ll n = a.size();
    ll cnt[10];
    memset(cnt , 0 , sizeof(cnt));
    for(ll i=0;i<n;i++) cnt[a[i] - '0']++;
    ll mx = -1;
    string fin;
    for(ll i=0;i<cnt[0];i++) fin.pb('0');
    cnt[0] = 0;
    string ans1 , ans2;
    for(ll i=1;i<10;i++)
    {
        ll x = i , y = 10 - i;
        if(cnt[x]==0 || cnt[y]==0) continue;
        ll cnt1[10] , cnt2[10];
        for(ll j=0;j<10;j++) cnt1[j] = cnt[j];
        for(ll j=0;j<10;j++) cnt2[j] = cnt[j];
        cnt1[x]--;
        cnt2[y]--;
        ll c = 0;
        for(ll j=0;j<10;j++)
        {
            c+=min(cnt1[j] , cnt2[9-j]);
        }
        c++;
        if(c > mx)
        {
            mx = c;
            ans1.clear();
            ans2.clear();
            ans1.pb('0' + x);
            ans2.pb('0' + y);
            for(ll j=0;j<10;j++)
            {
                ll mn = min(cnt1[j] , cnt2[9-j]);
                if(mn==0) continue;
                for(ll k=0;k<mn;k++)
                {
                    ans1.pb('0' + j);
                }
                for(ll k=0;k<mn;k++)
                {
                    ans2.pb('0' + (9 - j));
                }
                cnt1[j]-=mn;
                cnt2[9-j]-=mn;
            }
            for(ll j=0;j<10;j++)
            {
                while(cnt1[j] > 0)
                {
                    ans1.pb('0' + j);
                    cnt1[j]--;
                }
                while(cnt2[j] > 0)
                {
                    ans2.pb('0' + j);
                    cnt2[j]--;
                }
            }
            reverse(all(ans1));
            reverse(all(ans2));
        }
    }
    ll SZZ = fin.size();
    if(SZZ > 0)
    {
        ans1+=fin;
        ans2+=fin;
    }
    cout<<ans1<<endl<<ans2;
}

int main()
{
	FIO;
	ll t;
	//cin>>t;
	t = 1;
	while(t--) solve();
}

#pragma comment(linker, "/STACK:16777216")

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <climits>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

using namespace std;

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }

typedef long long ll;
typedef pair<int,int> pii;

const double eps = 1e-10;
const int inf  = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;

#define fr(x,y,z) for(int(x)=(y);(x)<(z);(x)++)
#define rep(x,n) fr(x,0,n)
#define cast(x,t) *({stringstream ss;static t __ret;ss<<x,ss>>__ret;&__ret;})
#define dbg(x) cout << #x << " == " << x << endl
#define _ << " , " <<
#define print(x) cout << x << endl
#define mp make_pair
#define X first
#define Y second

int conta[20], conta2[10], n;

int main() {
	string v;
	cin >> v;

	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());

	n = v.size();
	rep(i,n) conta[ v[i]-'0' ]++;
	rep(i,10) conta2[i] = conta[i];

	int best = conta[0];

	rep(i,10) rep(j,10) if((i+j)==10 && conta[i] && conta2[j]) {
		conta[i]--, conta2[j]--;
		int f = conta[0] + 1;
		for(int k = 1; k <= 4; k++) {
			f += min( conta[k], conta2[9-k] );
			f += min( conta[9-k], conta2[k] );
		}
		if(f > best) best = f;
		conta[i]++, conta2[j]++;
	}

	if(!best) {
		print(v);
		print(v);
		return 0;
	}

	rep(i,10) rep(j,10) if((i+j)==10 && conta[i] && conta2[j]) {
		conta[i]--, conta2[j]--;
		int f = conta[0] + 1;
		for(int k = 1; k <= 4; k++) {
			f += min( conta[k], conta2[9-k] );
			f += min( conta[9-k], conta2[k] );
		}
		if(f == best) {
			string a, b;
			while(conta[0]) a.push_back('0'), b.push_back('0'), conta[0]--, conta2[0]--;
			a.push_back(i+'0');
			b.push_back(j+'0');
			for(int k = 1; k <= 4; k++) {
				while(conta[k] && conta2[9-k]) {
					a.push_back(k+'0'); conta[k]--;
					b.push_back(9-k+'0'); conta2[9-k]--;
				}
				while(conta[9-k] && conta2[k]) {
					a.push_back(9-k+'0'); conta[9-k]--;
					b.push_back(k+'0'); conta2[k]--;
				}
			}
			rep(k,10) while(conta[k]--) a.push_back(k+'0');
			rep(k,10) while(conta2[k]--) b.push_back(k+'0');
			reverse(a.begin(),a.end());
			reverse(b.begin(),b.end());
			print(a);
			print(b);
			return 0;
		}
		conta[i]++, conta2[j]++;
	}

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
#define PB push_back
#define INF 999999999
using namespace std;
bool flag;
char n[1000001];
short a[20],d[20],b[1000001],c[1000001];
int i,j,m,len,ans,tot,k,end;
void	print(){
	for (int i=1;i<=10;i++)
	while (a[i%10]--) printf("%d",i%10);printf("\n");
	for (int i=1;i<=10;i++)
	while (d[i%10]--) printf("%d",i%10);
	exit(0);
}
int calc(){
	int sum=min(a[0],d[9])+min(a[9],d[0])+
	min(a[0]-min(a[0],d[9]),d[0]-min(a[9],d[0]));
	for (int i=1;i<=8;i++)
	sum+=min(a[i],d[9-i]);
	return sum;
}
int main()
{
	//cin>>n;
	scanf("%s",&n);
	//gets(n);
	len=strlen(n);int ll=len;
	for (i=0;i<len;i++){
	a[n[i]-'0']++;d[n[i]-'0']++;
	}
	ans=-1;
	for (i=1;i<=5;i++)
	if (a[i] && d[10-i]){
		a[i]--;d[10-i]--;tot=1;
		tot+=calc();
		if (tot>ans){
			end=i;ans=tot;
		}
		a[i]++;d[10-i]++;
	}
	if (ans==-1) print();
	b[len]=end;c[len]=10-end;
	a[end]--;  d[10-end]--;len--;
	for (i=0;i<=9;i++){
		while (a[i] && d[9-i]){
			b[len]=i;c[len]=9-i;
			len--;a[i]--;d[9-i]--;
		}
	}int p=len;k=min(a[0],d[0]);
	for (i=1;i<=a[0]-k;i++) b[len--]=0;
	for (i=1;i<=9;i++) while (a[i]--)b[len--]=i;
	len=p;
	for (i=1;i<=d[0]-k;i++) c[len--]=0;
	for (i=1;i<=9;i++) while (d[i]--)c[len--]=i;
	for (i=k+1;i<=ll;i++) printf("%d",b[i]);
	for (i=1;i<=k;i++) printf("0");printf("\n");
	for (i=k+1;i<=ll;i++) printf("%d",c[i]);
	for (i=1;i<=k;i++) printf("0");printf("\n");
	return 0;
}

#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#define PI 3.14159265358979
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std ;
long long int  typedef ll ;
int binpow (int a, int n) // число в степень
{
    int res = 1;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}
bool prov ( string a, string b, int k)
{
    int y = 1;
    int v = 0;
    bool g = true;
    int h = a.length();
    int f = b.length();
    while(h - y >= 0 && f-y >= 0)
    {
        if(a[a.length() - y] != b[b.length() - y])
            g = false;
        if ( (a[a.length() - y] =='a' && b[b.length() - y ]=='a') || (a[a.length() - y] =='e' && b[b.length() - y]=='e')  || (a[a.length() - y] == 'i' && b[b.length() - y]=='i') || (a[a.length() - y] == 'o' && b[b.length() - y]=='o') || (a[a.length() - y] == 'u' && b[b.length() - y] == 'u'))
            v++;
        if (g ==false || (v!=k && h-y==0) || (v!=k && f-y==0) )
            return 0;
        if(g == true && v == k)
            return 1;
        y++;
    }
}

int main()
{
    /*ifstream cin ;
    ofstream cout ;
    cin.open ("input.txt");
    cout.open ("output.txt");*/
    string s1;
    string s2;
    string s3;
    int mas1[10] = {};
    int mas2[10] = {};
    int i = 0;
    int j = 0;
    cin >> s1;
    for(int i = 0; i < s1.length(); i++)
    {
        mas1[s1[i]- '0']++;
        mas2[s1[i]- '0']++;
    }
    /*while(mas1[0] > 0 && mas2[0] > 0)
    {
        s2+= '0';
        s3+= '0';
        mas1[0]--;
        mas2[0]--;
    }*/
    int d = 0;
    for(i = 9; i>=0; i--)
    {
        if(mas1[i] > 0)
        {   for(j =9; j>0; j--)
            {
                if( i + j + d == 10 && mas2[j] > 0)
                {
                    char a = i +'0';
                    char b = j + '0';
                    mas1[i]--;
                    mas2[j]--;
                    s2+=a;
                    s3+=b;
                    d=1;
                    i++;
                    break;
                }
            }
        }
        else
            continue;
    }
    i = 0;
    for(i=1; i< 10; i++)
    {
        char a = i +'0';
        while(mas1[i] > 0)
        {
            s2+=a;
            mas1[i]--;
        }
        while(mas2[i] > 0)
        {
            s3+=a;
            mas2[i]--;
        }
    }
    reverse(ALL(s2));
    reverse(ALL(s3));
    while(mas1[0] > 0)
    {
        s2+= '0';
        mas1[0]--;
    }
    while(mas2[0] > 0)
    {
        s3+= '0';
        mas2[0]--;
    }
    cout << s2 << endl;
    cout << s3;

    //system("pause");
    //cin.close();
    //cout.close();
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <cstdlib>

using namespace std;
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define sz(a)       (int)((a).size())
#define REP(i,j,k)  for(int i=j;i<k;++i)
#define rep(i,n)    for(int i=0;i<n;++i)
#define fori(T,v,i) for(T::iterator i = v.begin(); i != v.end(); i++)
#define forc(T,v,i) for(T::const_iterator i = v.begin(); i != v.end(); i++)
int    INF = 100000000;
double EPS = 1e-8;
typedef long long ll;
string x, y;
int a[10], b[10];

string toStr(int z) {
  stringstream ss;
  ss << z;
  return ss.str();
}

int toInt(string s) {
  stringstream ss(s);
  int z;
  ss >> z;
  return z;
}

int carry(int c) {
  rep (i, 10) if (a[i] && b[10-c-i]) {
    x += i+'0';      a[i]--;
    y += 10-c-i+'0'; b[10-c-i]--;
    return 1;
  }
  return 0;
}

void solve(string s) {
  rep (i, sz(s)) a[s[i]-'0'] = b[s[i]-'0'] = a[s[i]-'0']+1;
  REP (i, 1, 10) while (a[i] && b[10-i]) {
    x += i+'0';    a[i]--;
    y += 10-i+'0'; b[10-i]--;
    while (carry(1));
  }
  while (a[0] && b[0]) {
    x.insert(0, 1, '0'); a[0]--;
    y.insert(0, 1, '0'); b[0]--;
  }
  rep (i, 10) {
    rep (j, a[i]) x += i+'0';
    rep (j, b[i]) y += i+'0';
  }
  return;
}

void init() {
  x =  y = "";
  rep (i, 10) a[i] = b[i] = 0;
}

int main () {
  string s;
  cin >> s;
  init();
  solve(s);
  reverse(all(x)), reverse(all(y));
  cout << x << endl << y << endl;
  return 0;
}

// 1st submit: wa 9还是要管的..

#include <cstdio>
#include <cstring>

const int maxN = 101234;

char s[maxN];
int tot_a[20], tot_b[20];

int solve() {
    int tot = 1;
    int v[30];
    memset(v, 0, sizeof v);
    for (int i = 0; i < 10; i ++) {
        v[i] = tot_a[i];
        if (v[i] > tot_b[9 - i]) v[i] = tot_b[9 - i];
        tot += v[i];
    }

    int extra = tot_a[0] - v[0];
    if (extra > tot_b[0] - v[9]) extra = tot_b[0] - v[9];

    return tot + extra;
}

int main() {
    scanf("%s", s);
    int l = strlen(s);
    memset(tot_a, 0, sizeof tot_a);
    memset(tot_b, 0, sizeof tot_b);
    for (int i = 0; i < l; i ++) {
        tot_a[s[i] - '0'] ++;
        tot_b[s[i] - '0'] ++;
    }

    int ans = 0, val = -1;
    for (int i = 1; i <= 5; i ++) {
        if (!tot_a[i] || !tot_b[10 - i]) continue;

        tot_a[i] --; tot_b[10 - i] --;
        int t = solve();
        if (t > val) {
            val = t; ans = i;
        }
        tot_a[i] ++; tot_b[10 - i] ++;
    }

    if (!ans) {
        printf("%s\n%s\n", s, s);
    } else {
        tot_a[ans] --; tot_b[10 - ans] --;
        int v[100]; memset(v, 0, sizeof v);
        for (int i = 0; i <= 9; i ++) {
            v[i] = tot_a[i];
            if (v[i] > tot_b[9 - i]) v[i] = tot_b[9 - i];
        }

        int extra = tot_a[0] - v[0];
        if (tot_b[0] - v[9] < extra) extra = tot_b[0] - v[9];
        tot_a[0] -= extra; tot_b[0] -= extra;

        int p = 0;
        for (int i = 0; i < extra; i ++) s[p ++] = '0';
        s[p ++] = ans + '0';

        for (int i = 0; i <= 9; i ++)
            for (int j = 0; j < v[i]; j ++) {
                s[p ++] = i + '0';
                tot_a[i] --;
            }
        for (int i = 0; i <= 9; i ++)
            for (int j = 0; j < tot_a[i]; j ++)
                s[p ++] = i + '0';

        for (int i = p - 1; i >= 0; i --) printf("%c", s[i]);
        printf("\n");

        p = 0;
        for (int i = 0; i < extra; i ++) s[p ++] = '0';
        s[p ++] = 10 - ans + '0';

        for (int i = 9; i >= 0; i --)
            for (int j = 0; j < v[9 - i]; j ++) {
                s[p ++] = i + '0';
                tot_b[i] --;
            }
        for (int i = 0; i <= 9; i ++)
            for (int j = 0; j < tot_b[i]; j ++)
                s[p ++] = i + '0';

        for (int i = p - 1; i >= 0; i --) printf("%c", s[i]);
        printf("\n");
    }

    return 0;
}

#include <iostream>
using namespace std;
char first[100001], second[100001], zero[100001];
int number1[10], number2[10];
int just_zero()
{
     char *p1=first, *p2=second;
     while ( number1[0]-- )
           *p1++=*p2++='0';
     return p1-first;
}
int summary_ten (int count)
{
     for ( int i=1; i<6; i++ )
     {
         if ( number1[i]&&number2[10-i] )
         {
              number1[i]--;
              number2[10-i]--;
              first[count]=i+'0';
              second[count]=(10-i)+'0';
              return count+1;
         }
     }
     return count;
}
int summary_nine(int count)
{
     char *p1=&first[count], *p2=&second[count];
     for ( int i=0; i<10; i++ )
     {
         int t1=number1[9-i];
         int t2=number2[i];
         while ( t1*t2 )
         {
               *p1++=(9-i)+'0';
               *p2++=i+'0';
               t1--;
               t2--;
               number1[9-i]--;
               number2[i]--;
         }
     }
     return p1-first;
}
int what_else ( int count )
{
     char *zero_p=zero;
     while ( number1[0]*number2[0] )
     {
           *zero_p++='0';
           number1[0]--;
           number2[0]--;
     }
     char *p1=&first[count], *p2=&second[count];
     for ( int i=0; i<10; i++ )
     {
         while ( number1[i] )
         {
               *p1++=i+'0';
               number1[i]--;
         }
         while ( number2[i] )
         {
               *p2++=i+'0';
               number2[i]--;
         }
     }
     return p1-first;
}
void print_screen ( int count )
{
     char *p1=first+count, *p2=second+count;
     while ( true )
     {
           printf("%c", *p1);
           if ( p1==first )
              break;
           *p1--;
     }
     printf("%s\n", zero);
     while ( true )
     {
           printf("%c", *p2);
           if ( p2==second )
              break;
           *p2--;
     }
     printf("%s", zero);
     return;
}
void maximum_sum ()
{
     int count1=summary_ten(0);
     int count2=count1;
     if ( count1 )
        count2=summary_nine(count1);
     int count3=what_else(count2);
     print_screen(count3-1);
     return;
}
int main()
{
    char str[100001];
    scanf("%s", &str);
    char *p=&str[0];
    while ( *p )
    {
          number2[*p-'0']++;
          number1[(*p++)-'0']++;
    }
    maximum_sum();
    scanf("%s", &str);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <cmath>
#include <algorithm>

#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int len;
int zero;
char buf[100100];
int freq[10];
char a[100100];
char b[100100];

int solve(int a0, int b0, bool need_print){
  a[len] = b[len] = '\0';
  int org = len-zero-1;
  for(int i = len-1; i > org; i--)
    a[i] = b[i] = '0';
  int ret = zero+1;
  a[org] = (char)(a0 + '0');
  b[org] = (char)(b0 + '0');
  vector<int> fa(10);
  vector<int> fb(10);
  for(int i = 0; i < 10; i++)fa[i] = fb[i] = freq[i];
  org--;
  fa[a0]--; fb[b0]--;
  for(int i = 1; i <= 4; i++){
    int j = 9 - i;
    int mn = min(fa[i], fb[j]);
    fa[i] -= mn; fb[j] -= mn;
    for(int k = 0; k < mn; k++){
      a[org] = (char)(i+'0'); b[org--] = (char)(j + '0');
    }
    ret += mn;
  }
  if(need_print){
    int rest = org;
    for(int i = 1; i < 10; i++)
      while(fa[i]>0){
        a[rest--] = (char)(i+'0');
        fa[i]--;
      }
    rest = org;
    for(int i = 1; i < 10; i++)
      while(fb[i]>0){
        b[rest--] = (char)(i+'0');
        fb[i]--;
      }
    printf("%s\n%s\n", a, b);
  }
  return ret;
}

int main(){
  //cin.tie(0);
  //ios_base::sync_with_stdio(false);

  scanf("%s", buf);
  len = strlen(buf);
  for(int i = 0; i < len; i++)
    freq[buf[i]-'0']++;
  zero = freq[0];
  int mx = -1;
  int cand = -1;
  for(int i = 1; i <= 5; i++){
    int j = 10-i;
    if(freq[i] == 0 || freq[j] == 0)continue;
    //freq[i]--; freq[j]--;
    int zn = solve(i, j, false);
    if(mx < zn){
      mx = zn;
      cand = i;
    }
    //freq[i]++; freq[j]++;
  }
  if(cand < 0){
    int count = 0;
    for(int i = 1; i < 10; i++)
      while(freq[i] > 0){
        buf[count++] = (char)(i+'0');
        freq[i]--;
      }
    while(freq[0]>0){
      buf[count++] = '0';
      freq[0]--;
    }
    printf("%s\n%s\n", buf, buf);
  }else{
    solve(cand, 10-cand, true);
  }

  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

char ch[100010];
int A[10];
char X[100010], Y[100010];
int lx, ly;

void solve(int tc){
	scanf("%s", ch);
	int L = (int)strlen(ch);
	for(int i=0;i<L;i++)A[ch[i] - '0']++;
	int mx = 0, mxq = 0;
	for(int q=0;q<=A[0];q++){
		int B[10];
		rep(i, 10)B[i] = A[i];
		B[0] -= q;
		for(int i=1;i<10;i++){
			int r = (10-i) % 10;
			if(B[i] < 1 || B[r] < 1){
				continue;
			}
			int res = q + 1;
			for(int j=1;j<10;j++){
				int x = B[j]; if(j == i)x--;
				int y = B[9-j]; if(9-j == r)y--;
				res += min(x, y);
			}
			if(mx < res){
				X[lx] = '0' + i, Y[ly] = '0' + r;
				mx = res;
				mxq = q;
			}
		}
	}
	if(mx == 0){
		printf("%s\n%s", ch, ch);
		return;
	}
	int x = X[lx++] - '0';
	int y = Y[ly++] - '0';
	A[0] -= mxq;
	int B[10], C[10];
	rep(i, 10)B[i] = A[i] - (x == i);
	rep(i, 10)C[i] = A[i] - (y == i);
	for(int i=0;i<10;i++){
		rep(j, min(B[i], C[9-i]))X[lx++] = i + '0', Y[ly++] = 9-i + '0';
		int a = min(B[i], C[9-i]);
		B[i] -= a;
		C[9-i] -= a;
	}
	for(int i=0;i<10;i++)rep(j, B[i])X[lx++] = '0' + i;
	for(int i=0;i<10;i++)rep(j, C[i])Y[ly++] = '0' + i;
	reverse(X, X+lx);
	reverse(Y, Y+ly);
	rep(i, mxq)Y[ly++] = X[lx++] = '0';
	printf("%s\n%s", X, Y);
}

int main(){
	int Tc = 1;//; scanf("%d", &Tc);
	for(int tc=1; tc<=Tc; tc++){
		solve(tc);
	}
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define MM(a,b) memset(a,b,sizeof(a));
typedef unsigned long long u64;
typedef long long lld;
#define maxn 100050
char c[maxn], c1[maxn], c2[maxn];
int n[20],a[20]; //��¼ÿ�����ֵĸ���
int y[3][20]; //��¼c1��c2�����е����ָ���
int main()
{
    //freopen("D.txt","r",stdin);
    while(scanf("%s",c)!=EOF){
        int len,i,j,next1,next2; //len: �����ȣ� next�������´�������
        len= strlen(c);
        for(i=0;i<=9;++i) n[i]=0;
        for(i=0;i<len;++i)
            ++n[ c[i]-'0' ];
        //ֱ��ö��10�Ĺ��ɣ������������λ�����
        int tmp= -1, mark=-1;
        for(i=1;i<=5;++i){
            // ������ i + 10-i = 10;
            if( n[i] && n[10-i] ){
                if( i==5 && n[5]<=1 ) continue;
                for(j=1;j<=9;++j) a[j]=n[j];
                a[i]--, a[10-i]--; //5Ҳ���2�Σ�
                int sum=0;
                for(j=1;j<=4;++j)
                    sum+= min( a[j], a[9-j] ); //���Թ���9�Ķ���
                if( sum>tmp ){
                    tmp= sum;
                    mark= i;
                }
            }
        }

        //�����Թ���10��mark��=-1���Ļ��͹��ɣ����򲻹��� ��
        //�����ҹ���һ����������ô�����0�Ļ�����Ȼ��0��ͷ��

        next1=next2=0;
        for(i=0;i<n[0];++i){
            c1[ next1++ ]= '0';
            c2[ next2++ ]= '0';
        }
        for(i=1;i<=9;++i) y[1][i]= y[2][i]= n[i];
        if(mark != -1){
            y[1][mark]--, y[2][10-mark]--;
            c1[ next1++ ]= mark+'0';
            c2[ next2++ ]= (10-mark)+'0';

            for(i=1;i<=4;++i){
                int t= min( y[1][i], y[2][9-i] );
                y[1][i]-= t, y[2][9-i]-= t;
                for(j=1;j<=t;++j){
                    c1[ next1++ ]= i+'0';
                    c2[ next2++ ]= 9-i+'0';
                }
                t= min( y[1][9-i], y[2][i] ); //ע���ⲿ�ֲ����٣�
                y[1][9-i]-= t, y[2][i]-= t;
                for(j=1;j<=t;++j){
                    c1[ next1++ ]= 9-i+'0';
                    c2[ next2++ ]= i+'0';
                }
            }
        }
        for(i=1;i<=9;++i){
            for(j=1;j<=y[1][i];++j)
                c1[ next1++ ]= i+'0';
            for(j=1;j<=y[2][i];++j)
                c2[ next2++ ]= i+'0';
       }
       c1[next1]='\0', c2[next2]='\0';
       strrev(c1); strrev(c2);
       puts(c1); puts(c2);
    }
    //while(1);
}

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <numeric>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <fstream>
#include <list>
#include <sstream>
#include <iostream>
#include <iomanip>

using namespace std;
#define MAX 100005
int main(){

    char s[ MAX ];
    int l;
    scanf("%s" , &s );
    l = strlen( s );
    int a[ 15 ] = { 0 }, a2[ 15 ] = { 0 };
    string n1 = "" , n2 = "";
    for( int i = 0 ; s[ i ] ; ++i ){
        a[ s[ i ] - '0' ]++;
        a2[ s[ i ] - '0' ]++;
    }

    int v1 = 0, v2 = 0;
    for( int i = 0 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        int nv = min( a[ i ] , a2[ 9 - i ] );
        if( t != 0 && nv == 0 ){
            v1 = i;
            v2 = 10 - i;
            break;
        }
        else if( t != 0 && nv != 0 ){
            v1 = i;
            v2 = 10 - i;
        }
    }

    if( v1 != 0 ){
        n1 += (char)( v1 + '0');
        n2 += (char)( v2 + '0');
        a[ v1 ]--;
        a2[ v2 ]--;
    }
    //nueves despues del 1er 10
    for( int i = 0 ; i < 10 ; ++i ){
        int nv = min( a[ i ] , a2[ 9 - i ] );
        for( int j = 0 ; j < nv; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 9 - i + '0');
        }
        a[ i ] -= nv;
        a2[ 9 - i ] -= nv;
    }
    //zeros sobrantes al final
    for( int i = 0 ; i < a[ 0 ] ; ++i ){
        n1 = "0" + n1;
        n2 = "0" + n2;
    }
    //dieces
    for( int i = 1 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        for( int j = 0 ; j < t ; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 10 - i + '0');
        }
        a[ i ] -= t;
        a2[ 10 - i ] -= t;
    }

    for( int i = 1 ; i < 10 ; ++i ){
        for( int j = 0 ; j < a[ i ] ; ++j ) n1 += (char)( i + '0');
        for( int j = 0 ; j < a2[ i ] ; ++j ) n2 += (char)( i + '0');
    }

    reverse( n1.begin() , n1.end() );
    reverse( n2.begin() , n2.end() );
    printf("%s\n%s\n" , n1.c_str() , n2.c_str() );

    return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define db double
#define int long long
#define all(c) (c).begin(), (c).end()
using namespace std;

const int N = 1e6 + 1;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;

inline int read () {
    char c = getchar();
    int t = 0, f = 1;
    while (!isdigit(c)) f = (c == '-') ? -1 : 1, c = getchar();
    while (isdigit(c)) t = t * 10 + c - 48, c = getchar();
    return t * f;
}
int cnt1[10], cnt2[10];
int cnt3[10], cnt4[10];
//int a[N];
main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        cnt3[s[i] - 48] ++;
        cnt4[s[i] - 48] ++;
    }
    int mx = 0;
    int kx = 0, ky = 0;
    for(int i = 1; i < 10; i++) {
        int x = i, y = 10 - i;
        int d = 0;
        for(int i = 0; i < 10; i++) {
            cnt1[i] = cnt3[i];
            cnt2[i] = cnt4[i];
        }
        if(cnt1[x] && cnt2[y]) {
            cnt1[x]--;
            cnt2[y]--;
            d++;
            for(int j = 1; j < 9; j++) {
                int t1 = j, t2 = 9 - j;
                if(cnt1[t1] && cnt2[t2]) {
                    int mn = min(cnt1[t1], cnt2[t2]);
                    cnt1[t1] -= mn;
                    cnt2[t2] -= mn;
                    d += mn;
                }
            }
            if(mx < d) {
                mx = d;
                kx = x;
                ky = y;
            }
        }
    }
    if(mx) {
        int x = kx, y = ky;
        string ans1(cnt3[0], '0');
        string ans2(cnt3[0], '0');
        for(int i = 0; i < 10; i++) {
            cnt1[i] = cnt3[i];
            cnt2[i] = cnt4[i];
        }
        if(cnt1[x] && cnt2[y]) {
            cnt1[x]--;
            cnt2[y]--;
            ans1 += (char)(x + 48);
            ans2 += (char)(y + 48);
            for(int j = 1; j < 9; j++) {
                int t1 = j, t2 = 9 - j;
                if(cnt1[t1] && cnt2[t2]) {
                    int mn = min(cnt1[t1], cnt2[t2]);
                    cnt1[t1] -= mn;
                    cnt2[t2] -= mn;
                    for(int k = 1; k <= mn; k++) {
                        ans1 += (char)(t1 + 48);
                        ans2 += (char)(t2 + 48);
                    }
                }
            }
        }
        for(int i = 1; i < 10; i++) {
            for(int j = 1; j <= cnt1[i]; j++)
                ans1 += (char)(i + 48);
            for(int j = 1; j <= cnt2[i]; j++)
                ans2 += (char)(i + 48);
        }
        reverse(all(ans1));
        reverse(all(ans2));
        cout << ans1 << "\n" << ans2;
    }
    else {
        sort(s.rbegin(), s.rend());
        cout << s << "\n" << s;
    }
}

/*
 * Bidhan Roy
 * University of Dhaka
 */

using namespace std;
#include <bits/stdc++.h>

#define sgn(x,y) ((x)+eps<(y)?-1:((x)>eps+(y)?1:0))
#define rep(i,n) for(auto i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<28)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9

typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector < int > vi;
typedef vector < st > vs;
typedef map < int , int > mii;
typedef map < st , int > msi;
typedef set < int > si;
typedef set < st > ss;
typedef pair < int , int > pii;
typedef vector < pii > vpii;

#define mx 0

unordered_map<int,int> count(st &inp){
    unordered_map < int , int > ret;
    for( auto x : inp ) ret [ x - '0' ] ++;
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    st inp;
    cin >> inp;
    auto cc = count( inp );
    int maxi = -1, idx = -1;
    st ansa, ansb;
    while( cc[0] > 0 ) ansa+='0', ansb+='0', cc[0]--;
    //for( auto x : cc ) cout << x.xx << " = " << x.yy << endl;
    rep(i,10){
        int j = 10 - i ;
        auto aa = cc;
        auto bb = cc;
        if( !aa[i] || !bb[j] ) continue;
        aa [i] --;
        bb [j] --;
        int total = 1;
        rep(k,10){
            int tk = 9 - k;
            int temp = min( aa[k] , bb[tk] );
            total += temp;
            aa[k] -= temp;
            bb[tk] -= temp;
        }
        //cout << i << " " << j << " = " <<total << endl;
        if( maxi < total ) maxi = total, idx = i;
    }
    //assert( idx != -1 );
    //cout << maxi << " " << idx << endl;
    auto cc2 = cc;
    if( idx !=-1 ) {
        ansa += char(idx+'0');
        ansb += char(10-idx+'0');

        cc[ idx ] --;
        cc2[ 10 - idx ] --;
        rep(k,10){
            int tk = 9 - k;
            int temp = min( cc[k] , cc2[tk] );
            cc[k] -= temp;
            cc2[tk] -= temp;
            while( temp -- ){
                ansa += char( k + '0' );
                ansb += char( tk + '0' );
            }
            //cout << " k = " << k << " " << cc[1] << " , " << cc2[1] << endl;
        }
    }
    for( auto x : cc ) while( x.yy-- ) ansa+=char(x.xx+'0');
    for( auto x : cc2 ) while( x.yy-- ) ansb+=char(x.xx+'0');
    reverse(all(ansa));
    reverse(all(ansb));
    cout << ansa << endl << ansb << endl;
    return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

#define sqr(x) ((x)*(x))
#define PB(a) push_back(a)
#define MP(a) make_pair(a)

int n,m,k,p,ans,ci,cj;
string s;
bool f2[200000];
int a[10],b1[10],b2[10],a1[200000],a2[200000];

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> s;
	for (int i=0; i<s.length(); i++) {
		b1[s[i]-'0']++;
		b2[s[i]-'0']++;
	}

	for (int i=0; i<=b1[0]; i++) {
		for (int j=1; j<10; j++) {
			int curans=i;
			if (b1[j]>0 && b1[10-j]>0) curans++;
			else continue;
			b1[j]--; b2[10-j]--;
			for (int k=0; k<10; k++) curans+=min(b1[k],b2[9-k]);
			b1[j]++; b2[10-j]++;
			if (curans>ans) {
				ans=curans;
				ci=i; cj=j;
			}
		}
	}

	for (int i=s.length()-1; s.length()-i<=ci; i--) {
		a1[i]=a2[i]=0;
		b1[0]--; b2[0]--;
		f2[i]=true;
	}

	bool f=true;

	for (int i=s.length()-1; i>=0; i--) {
		if (f2[i]) continue;
		if (f) {
			if (b1[cj]>0 && b1[10-cj]>0) {
				a1[i]=cj; a2[i]=10-cj;
				b1[cj]--; b2[10-cj]--;
			} else {
				for (int j=0; j<10; j++) if (b1[j]>0) {
					b1[j]--; a1[i]=j; break;
				}
				for (int j=0; j<10; j++) if (b2[j]>0) {
					b2[j]--; a2[i]=j; break;
				}
			}
			f=false;
		} else {
			bool f1=true;
			for (int j=0; j<10; j++) {
				if (b1[j] && b2[9-j]) {
					b1[j]--; b2[9-j]--;
					a1[i]=j; a2[i]=9-j;
					f1=false; break;
				}
			}
			if (f1) {
				for (int j=0; j<10; j++) if (b1[j]>0) {
					b1[j]--; a1[i]=j; break;
				}
				for (int j=0; j<10; j++) if (b2[j]>0) {
					b2[j]--; a2[i]=j; break;
				}
			}
		}
	}

	for (int i=0; i<s.length(); i++) cout << a1[i];
	cout << endl;
	for (int i=0; i<s.length(); i++) cout << a2[i];
	cout << endl;

	return 0;
}

//#define DEBUG

// Includes. {{{
//----------------------------------------
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <cmath>
#include <cstdlib>
#ifdef DEBUG
#include <gtest/gtest.h>
#endif
//---------------------------------------- }}}

using namespace std;

int main(int argc, char* argv[]) {
    string s; cin >> s;
    vector<int> count1(10, 0);
    for(int i=0; i<s.size(); ++i)
    {
        ++count1[s[i] - '0'];
    }
    vector<int> count2 = count1;

    int maxCount = -1;
    int I, J;
    for(int i=1; i<=9; ++i)
    {
        int j = 10 - i;
        --count1[i]; --count2[j];

        int count = 0;
        if(count1[i] >= 0 && count2[j] >= 0)
        {
            for(int k=0; k<10; ++k)
            {
                int l = 9 - k;
                count += min(count1[k], count2[l]);
            }
            if(maxCount < count)
            {
                I = i; J = j;
                maxCount = count;
            }
        }

        ++count1[i]; ++count2[j];
    }

    string s1 = "", s2 = "";
    s1 = string(count1[0], '0');
    s2 = string(count2[0], '0');
    count1[0] = count2[0] = 0;

    if(maxCount > 0)
    {
        string tmp;
        s1 += '0' + I;
        s2 += '0' + J;
        --count1[I]; --count2[J];

        for(int i=0; i<10; ++i)
        {
            int j = 9 - i;
            int m = min(count1[i], count2[j]);
            s1 += string(m, '0' + i);
            s2 += string(m, '0' + j);
            count1[i] -= m;
            count2[j] -= m;
        }
    }

    for(int i=0; i<10; ++i)
    {
        int j = 9 - i;
        s1 += string(count1[i], '0' + i);
        s2 += string(count2[j], '0' + j);
    }

    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());

    //cout << I << " " << J << " " << maxCount << endl;
    cout << s1 << endl << s2 << endl;

// Execute test cases. {{{
//----------------------------------------
#ifdef DEBUG
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
#endif
//---------------------------------------- }}}
    return 0;
}

// Test cases. {{{
//----------------------------------------
#ifdef DEBUG
TEST(Example, ex1) {
}
TEST(Normal, ex1) {
}
TEST(Corner, ex1) {
}
#endif
//---------------------------------------- }}}

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

int main() {
  string s;
  while (cin >> s) {
    int a[10] = {}, b[10] = {};
    rep (d, 10) a[d] = b[d] = count(all(s), '0' + d);

    int best_s = -1, best_l = 0;
    for (int s = 1; s <= 9; ++s) {
      int t = 10 - s;
      --a[s];
      --b[t];

      if (a[s] >= 0 && b[t] >= 0) {
        int l = 1, t[10] = {};
        rep (d, 10) {
          l += (t[d] = min(a[d], b[9 - d]));
          a[d]     -= t[d];
          b[9 - d] -= t[d];
        }
        l += min(a[0], b[0]);

        if (l > best_l) {
          best_s = s;
          best_l = l;
        }

        rep (d, 10) {
          a[d]     += t[d];
          b[9 - d] += t[d];
        }
      }

      ++a[s];
      ++b[t];
    }

    string p, q;

    if (best_s != -1) {
      p += '0' + best_s;        --a[best_s];
      q += '0' + (10 - best_s); --b[10 - best_s];

      rep (d, 10) {
        while (a[d] > 0 && b[9 - d] > 0) {
          p += '0' + d;       --a[d];
          q += '0' + (9 - d); --b[9 - d];
        }
      }
    }

    int z = min(a[0], b[0]);
    p = string(z, '0') + p; a[0] -= z;
    q = string(z, '0') + q; b[0] -= z;
    for (int d = 1; d <= 9; ++d) {
      p += string(a[d], '0' + d);
      q += string(b[d], '0' + d);
    }

    reverse(all(p));
    reverse(all(q));
    cout << p << endl
         << q << endl;
  }

  return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int a[10];
int b[10];
int n;
string s;
int solve(int x,int y)
{
    if((x+y)%10!=0)
        return 0;
    int c[10] = {0};
    int d[10] = {0};
    for(int i=0;i<10;i++)
    {
        c[i] = a[i];
        d[i] = b[i];
    }
    if(c[x] == 0 || d[y] == 0)
        return 0;
    c[x]--;
    d[y]--;
    int res = 1;
    int ok = 0;
    if(x == 0 && y == 0)
    {
        ok = 1;
    }
    while(true)
    {
        int take = 0;
        for(int i=0;i<10;i++)
        {
            int rem = ok+9-i;
            if(rem == 10)
                rem = 0;
            if(i == 0 && rem == 0)
                continue;
            ok = 0;
            if(c[i] > 0 && d[rem] > 0)
            {
                res++;
                c[i]--;
                d[rem]--;
                take = 1;
            }
        }
        if(!take)
        {
            res+=min(c[0],d[0]);
            break;
        }
    }
    return res;
}

void solve2(int x,int y)
{
    if((x+y)%10!=0)
        {
            cout<<s<<"\n"<<s<<endl;
            return ;
        }
    int c[10] = {0};
    int d[10] = {0};
    for(int i=0;i<10;i++)
    {
        c[i] = a[i];
        d[i] = b[i];
    }
    if(c[x] == 0 || d[y] == 0)
        {
            return ;
        }
    string R1,R2;
    R1+=char('0'+x);
    R2+=char('0'+y);
    c[x]--;
    d[y]--;
    int res = 1;
    int ok = 0;
    if(x == 0 && y == 0)
    {
        ok = 1;
    }
    string suf;
    while(true)
    {
        int take = 0;
        for(int i=0;i<10;i++)
        {
            int rem = ok+9-i;
            if(rem == 10)
                rem = 0;
            if(i == 0 && rem == 0)
                continue;
            ok = 0;
            if(c[i] > 0 && d[rem] > 0)
            {
                res++;
                c[i]--;
                d[rem]--;
                R1+=char('0'+i);
                R2+=char('0'+rem);
                take = 1;
            }
        }
        if(!take)
        {
            res+=min(c[0],d[0]);
            int minx = min(c[0],d[0]);
            for(int j=0;j<minx;j++)
            {
                suf+='0';
                c[0]--;
                d[0]--;
            }
            for(int j=0;j<10;j++)
            {
                while(c[j] > 0)
                {
                    R1+=char('0'+j);
                    c[j]--;
                }
                while(d[j] > 0)
                {
                    R2+=char('0'+j);
                    d[j]--;
                }
            }
            reverse(R1.begin(),R1.end());
            reverse(R2.begin(),R2.end());
            break;
        }
    }
    R1+=suf;
    R2+=suf;
    cout<<R1<<endl;
    cout<<R2<<endl;
    return ;
}

int main()
{
   cin>>s;
   n = s.size();
   for(int i=0;i<n;i++)
   {
       a[s[i]-'0']++;
       b[s[i]-'0']++;
   }
   int ans = 0;
   for(int i=0;i<10;i++)
   {
       for(int j=0;j<10;j++)
       {
           ans = max(ans , solve(i,j));
       }
   }
   for(int i=0;i<10;i++)
   {
       for(int j=0;j<10;j++)
       {
           if(ans == solve(i,j))
           {
               solve2(i,j);
               return 0 ;
           }
       }
   }
   return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

char str[100008];
int n;   int hash_a[12], hash_b[12];
int a[100008], b[100008];

int main(int argc, char**argv)
{
    while( scanf("%s", str) != EOF )
    {
        n = strlen(str);
        memset(hash_a, 0, sizeof(hash_a));
        memset(hash_b, 0, sizeof(hash_b));
        for(int i=0; i<n; i++)  {
            hash_a[str[i] -= '0']++;
            hash_b[str[i]]++;
        }
        a[0]=b[0]=0;
        for(int i=0; i<10; i++)  if(hash_a[i] && hash_b[10-i])
        {
            a[++a[0]]=i, hash_a[i]--;
            b[++b[0]]=10-i,  hash_b[10-i]--;
            for(int j=0; j<10; j++)  if(hash_a[j] && hash_b[9-j])
            {
                while(hash_a[j] && hash_b[9-j])
                {
                    a[++a[0]]=j, hash_a[j]--;
                    b[++b[0]]=9-j;
                }
            }
            break;
        }

        for(int i=9; i>=0; i--)
        {
            if(hash_a[i])
            for(int j=9; j>=0; j--) if(hash_b[j])
            {
                while(hash_a[i] && hash_b[j])
                {
                    a[++a[0]]=i, hash_a[i]--;
                    b[++b[0]]=j, hash_b[j]--;
                }
            }
        }

        for(int i=0; i<10; i++)  if(hash_a[i] && hash_b[10-i])
        {
            while(hash_a[i] && hash_b[10-i])
            {
                a[++a[0]]=i, hash_a[i]--;
                b[++b[0]]=10-i, hash_b[10-i]--;
            }
        }

        for(int i=a[0]; i>0; i--) cout << a[i];  cout << endl;
        for(int i=b[0]; i>0; i--) cout << b[i];  cout << endl;
    }
    return (EXIT_SUCCESS);
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

#define lowbit(x) ((x)&(-(x)))
#define sqr(x) ((x)*(x))
#define PB push_back
#define MP make_pair

typedef unsigned long long ULL;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;

struct Tpoint
{
    double x,y;
    Tpoint(){}
    Tpoint(double _x,double _y){x=_x;y=_y;}
    inline void read(){scanf("%lf%lf",&x,&y);}
    inline void show(){printf("%lf %lf\n",x,y);}
    inline double norm(){ return sqrt( sqr(x)+sqr(y) ); }
};

inline Tpoint operator +(const Tpoint &a,const Tpoint &b){ return Tpoint(a.x+b.x,a.y+b.y); }
inline Tpoint operator -(const Tpoint &a,const Tpoint &b){ return Tpoint(a.x-b.x,a.y-b.y); }
inline Tpoint operator *(const Tpoint &a,const double &b){ return Tpoint(a.x*b,a.y*b); }
inline Tpoint operator /(const Tpoint &a,const double &b){ return Tpoint(a.x/b,a.y/b); }
inline double det(const Tpoint &a,const Tpoint &b){ return a.x*b.y-a.y*b.x; }
inline double dot(const Tpoint &a,const Tpoint &b){ return a.x*b.x+a.y*b.y; }
//=============================================================================================

char s[100005],s1[100005],s2[100005];
int cnt[15],c1[15],c2[15];

inline int solve(char s[])
{
    int id1[100],id2[100];
    int res=0;
    int n=strlen(s);
    for (int i=0;i<n;++i)
        id1[i]=i;
    do{
        for (int i=0;i<n;++i)
            id2[i]=i;
        do{
            int inc=0;
            int cur=0;
            for (int i=0;i<n;++i){
                int st=s[id1[i]]-'0'+s[id2[i]]-'0'+inc;
                if (st%10) break;
                inc=st/10;
                ++cur;
            }
            res=max(res,cur);
        }while (next_permutation(id2,id2+n));
    }while (next_permutation(id1,id1+n));
    return res;
}

int main()
{
    scanf("%s",s);
//printf("best = %d\n",solve(s));
    for (int i=0;s[i];++i){
        ++cnt[s[i]-'0'];
    }
    int n=strlen(s);
    s1[n]=s2[n]=0;
    int best=0;
    while (cnt[0]>0){
        s1[n-1]=s2[n-1]='0';
        --n;
        --cnt[0];
        ++best;
    }

    if (n>0){
        for (int i=0;i<=9;++i)
            c1[i]=c2[i]=cnt[i];
        int ans=0,x,y;
        for (int i=1;i<=9;++i){
            int j=10-i;
            if (c1[i]==0 || c2[j]==0) continue;

            --c1[i];
            --c2[j];

            int c=1;
            for (int j=1;j<=9;++j){
                c+=min(c1[j],c2[9-j]);
            }

            if (c>ans){
                ans=c;
                x=i;
                y=j;
            }

            ++c1[i];
            ++c2[j];
        }
        best+=ans;
        if (ans!=0){
            s1[n-1]=x+'0';
            s2[n-1]=y+'0';
            --c1[x];
            --c2[y];
            --n;

            for (int i=1;i<=9;++i){
                while (c1[i]>0 && c2[9-i]>0){
                    --c1[i];
                    --c2[9-i];
                    s1[n-1]=i+'0';
                    s2[n-1]=9-i+'0';
                    --n;
                }
            }
        }

        int bak=n;
        for (int i=0;i<=9;++i)
        while (c1[i]>0){
            s1[n-1]=i+'0';
            --c1[i];
            --n;
        }
        n=bak;
        for (int i=0;i<=9;++i)
        while (c2[i]>0){
            s2[n-1]=i+'0';
            --n;
            --c2[i];
        }
    }

    memset(cnt,0,sizeof(cnt));
    for (int i=0;s[i];++i){
        ++cnt[s[i]-'0'];
    }
    for (int i=0;i<=9;++i)
        c1[i]=c2[i]=cnt[i];
    int cur=0,x,y;
    for (int i=1;i<=9;++i){
        int j=10-i;
        if (c1[i]==0 || c2[j]==0) continue;

        --c1[i];
        --c2[j];

        int c=1;
        for (int j=0;j<=9;++j){
            c+=min(c1[j],c2[9-j]);
        }

        if (c>cur){
            cur=c;
            x=i;
            y=j;
        }

        ++c1[i];
        ++c2[j];
    }
    if (cur>best){
        n=strlen(s);
        s1[n-1]=x+'0';
        s2[n-1]=y+'0';
        --c1[x];
        --c2[y];
        --n;
        for (int i=0;i<=9;++i)
        while (c1[i]>0 && c2[9-i]>0){
            --c1[i];
            --c2[9-i];
            s1[n-1]=i+'0';
            s2[n-1]=9-i+'0';
            --n;
        }
        int bak=n;
        for (int i=0;i<=9;++i)
        while (c1[i]>0){
            s1[n-1]=i+'0';
            --c1[i];
            --n;
        }
        n=bak;
        for (int i=0;i<=9;++i)
        while (c2[i]>0){
            s2[n-1]=i+'0';
            --n;
            --c2[i];
        }
    }

    puts(s1);
    puts(s2);

    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 100010;
const int MAXA = 10;

int cnt[2][MAXA];
char s[MAXN];

char resa[MAXN], resb[MAXN];

int n;

inline int zero_tot()
{
  int tot = 1;
  for (int i = 0; i < 5; ++i) tot += max(min(cnt[0][i], cnt[1][9-i]), min(cnt[1][i], cnt[0][9-i]));
  return tot;
}

void cal_res(int l0, int l1, int rm_zero)
{
  resa[n] = resb[n] = 0;

  int i = n-1, j;
  cnt[0][0] -= rm_zero;
  cnt[1][0] -= rm_zero;
  for (; rm_zero--; --i) resa[i] = resb[i] = '0';

  if (l0 != -1) {
    resa[i] = (char)l0 + '0';
    resb[i] = (char)l1 + '0';
    --i;
    --cnt[0][l0];
    --cnt[1][l1];
  }

  for (; i >= 0; --i)  {
    for (j = 0; j <= 9; ++j)
      if (cnt[0][j] && cnt[1][9-j]) break;

    if (j <= 9) {
      --cnt[0][j];
      --cnt[1][9-j];
      resa[i] = j + '0';
      resb[i] = (9-j) + '0';
    } else
      break;
  }

  for (; i >= 0; --i) {
    for (int j = 1; j < 10; ++j)
      if (cnt[0][j]) { --cnt[0][j]; resa[i] = j + '0'; break; }
    for (int j = 1; j < 10; ++j)
      if (cnt[1][j]) { --cnt[1][j]; resb[i] = j + '0'; break; }
  }
}

void solve()
{
  memset(cnt, 0, sizeof(cnt));

  n = strlen(s);
  for (int i = 0; i < n; ++i) ++cnt[0][s[i]-'0'], ++cnt[1][s[i]-'0'];

  int zero = cnt[0][0];
  int l0 = -1, l1 = -1, zero_max = 0, rm_zero = 0;

  for (int l = 0; l <= zero; ++l) {
    cnt[0][0] -= l;
    cnt[1][0] -= l;
    for (int tmp, i = 1; i <= 5; ++i)
      if (cnt[0][i] > 0 && cnt[1][10-i] > 0) {
	--cnt[0][i];
	--cnt[1][10-i];
	if ( (tmp = zero_tot()) + l > zero_max) {
	  zero_max = tmp + l;
	  rm_zero = l;
	  l0 = i;
	  l1 = 10-i;
	}
	++cnt[0][i];
	++cnt[1][10-i];
      }
    cnt[0][0] += l;
    cnt[1][0] += l;
  }

  if (l0 == -1) rm_zero = zero;
  cal_res(l0, l1, rm_zero);
  puts(resa);
  puts(resb);
}

int main()
{
  scanf("%s", s);
  solve();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define SZ(x) ((int)x.size())

vector <int> cnt1(10, 0), cnt2(10, 0);

int fu() {
    int ret = 0;
    vector <int> bk1 = cnt1, bk2 = cnt2;
    for(int i=0; i<=9; i++) {
        int j = 9 - i;
        int mn = min(bk1[i], bk2[j]);
        bk1[i] -= mn, bk2[j] -= mn;
        ret += mn;
    }
    ret += bk1[0];
    return ret;
}

void build(int idx) {
    string a, b;
    if(idx) {
        a += char('0' + idx);
        b += char('0' + 10 - idx);
        -- cnt1[idx], -- cnt2[10-idx];
        for(int i=0; i<=9; i++) {
            int j = 9 - i;
            int mn = min(cnt1[i], cnt2[j]);
            cnt1[i] -= mn, cnt2[j] -= mn;
            while(mn --) {
                a = char('0' + i) + a;
                b = char('0' + j) + b;
            }
        }
    }
    string t(cnt1[0],'0');
    a += t, b += t;
    for(int i=1; i<=9; i++) {
        while(cnt1[i] --) {
            a = char('0' + i) + a;
        }
        while(cnt2[i] --) {
            b = char('0' + i) + b;
        }
    }
    cout << a << endl;
    cout << b << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string str; cin >> str;

    for(int i=0; i<SZ(str); ++ i) {
        ++ cnt1[str[i]-'0'];
        ++ cnt2[str[i]-'0'];
    }

    int zs = 0, idx = 0;
    for(int i=1; i<=5; i++) {
        int j = 10 - i;
        if(cnt1[i] && cnt2[j]) {
            -- cnt1[i], -- cnt2[j];
            int t = fu();
            if(t > zs) {
                zs = t, idx = i;
            }
            ++ cnt1[i], ++ cnt2[j];
        }
    }

    build(idx);

    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int vis1[10];
int vis2[10];
int s2[10];
string str;

int sum_9()
{
    int i,j;
    int res=0;
    for(i=1; i<=9; i++)
    {
        res+=min(vis1[i],vis2[9-i]);
    }
    return res;
}

int getmax()
{
    int i,j;
    int res=0;
    int idx=-1;
    for(i=1; i<=9; i++)
    {
        if(vis1[i]&&vis2[10-i])
        {
            vis1[i]--,vis2[10-i]--;
            int t=sum_9()+1;
            vis1[i]++,vis2[10-i]++;

            if(t>res)
            {
                idx=i;
                res=t;
            }
        }
    }
    return idx;
}

int main()
{
    //freopen("input.txt","r",stdin);
    int i,j;
    cin>>str;
    for(i=0; i<str.size(); i++)
    {
        vis1[str[i]-'0']++;
        vis2[str[i]-'0']++;
    }
    int id=getmax();

    string ans1,ans2;

    if(id!=-1)
    {
        ans1+=id+'0';
        ans2+=10-id+'0';
        vis1[id]--,vis2[10-id]--;

        for(i=1; i<=9; i++)
        {
            while(vis1[i]&&vis2[9-i])
            {
                ans1+=i+'0';
                ans2+=9-i+'0';
                vis1[i]--,vis2[9-i]--;
            }
        }
        reverse(ans1.begin(),ans1.end());
        reverse(ans2.begin(),ans2.end());
        // cout<<ans1<<"  "<<ans2<<endl;
    }

    while(vis1[0]&&vis2[0])
    {
        ans1+=0+'0';
        ans2+=0+'0';
        vis1[0]--;
        vis2[0]--;
    }

    // cout<<ans1<<"  "<<ans2<<endl;
    reverse(ans1.begin(),ans1.end());
    reverse(ans2.begin(),ans2.end());

    for(i=1; i<=9; i++)
    {
        while(vis1[i])
        {
            ans1+=i+'0';
            vis1[i]--;
        }
        while(vis2[i])
        {
            ans2+=i+'0';
            vis2[i]--;
        }
        //cout<<ans1<<"  "<<ans2<<endl;
    }

    // cout<<ans1<<" *** "<<ans2<<endl;

    reverse(ans1.begin(),ans1.end());
    reverse(ans2.begin(),ans2.end());

    cout<<ans1<<endl<<ans2<<endl;
}

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <list>
using namespace std;
char s[100010];
list<int> ans_a,ans_b;
int main(){
#ifndef ONLINE_JUDGE
	freopen("prob.in","r",stdin);
#endif
	scanf("%s",s);
	int n=strlen(s),t,max_zero=0,cnt[10]={0},cnt_a[10],cnt_b[10]={0};
	for(int i=0; i<n; i++)
		cnt[s[i]-'0']++;
	for(int i=0; i<10; i++)
		cnt_a[i]=cnt_b[i]=cnt[i];
	for(int i=1; i<=9; i++){
		if(cnt_a[i]&&cnt_b[10-i]){
			cnt_a[i]--;
			cnt_b[10-i]--;
			int zero=1;
			for(int i=0; i<10; i++){
				int t=min(cnt_a[i],cnt_b[9-i]);
				cnt_a[i]-=t;
				cnt_b[9-i]-=t;
				zero+=t;
			}
			zero+=min(cnt_a[0],cnt_b[0]);
			max_zero=max(max_zero,zero);
			memcpy(cnt_a,cnt,sizeof(cnt));
			memcpy(cnt_b,cnt,sizeof(cnt));
		}
	}
	for(int i=1; i<=9; i++){
		if(cnt_a[i]&&cnt_b[10-i]){
			cnt_a[i]--;
			cnt_b[10-i]--;
			int zero=1;
			for(int j=0; j<10; j++){
				t=min(cnt_a[j],cnt_b[9-j]);
				cnt_a[j]-=t;
				cnt_b[9-j]-=t;
				zero+=t;
			}
			zero+=min(cnt_a[0],cnt_b[0]);
			memcpy(cnt_a,cnt,sizeof(cnt));
			memcpy(cnt_b,cnt,sizeof(cnt));
			if(zero==max_zero){
				ans_a.push_back(i);
				ans_b.push_back(10-i);
				cnt_a[i]--;
				cnt_b[10-i]--;
				for(int j=0; j<10; j++){
					t=min(cnt_a[j],cnt_b[9-j]);
					for(int k=1; k<=t; k++)
						ans_a.push_front(j),ans_b.push_front(9-j);
					cnt_a[j]-=t;
					cnt_b[9-j]-=t;
				}
				t=min(cnt_a[0],cnt_b[0]);
				for(int j=1; j<=t; j++){
					ans_a.push_back(0);
					ans_b.push_back(0);
				}
				cnt_a[0]-=t;
				cnt_b[0]-=t;
				for(int j=0; j<10; j++){
					for(int k=1; k<=cnt_a[j]; k++)
						ans_a.push_front(j);
					for(int k=1; k<=cnt_b[j]; k++)
						ans_b.push_front(j);
				}
				for(list<int>::iterator it=ans_a.begin(); it!=ans_a.end(); ++it){
					printf("%d",*it);
				}
				printf("\n");
				for(list<int>::iterator it=ans_b.begin(); it!=ans_b.end(); ++it){
					printf("%d",*it);
				}
				return 0;
			}
		}
	}
	for(int i=1; i<10; i++)
		for(int j=1; j<=cnt[i]; j++)
			printf("%d",i);
	for(int i=1; i<=cnt[0]; i++)
		printf("0\n");
	return 0;
}

#pragma comment(linker,"/STACK:256000000")
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	//freopen("1.txt","r",stdin);
	string s;
	getline(cin,s);
	vector<int> a(10),b(10);
	for(int i=0;i<s.size();i++)
		a[s[i]-'0']++;
	b=a;
	string t,h;
	t=s;
	h=s;
	int em=s.size()-1;
	int M=a[0];
	while(a[0]){
		a[0]--;
		b[0]--;
	}
	int max=0,maxi=0,maxk=0;
	for(int i=1;i<=5;i++){
		vector<int> aa,bb;
		aa=a;
		bb=b;
		if(aa[i]==0) continue;
		aa[i]--;
		if(bb[10-i]==0) continue;
		bb[10-i]--;
		int m=0;
		for(int j=1;j<10;j++)
			m+=min(aa[j],bb[9-j]);
		if(m+M>max){
			max=m+M;
			maxk=M;
			maxi=i;
		}
		aa[0]=M;
		bb[0]=M;
		int p=min(aa[9],bb[0]);
		m+=p;
		aa[9]-=p;
		bb[0]-=p;
		p=min(bb[9],aa[0]);
		m+=p;
		bb[9]-=p;
		aa[0]-=p;

		if(m+min(aa[0],bb[0])>max){
			max=m+min(aa[0],bb[0]);
			maxk=min(aa[0],bb[0]);
			maxi=i;
		}
	}
	a[0]=M;
	b[0]=M;
	if(maxi!=0){

		for(int i=0;i<maxk;i++)
		{
			t[em]='0';
			h[em]='0';
			em--;
			a[0]--;
			b[0]--;
		}
		t[em]='0'+maxi;
		a[maxi]--;
		h[em]='0'+10-maxi;
		b[10-maxi]--;
		em--;
		for(int j=0;j<10;j++)
			while(min(a[j],b[9-j])>0){
				t[em]='0'+j;
				h[em]='0'+9-j;
				em--;
				a[j]--;
				b[9-j]--;
			}
	}
	else{
		while(a[0]){
			t[em]='0';
			h[em]='0';
			em--;
			a[0]--;
			b[0]--;
		}
	}

	int emi=em;
	for(int i=0;i<10;i++)
		while(a[i]){
			t[emi]='0'+i;
			a[i]--;
			emi--;
		}
	emi=em;
	for(int i=0;i<10;i++)
		while(b[i]){
			h[emi]='0'+i;
			b[i]--;
			emi--;
		}

	cout<<t<<endl<<h<<endl;

}

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    vector <int> arr(10, 0), a ,b, ttt;
    int n = s.length();
    for (int i = 0; i < n; i++)
        arr[s[i] - '0']++;
    int ans = 0;
    for (int i = 0; i <= arr[0]; i++)
    {
        int res = i;
        ttt = arr;
        arr[0] -= i;
        a = arr;
        b = arr;
        int tmp = res;
        for (int j = 1; j <= 9; j++)
        {
            if (min(arr[j], arr[10 - j]) == 0)
                continue;
            res = tmp;
            res++;
            a[j]--;
            b[10 - j]--;
            for (int k = 0; k <= 9; k++)
                res += min(a[k], b[9 - k]);
            ans = max(ans, res);
        }
        ans = max(ans, res);
        arr = ttt;
    }

    for (int i = 0; i <= arr[0]; i++)
    {
        int res = i;
        ttt = arr;
        arr[0] -= i;
        a = arr;
        b = arr;
        int tmp = res;
        for (int j = 1; j <= 9; j++)
        {
            if (min(arr[j], arr[10 - j]) == 0)
                continue;
            res = tmp;
            res++;
            a[j]--;
            b[10 - j]--;
            for (int k = 0; k <= 9; k++)
                res += min(a[k], b[9 - k]);
            if (ans == res)
            {
                string s1, s2;
                for (int k = 0; k < i; k++)
                {
                    s1.push_back('0');
                    s2.push_back('0');
                }
                s1.push_back(j + '0');
                s2.push_back(10 - j + '0');
                for (int k = 0; k <= 9; k++)
                {
                    int x = min(a[k], b[9 - k]);
                    for (int y = 0; y < x; y++)
                    {
                        s1.push_back(k + '0');
                        s2.push_back(9 - k + '0');
                    }
                }
                vector <int> tmp(10, 0);
                for (int i = 0; i < s1.length(); i++)
                    tmp[s1[i] - '0']++;
                for (int i = 0; i < 10; i++)
                    for (int j = 0; j < arr[i] - tmp[i]; j++)
                        s1.push_back(i + '0');

                tmp.assign(10, 0);
                for (int i = 0; i < s2.length(); i++)
                    tmp[s2[i] - '0']++;
                for (int i = 0; i < 10; i++)
                    for (int j = 0; j < arr[i] - tmp[i]; j++)
                        s2.push_back(i + '0');
                reverse(s1.begin(), s1.end());
                reverse(s2.begin(), s2.end());
                cout << s1 << endl << s2 << endl;
                return 0;
            }
        }
        arr = ttt;
    }
    string s1, s2;
    for (int k = 0; k < ans; k++)
    {
        s1.push_back('0');
        s2.push_back('0');
    }

    vector <int> tmp(10, 0);
    for (int i = 0; i < s1.length(); i++)
        tmp[s1[i] - '0']++;
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < arr[i] - tmp[i]; j++)
            s1.push_back(i + '0');

    tmp.assign(10, 0);
    for (int i = 0; i < s2.length(); i++)
        tmp[s2[i] - '0']++;
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < arr[i] - tmp[i]; j++)
            s2.push_back(i + '0');
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    cout << s1 << endl << s2 << endl;
    return 0;
}

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <numeric>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <fstream>
#include <list>
#include <sstream>
#include <iostream>
#include <iomanip>

using namespace std;
#define MAX 100005
int main(){

    char s[ MAX ];
    int l;
    scanf("%s" , &s );
    l = strlen( s );
    int a[ 15 ] = { 0 }, a2[ 15 ] = { 0 };
    string n1 = "" , n2 = "";
    for( int i = 0 ; s[ i ] ; ++i ){
        a[ s[ i ] - '0' ]++;
        a2[ s[ i ] - '0' ]++;
    }

    int v1 = 0, v2 = 0;
    for( int i = 0 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        int nv = min( a[ i ] , a2[ 9 - i ] );
        if( t != 0 && nv == 0 ){
            v1 = i;
            v2 = 10 - i;
            break;
        }
        else if( t != 0 && nv != 0 ){
            v1 = i;
            v2 = 10 - i;
        }
    }

    if( v1 != 0 ){
        n1 += (char)( v1 + '0');
        n2 += (char)( v2 + '0');
        a[ v1 ]--;
        a2[ v2 ]--;
    }
    //nueves despues del 1er 10
    for( int i = 0 ; i < 10 ; ++i ){
        int nv = min( a[ i ] , a2[ 9 - i ] );
        for( int j = 0 ; j < nv; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 9 - i + '0');
        }
        a[ i ] -= nv;
        a2[ 9 - i ] -= nv;
    }
    //zeros sobrantes al final
    int z = min( a[ 0 ] , a2[ 0 ] );
    for( int i = 0 ; i < z ; ++i ){
        n1 = "0" + n1;
        n2 = "0" + n2;
    }
    a[ 0 ] -= z;
    a2[ 0 ] -= z;
    //dieces
    for( int i = 1 ; i < 10 ; ++i ){
        int t = min( a[ i ] , a2[ 10 - i ] );
        for( int j = 0 ; j < t ; ++j ){
            n1 += (char)( i + '0');
            n2 += (char)( 10 - i + '0');
        }
        a[ i ] -= t;
        a2[ 10 - i ] -= t;
    }

    for( int i = 0 ; i < 10 ; ++i ){
        for( int j = 0 ; j < a[ i ] ; ++j ) n1 += (char)( i + '0');
        for( int j = 0 ; j < a2[ i ] ; ++j ) n2 += (char)( i + '0');
    }

    reverse( n1.begin() , n1.end() );
    reverse( n2.begin() , n2.end() );
    printf("%s\n%s\n" , n1.c_str() , n2.c_str() );

    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define N 200000
char a[ N ], b[ N ];
int ia[ 10 ], ib[ 10 ];
char linha[ N ];

int main(){
    scanf( "%s", linha );
    memset( ia, 0, sizeof ia );
    memset( ib, 0, sizeof ib );

    for( int i = 0; linha[i]; ++i ){
        ++ia[ linha[i] - '0' ];
        ++ib[ linha[i] - '0' ];
    }

    int maior = 0, index = 1;
    for( int i = 1; i < 10; ++i ){
        if( min( ia[ i ], ib[ 10 - i ] ) > 0 ){
            int tmp = 1;
            --ia[ i ];
            --ib[ 10 - i ];

            for( int j = 0; j <= 9; ++j ){
                int qtd = min( ia[ j ], ib[ 9 - j ] ) ;
                if( qtd > 0 ) tmp += qtd;
            }
            if( tmp > maior ){
                maior = tmp;
                index = i;
            }
            ++ia[ i ];
            ++ib[ 10 - i ];
        }
    }

    for( int i = 1; i < 10; ++i ){
        if( min( ia[ i ], ib[ 10 - i ] ) > 0 ){
            int tmp = 1 + ia[ 0 ];
            --ia[ i ];
            --ib[ 10 - i ];

            for( int j = 1; j < 9; ++j ){
                int qtd = min( ia[ j ], ib[ 9 - j ] ) ;
                if( qtd > 0 ) tmp += qtd;
            }
            if( tmp > maior ){
                maior = tmp;
                index = -i;
            }
            ++ia[ i ];
            ++ib[ 10 - i ];
        }
    }

    if( !maior ){
        int prt = strlen( linha ) - 1;
        for( int i = 0; i < 10; ++i ){
            while( ia[ i ] ){
                linha[ prt-- ] = i + '0';
                --ia[ i ];
            }
        }

        printf( "%s\n%s\n", linha, linha );
    }else{
        int prt = 0;
        if( index < 0 ){
            index = -index;
            while( ia[ 0 ] ){
                a[ prt ] = '0';
                b[ prt++ ] = '0';
                --ia[ 0 ];
                --ib[ 0 ];
            }
        }
        a[ prt ] = index + '0';
        b[ prt ] = 10 - index + '0';
        --ia[ index ];
        --ib[ 10 - index ];
        ++prt;

        for( int i = 0; i < 10; ++i ){
            int qtd = min( ia[ i ], ib[ 9 - i ] );
            if( qtd > 0 ){
                for( int j = 0; j < qtd; ++j ){
                    a[ prt ] = i + '0';
                    b[ prt++ ] = 9 - i + '0';
                }
                ia[ i ] -= qtd;
                ib[ 9 - i ] -= qtd;
            }
        }

        int pa = prt, pb = prt;
        for( int i = 1; i < 10; ++i ){
            while( ia[ i ] ){
                a[ pa++ ] = i + '0';
                --ia[ i ];
            }

            while( ib[ i ] ){
                b[ pb++ ] = i + '0';
                --ib[ i ];
            }
        }

        while( ia[ 0 ] > ib[ 0 ] ){
            a[ pa++ ] = '0';
            --ia[ 0 ];
        }

        while( ib[ 0 ] > ia[ 0 ] ){
            b[ pb++ ] = '0';
            --ib[ 0 ];
        }
        reverse( a, a + pa );
        reverse( b, b + pb );

        while( ia[ 0 ] && ib[ 0 ] ){
            a[ pa++ ] = b[ pb++ ] = '0';
            --ia[ 0 ];
            --ib[ 0 ];
        }
        a[ pa ] = 0;
        b[ pb ] = 0;
        printf( "%s\n%s\n", a, b );
    }

}

#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <vector>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define INF 1e9
#define pb push_back
#define mp make_pair
#define forn(i,n) for (int i = 0; i < n; i++)
#define MAXN 10

using namespace std;

typedef long long ll;
typedef vector <int> vt;

string s;
vector <int> g(MAXN);

int ans = -1, mxa, mxz;
string ans1, ans2;

void solve(int z, int a)
{
    vt x = g;
    vt y = g;
    if (z > x[0])
        return;
    int res = 0;
    res += z;
    x[0] -= z;
    y[0] -= z;
    if (x[a] && y[10 - a])
    {
        x[a]--;
        y[10 - a]--;
    }
    else
    {
        if (res > ans)
        {
            ans = res;
            mxa = a;
            mxz = z;
        }
        return;
    }
    for (int i = 0; i < 10; i++)
    {
        int m = min(x[i], y[9 - i]);
        res += m;
        x[i] -= m;
        y[9 - i] -= m;
    }
    if (res > ans)
    {
        ans = res;
        mxa = a;
        mxz = z;
    }
    return;
}

void add(vt x, string &s)
{
    forn (i, 10)
    {
        int t = x[i];
        forn (j, t)
        {
            s.pb(i + '0');
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> s;
    forn (i, s.size())
    {
        g[s[i] - '0']++;
    }
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j < 10; j++)
        {
            solve(i, j);
        }
    }
    vt x = g;
    vt y = g;
    forn (i, mxz)
    {
        ans1.pb('0');
        ans2.pb('0');
        x[0]--;
        y[0]--;
    }
    if (x[mxa] && y[10 - mxa])
    {
        ans1.pb(mxa + '0');
        ans2.pb(10 - mxa + '0');
        x[mxa]--;
        y[10 - mxa]--;
    }
    for (int i = 0; i < 10; i++)
    {
        int m = min(x[i], y[9 - i]);
        forn (j, m)
        {
            ans1.pb(i + '0');
            ans2.pb(9 - i + '0');
        }
        x[i] -= m;
        y[9 - i] -= m;
    }
    add(x, ans1);
    add(y, ans2);
    reverse(ans1.begin(), ans1.end());
    reverse(ans2.begin(), ans2.end());
    cout << ans1 << endl;
    cout << ans2 << endl;
    return 0;
}

//#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define infll 0x3f3f3f3f3f3f3f3f
#define il inline
#define re register
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define MP make_pair
#define lowbit(x) x&(-x)
#define fi first
#define se second
il ll read()
{
	char ch = getchar();
	ll 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;
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
void exgcd(ll a, ll b, ll &x,ll &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;
	while(num[0])
	{
		num[0]--;
		ans1[m] = '0';
		ans2[m] = '0';
		m--;
	}
	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 = 1; j <= 9; j++)
			tn[j][1] = tn[j][0] = num[j];
		tn[i][1]--,tn[t][0]--;
		for(int j = 1; j <= 8; j++)
			now += min(tn[j][1],tn[9-j][0]);
		if(now >= mx)
		{
			t1 = i;
			t2 = t;
			mx = now;
		}
	//	cout<<i<<" "<<t<<" "<<now<<endl;
	}
	int tn[10][2];
	for(int j = 1; j <= 9; j++)
		tn[j][1] = tn[j][0] = num[j];
	if(t1 && t2)
	{
		ans1[m] = t1+'0';
		ans2[m] = t2+'0';
		tn[t1][0]--;
		tn[t2][1]--;
		m--;
	}
	for(int i = m; i >= 1; i--)
	{
		if(mx)
		{
			mx--;
			for(int j = 1; j <= 8; j++)
				if(min(tn[j][0],tn[9-j][1]))
				{
					tn[j][0]--;
					tn[9-j][1]--;
					ans1[i] = j+'0';
					ans2[i] = 9-j+'0';
					break;
				}
		}
		else
		{
			for(int j = 1; j <= 9; j++)
				if(tn[j][0])
				{
					tn[j][0]--;
					ans1[i] = j+'0';
					break;
				}
			for(int j = 1; j <= 9; j++)
				if(tn[j][1])
				{
					tn[j][1]--;
					ans2[i] = j+'0';
					break;
				}
		}
	}
	printf("%s\n%s",ans1+1,ans2+1);
	return 0;
}

#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <float.h>
#include <ctime>
#include <list>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

int solve(VI& cnt1, VI& cnt2, string& f, string& s, int carry) {
  int res = 0;
  while (true) {
    FOR (i, 10) FOR (j, 10) {
      if (cnt1[i] > 0 && cnt2[j] > 0) {
        if ((i + j + carry) % 10 == 0) {
          f += i + '0';
          s += j + '0';
          carry = (i + j + carry) / 10;
          --cnt1[i];
          --cnt2[j];
          ++res;
          goto next;
        }
      }
    }

    break;
next:
    continue;
  }

  return res;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  ios_base::sync_with_stdio(false);

  string number;
  cin >> number;

  VI cnt1(10), cnt2(10);
  FOR (i, SIZE(number)) {
    ++cnt1[number[i] - '0'];
    ++cnt2[number[i] - '0'];
  }

  VI gcnt1 = cnt1, gcnt2 = cnt2;
  int best = 0;
  string f, s;
  FOR (i, 10) FOR (j, 10) if (gcnt1[i] && gcnt2[j] && (i + j) % 10 == 0){
    string f_(1, i + '0'), s_(1, j + '0');
    VI cnt1_ = gcnt1, cnt2_ = gcnt2;
    --cnt1_[i];
    --cnt2_[j];
    int res = solve(cnt1_, cnt2_, f_, s_, (i + j) / 10) + 1;
    if (res > best) {
      best = res;
      f = f_;
      s = s_;
      cnt1 = cnt1_;
      cnt2 = cnt2_;
    }
  }

  int const remains = SIZE(number) * 2 - SIZE(f) - SIZE(s);
  int need1 = remains / 2;
  int need2 = remains / 2;
  FOR (i, 10) {
    while (need1 && cnt1[i]) {
      --cnt1[i];
      f += i + '0';
      --need1;
    }
  }

  FOR (i, 10) {
    while (need2 && cnt2[i]) {
      --cnt2[i];
      s += i + '0';
      --need2;
    }
  }

  reverse(ALL(f));
  reverse(ALL(s));
  cout << f << " " << s << endl;

  return 0;
}

/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

string str;
int num[10], m[10], n, num2[10];
string ans,ans2;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> str;
    int n = str.size();
    FOR(i,0,n) num[str[i]-'0']++;
    FOR(i,0,10) num2[i] = num[i];
    FOR(i,0,10) m[i] = min(num[i],num[9-i]);

    FOR(i,0,num[0])
    {
	ans.pb('0');
	ans2.pb('0');
    }
    num[0] = 0;
    num2[0] = 0;

    int mini = INF, a=-1,b=-1;
    FOR(i,1,10)
    {
	int j = (10-i)%10;
	if(!num[i] || !num[j]) continue;
	int now = (int)(num[i] == m[i]) + (num[j] == m[j]);
	if(now < mini)
	{
	    mini = now;
	    a = i;
	    b = j;
	}
    }

    if(mini == INF)
    {
	cout << str << endl << str;
	return 0;
    }

    num[a]--;
    num2[b]--;
    ans.pb(a+'0');
    ans2.pb(b+'0');
    FOR(i,0,10) m[i] = min(num[i],num2[9-i]);
    FOR(i,0,10)
    {
	FOR(j,0,m[i])
	{
	    ans.pb(i+'0');
	    ans2.pb(9-i+'0');
	    num[i]--;
	    num2[9-i]--;
	}
    }
    FOR(i,0,10)
    {
	FOR(j,0,num[i]) ans.pb(i+'0');
	FOR(j,0,num2[i]) ans2.pb(i+'0');
    }
    reverse(all(ans));
    reverse(all(ans2));
    cout << ans << endl << ans2;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
#define UNIQ(x) sort(x.begin(),x.end()); x.erase(unique(x.begin(),x.end()),x.end());
int main(){
    int a[10] = {}, b[10] = {};
    string s;
    cin >> s;
    sort(s.rbegin(),s.rend());
    for(char c : s){
        a[c-'0']++;
        b[c-'0']++;
    }
    string A,B;
    vector<int> arr;
    for(int i = 0; i <= 9; ++i)
        while(a[i] > 0 && b[9-i] > 0){
            arr.push_back(i);
            a[i]--;
            b[9-i]--;
        }
    while(a[0] > 0){
        A += "0";
        B += "0";
        a[0]--;
        b[0]--;
    }
    bool found = false;
    for(int i = 1; i <= 9; ++i)
        if(a[i] > 0 && b[10-i] > 0){
            //optimal
            a[i]--;
            b[10-i]--;
            A.push_back(i+'0');
            B.push_back(10-i+'0');
            found = true;
            break;
        }
    if(!found)
        for(int i = 0; i < arr.size(); ++i){
            if(arr[i] > 0 && b[10-arr[i]] > 0){
                b[9-arr[i]]++;
                b[10-arr[i]]--;
                A.push_back(arr[i]+'0');
                B.push_back(10-arr[i]+'0');
                found = true;
                arr.erase(arr.begin()+i);
                break;
            }
        }
    if(!found){
        cout << s << '\n';
        cout << s << '\n';
        return 0;
    }
    for(int x : arr){
        A.push_back(x+'0');
        B.push_back(9-x+'0');
    }
    for(int i = 1; i <= 9; ++i) while(a[i]-- > 0) A.push_back(i+'0');
    for(int i = 1; i <= 9; ++i) while(b[i]-- > 0) B.push_back(i+'0');
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    cout << A << '\n';
    cout << B << '\n';
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
using namespace std;

#define MP make_pair
#define PB push_back
#define two(X) (1<<(X))
#define SIZE(A) ((int)(A.size()))
#define LENGTH(A) ((int)A.length())
#define random(x) (rand()%x)
#define randomize() (srand((int)time(0)))

typedef long long int64;
typedef vector<int> VI;
typedef vector<string> VS;

const int MAXN=200000;
const int INF=0x7FFFFFFF;
const double eps=1e-10;
const double pi=acos(-1.0);

int n;
string st;
vector<int> num1,num2;
int u[20],v[20],U[20],V[20];

int calc(int x, int y)
{
	for (int i=0; i<=9; i++)
	{
		U[i]=u[i];
		V[i]=v[i];
	}
	if (u[x]==0 || v[y]==0) return 0;
	--U[x]; --V[y];
	int ret=1;
	for (int i=0; i<=9; i++)
		if (U[i]>0 && V[9-i]>0)
		{
			int tmp=min(U[i],V[9-i]);
			ret+=tmp;
			U[i]-=tmp;
			V[i]-=tmp;
		}
	return ret;
}

int main()
{
	cin>>st;
	int n=st.size();
	memset(u,0,sizeof(u));
	for (int i=0; i<n; i++)
		++u[st[i]-'0'];
	num1.clear(); num2.clear();

	for (int i=0; i<=9; i++) v[i]=u[i];
	int delta=v[0]-v[9];
	for (int i=1; i<=delta; i++)
	{
		num1.PB(0);
		num2.PB(0);
	}
	if (delta>0)
	{
		u[0]-=delta;
		v[1]-=delta;
	}

	int ret=0,now=1;
	for (int i=1; i<=9; i++)
		if (calc(i,10-i)>ret)
		{
			now=i;
			ret=calc(i,10-i);
		}
	if (ret==0)
	{
		sort(st.begin(),st.end());
		for (int i=n-1; i>=0; i--) cout<<st[i];
		cout<<endl;
		for (int i=n-1; i>=0; i--) cout<<st[i];
		cout<<endl;
	} else
	{
		u[now]--; v[10-now]--;
		num1.PB(now); num2.PB(10-now);
		for (int i=0; i<=9; i++)
			if (u[i]>0 && v[9-i]>0)
			{
				int tmp=min(u[i],v[9-i]);
				for (int j=1; j<=tmp; j++) num1.PB(i);
				for (int j=1; j<=tmp; j++) num2.PB(9-i);
				u[i]-=tmp; v[9-i]-=tmp;
			}
		for (int i=0; i<=9; i++)
		{
			for (int j=1; j<=u[i]; j++) num1.PB(i);
			for (int j=1; j<=v[i]; j++) num2.PB(i);
		}
		for (int i=n-1; i>=0; i--) cout<<num1[i];
		cout<<endl;
		for (int i=n-1; i>=0; i--) cout<<num2[i];
		cout<<endl;
	}
	return 0;
}

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

int main() {
  string s;
  while (cin >> s) {
    int a[10] = {}, b[10] = {};
    rep (d, 10) a[d] = b[d] = count(all(s), '0' + d);

    int best_s = -1, best_l = 0;
    for (int s = 1; s <= 9; ++s) {
      int t = 10 - s;
      --a[s];
      --b[t];

      if (a[s] >= 0 && b[t] >= 0) {
        int l = 1;
        rep (d, 10) l += min(a[d], b[9 - d]);
        if (l > best_l) {
          best_s = s;
          best_l = l;
        }
      }

      ++a[s];
      ++b[t];
    }

    string p(a[0], '0'), q(b[0], '0');
    a[0] = 0;
    b[0] = 0;

    p += '0' + best_s;        --a[best_s];
    q += '0' + (10 - best_s); --b[10 - best_s];

    rep (d, 10) {
      int l = min(a[d], b[9 - d]);
      rep (i, l) {
        p += '0' + d;       --a[d];
        q += '0' + (9 - d); --b[9 - d];
      }
    }

    rep (d, 10) {
      rep (i, a[d]) p += '0' + d;
      rep (i, b[d]) q += '0' + d;
    }

    reverse(all(p));
    reverse(all(q));
    cout << p << endl
         << q << endl;
  }

  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n,tmp,cnt1[10],cnt2[10],dig[10],ans,po;
char s[101000];

int main()
{
  //  freopen("input.txt","r",stdin);

    cin>>s;
    n=strlen(s);
    for (int i=0;i<n;i++) { cnt1[int(s[i])-48]++;cnt2[int(s[i])-48]++; }
    for (int dif=0;dif<=5;dif++)
    {
  		if (cnt1[dif]==0 || cnt2[(10-dif)%10]==0) continue;
        tmp=0;
        cnt1[dif]--;cnt2[(10-dif)%10]--;
        for (int i=0;i<10;i++) tmp+=min(cnt1[i],cnt2[9-i]);
        if (tmp>ans) { ans=tmp;po=dif; }
        cnt1[dif]++;cnt2[(10-dif)%10]++;
    }
    cnt1[po]--;cnt2[(10-po)%10]--;
    for (int i=0;i<10;i++)
		{ tmp=min(cnt1[i],cnt2[9-i]); cnt1[i]-=tmp; cnt2[9-i]-=tmp; dig[i]=tmp; }

    for (int i=9;i>=0;i--) while (cnt1[i]) { cout<<i;cnt1[i]--; }
    for (int i=9;i>=0;i--) for (int j=1;j<=dig[i];j++) cout<<i;
    cout<<po<<endl;
    for (int i=9;i>=0;i--) while (cnt2[i]) { cout<<i;cnt2[i]--; }
    for (int i=0;i<10;i++) for (int j=1;j<=dig[9-i];j++) cout<<i;
    cout<<(10-po)%10<<endl;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <set>
#include <algorithm>
using namespace std;

int cnt1[10];
int cnt2[10];
int cnt[10];
int main()
{
    //freopen("input.txt","r",stdin);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        cnt[s[i]-'0']++;

    int ans = cnt[0];
    string a,b;
    sort(s.begin(),s.end());
    a = s;
    b = s;
    for(int i=1;i<10;i++)
    {
        int cur = 0;
        string ta,tb;
        for(int j=0;j<10;j++)
            cnt1[j] = cnt2[j] = cnt[j];
        if(cnt1[i] && cnt2[10-i])
        {
            for(int j=0;j<min(cnt1[0]-cnt2[9],cnt2[0]-cnt1[9]);j++)
            {
                ta.push_back('0');
                tb.push_back('0');
                cnt1[0]--;
                cnt2[0]--;
                cur++;
            }
            cur = 1;
            cnt1[i]--;
            cnt2[10-i]--;
            ta.push_back('0'+i);
            tb.push_back('0'+10-i);

            for(int j=0;j<=9;j++)
            {
                cur += min(cnt1[j],cnt2[9-j]);
                int d = min(cnt1[j],cnt2[9-j]);
                for(int k=0;k<d;k++)
                {
                    ta.push_back('0'+j);
                    tb.push_back('0'+9-j);
                }
                cnt1[j] -= d;
                cnt2[9-j] -= d;
            }
            for(int j=0;j<10;j++)
                for(int k=0;k<cnt1[j];k++)
                    ta.push_back('0'+j);
            for(int j=0;j<10;j++)
                for(int k=0;k<cnt2[j];k++)
                    tb.push_back('0'+j);
            if(ans < cur)
            {
                ans = cur;
                a = ta;
                b = tb;
            }
        }
    }
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    cout<<a<<endl;
    cout<<b<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int digitsOcc1[10], digitsOcc2[10], arr[10];
    int n, start=-1;
    string num, p1="", p2="";
    cin>>num; n=num.size();
    memset(digitsOcc1,0,sizeof(digitsOcc1));
    for(int i=0;i<n;i++) digitsOcc1[((int)num[i])-48]++;
    memcpy(digitsOcc2,digitsOcc1,sizeof(digitsOcc1));

    for(int i=0;i<10;i++) {
        arr[i]=min(digitsOcc1[i],digitsOcc1[9-i]);
    }

    for(int i=1;i<10;i++){
        if((digitsOcc1[i]-arr[i])&&(digitsOcc1[10-i]-arr[10-i])) {
            start=i; break;
        }
    }

    if(start==-1){
        for(int i=1;i<10;i++){
            if(digitsOcc1[i]&&digitsOcc1[10-i]) {
                arr[i]--; arr[10-i]--;
                arr[i]=max(arr[i],0);
                arr[10-i]=max(arr[10-i],0);
                start=i; break;
            }
        }
    }

    p1+=((char)(start+48)); digitsOcc1[start]--;
    p2+=((char)(10-start+48)); digitsOcc2[10-start]--;

    for(int i=0;i<10;i++){
        digitsOcc1[i]-=arr[i];
        digitsOcc2[9-i]-=arr[i];
        for(int j=0;j<arr[i];j++){
            p1+=((char)(i+48));
            p2+=((char)(9-i+48));
        }
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<digitsOcc1[i];j++){
            p1+=((char)(i+48));
        }
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<digitsOcc2[i];j++){
            p2+=((char)(i+48));
        }
    }

    reverse(p1.begin(),p1.end());
    reverse(p2.begin(),p2.end());
    cout<<p1<<endl;
    cout<<p2<<endl;
    return 0;
}

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string su="0123456789";
int k1[15],k2[15];
int main()
{
	memset(k1,0,sizeof(k1));memset(k2,0,sizeof(k2));
	int ma=-1,mai,i,j,n;string s,out1="",out2="";
	cin>>s;n=s.size();
	rep(i,n){
		if(s[i]>'0'){k1[(s[i]-'0')]++;k2[(s[i]-'0')]++;}
		else{out1+="0";out2+="0";}
	}
	REP(i,1,10){
		if(k1[i]<1 || k2[10-i]<1) continue;
		k1[i]--;k2[10-i]--;
		int t=0;
		REP(j,1,9) t+=min(k1[j],k2[9-j]);
		if(t>ma){ma=t;mai=i;}
		k1[i]++;k2[10-i]++;
	}
	if(ma<0){
//		sort(All(s));reverse(All(s));
		cout<<s<<endl;cout<<s<<endl;
		return 0;
	}
	out1+=su[mai];out2+=su[10-mai];k1[mai]--;k2[10-mai]--;
	rep(i,10){
		int t=min(k1[i],k2[9-i]);
		rep(j,t){
			out1+=su[i];out2+=su[9-i];k1[i]--;k2[9-i]--;
		}
	}
	rep(i,10){
		rep(j,k1[i]) out1+=su[i];
		rep(j,k2[i]) out2+=su[i];
	}
	reverse(All(out1));reverse(All(out2));
	cout<<out1<<endl;cout<<out2<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b)-1; i>=(a); i--)
#define de(x) cout << #x << " => " << x << endl
using namespace std;
typedef double db;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<db, db> pdd;

#define pb push_back
typedef vector<int> vi;

const int N = 1e5 + 7;
char str[N];
int dig[N], n;
int num1[20], num2[20];
//-------
vi ans1, ans2;
int gao(bool sav = false) {
    int ret = 0;
    rep(i, 0, 10) {
        int tmp = min(num1[i], num2[9 - i]);
        ret += tmp;
        if (sav) {
            per(j, 0, tmp) {
                ans1.pb(i);
                ans2.pb(9 - i);
            }
            num1[i] -= tmp;
            num2[9 - i] -= tmp;
        }
    }
    if (sav) {
        rep(i, 1, 10) while(num1[i]--) ans1.pb(i);
        rep(i, 1, 10) while(num2[i]--) ans2.pb(i);
    }
    return ret + num1[0] - min(num1[0], num2[9]);
}

int main() {

    ///read
    scanf(" %s", str); n = strlen(str);
    rep(i, 0, n) dig[i] = str[i] - '0';

    ///prework
    pii mx = {-1, -1};
    rep(i, 0, n) num1[dig[i]]++;
    rep(i, 0, 10) num2[i] = num1[i];
    rep(i, 0, 6) {
        if (!num1[i] || !num2[10 - i]) continue;
        num1[i]--; num2[10 - i]--;
        mx = max(mx, {gao(), i});
        num1[i]++; num2[10 - i]++;
    }

    ///work
    if (~mx.fi) {
        ans1.pb(mx.se), ans2.pb(10 - mx.se);
        num1[mx.se]--;
        num2[10 - mx.se]--;
        gao(true);
        per(i, 0, sz(ans1)) printf("%d", ans1[i]); rep(i, 0, num1[0]) printf("0"); printf("\n");
        per(i, 0, sz(ans2)) printf("%d", ans2[i]); rep(i, 0, num2[0]) printf("0"); printf("\n");
    } else {
        rep(k, 0, 2) {
            per(i, 0, 10) rep(j, 0, num1[i]) printf("%d", i);
            printf("\n");
        }
    }

}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
#define PB push_back
#define INF 999999999
using namespace std;
bool flag;
char n[100001];
int a[20],d[20],b[100001],c[100001];
int i,j,m,len;
int main()
{
	//cin>>n;
	scanf("%s",&n);
	for (i=0;i<strlen(n);i++){
	a[n[i]-'0']++;d[n[i]-'0']++;
	}
	len=strlen(n);
	while (a[0]){
		b[len]=c[len]=0;
		a[0]--;d[0]--;
		len--;
	}
	for (i=1;i<=9;i++)
		if (a[i] && d[10-i])
		{
			b[len]=i;a[i]--;
			c[len]=10-i;d[10-i]--;
			len--;
			break;
		}

	flag=true;
	while (flag){
	flag=false;
		for (i=0;i<=9;i++)
		if (a[i] && d[9-i]){
			b[len]=i;
			c[len]=9-i;a[i]--;d[9-i]--;
			len--;flag=true;
		}
	}
	int p=len;
	for (i=0;i<=9;i++)
	while (a[i]){
		b[len]=i;a[i]--;len--;
	}
	len=p;
	for (i=0;i<=9;i++)
	while (d[i]){
		c[len]=i;d[i]--;len--;
	}
	for (i=1;i<=strlen(n);i++) printf("%d",b[i]);printf("\n");
	for (i=1;i<=strlen(n);i++) printf("%d",c[i]);printf("\n");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

vector<pair<int, pair<char, char> > > counterNine;
vector<int> ind;
map<char, int> counter1, counter2;
map<char, bool> vis;
char ten1, ten2, otherTen1[2], otherTen2[2];
bool is = false, inside[2];

void butAllNine() {
    for (int i = 0; i <= 9; ++i) {
        char num1 = i + '0', num2 = (9 - i) + '0';
        int minNum = min(counter1[num1], counter2[num2]);
        if (minNum != 0) {
            counterNine.push_back(make_pair(minNum, make_pair(num1, num2)));
            counter1[num1] -= minNum, counter2[num2] -= minNum;
            vis[num1] = true, vis[num2] = true;
        }
    }
}

vector<int> get(bool vis1, bool vis2, char num1, char num2, int boo);
void getOneTen() {
    for (int i = 1; i <= 5; ++i) {
        char num1 = i + '0', num2 = (10 - i) + '0';
        if (counter1[num1] != 0 && counter2[num2] != 0) {
            is = true, ten1 = num1, ten2 = num2;
            break;
        }
    }
    if (!is) {
        for (int i = 1; i <= 5; ++i) {
            char num1 = i + '0', num2 = (10 - i) + '0';
            if (counter1[num1] != 0 && vis[num2])
                ind = get(false, true, num1, num2, 0);
            else if (counter2[num2] != 0 && vis[num1])
                ind = get(true, false, num1, num2, 0);
            break;
        }
    }
    if (!is && !inside[0]) {
        for (int i = 1; i <= 5; ++i) {
            char num1 = i + '0', num2 = (10 - i) + '0';
            if (vis[num1] && vis[num2])
                ind = get(true, true, num1, num2, 1);
        }
    }
}

vector<int> get(bool vis1, bool vis2, char num1, char num2, int boo) {
    inside[boo] = true, otherTen1[boo] = num1, otherTen2[boo] = num2;
    vector<int> indRes;
    for (int j = 0; j < int(counterNine.size()); ++j) {
        pair<char, char> temp = counterNine[j].second;
        if ((vis1 && temp.first == num1) || (vis2 && temp.second == num2))
            indRes.push_back(j);
    }
    return indRes;
}

void takeOneNine() {
    for (int j = 0; j <= 1; ++j) {
        if (!is && inside[j]) {
            ten1 = otherTen1[j], ten2 = otherTen2[j], is = true;
            for (int i = 0; i < int(ind.size()); ++i) {
                pair<char, char> temp = counterNine[ind[i]].second;
                counterNine[ind[i]].first--, counter1[temp.first]++, counter2[temp.second]++;
            }
            break;
        }
    }
}

void print() {
    string number1, number2;
    while (counter1['0'] > 0 && counter2['0'] > 0) {
        number1 = '0' + number1, number2 = '0' + number2;
        counter1['0']--, counter2['0']--;
    }
    if (is) {
        counter1[ten1]--, counter2[ten2]--;
        number1 = ten1 + number1, number2 = ten2 + number2;
    }
    for (int i = 0; i < int(counterNine.size()); ++i) {
        while (counterNine[i].first > 0) {
            counterNine[i].first--;
            number1 = counterNine[i].second.first + number1;
            number2 = counterNine[i].second.second + number2;
        }
    }
    for (char i = '0'; i <= '9'; ++i) {
        while (counter1[i] > 0)
            counter1[i]--, number1 = i + number1;
        while (counter2[i] > 0)
            counter2[i]--, number2 = i + number2;
    }
    cout << number1 << endl << number2 << endl;
}

int main() {
//#ifndef ONLINE_JUDGE
    //freopen("test.in", "rt", stdin);
    //freopen( "test.out" , "wt" , stdout );
//#endif
    char arr[100001];
    scanf("%s", arr);
    int size = strlen(arr);
    for (int i = 0; i < size; ++i)
        counter1[arr[i]]++, counter2[arr[i]]++;
    butAllNine(), getOneTen(), takeOneNine(), print();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;;

int a[11], b[11];
vector <pair<int, pair<int, int> > > v;

int ans(int i)
{
	a[i]--;
	b[10 - i]--;
	int sum = 0;
	for(int i = 0; i < 5; i++)
		sum += min(a[i], a[9 - i]),
		sum += min(b[i], b[9 - i]);
	a[i]++;
	b[10 - i]++;
	return sum;
}

int main()
{
	int sefr = 0;
	string s, s1, s2;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		a[s[i] - '0']++;
		b[s[i] - '0']++;
	}
	sefr = a[0];
	a[0] = b[0] = 0;
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
	for(int i = 1; i <= 5; i++)
	{
		v.push_back(make_pair(ans(i), make_pair(i, 10 - i)));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < sefr; i++)
	{
		s1 += '0';
		s2 += '0';
	}
//	cout << "# " << v[4].first << endl;
	s1 += ('0' + v[4].second.first);
	s2 += ('0' + v[4].second.second);
	a[v[4].second.first]--, b[v[4].second.second]--;
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
//	cout << s1 << " " << s2 << endl;

	for(int i = 0; i < 10; i++)
	{
		int g = min(a[i], b[9 - i]);
		for(int j = 0; j < g; j++)
		{
			s1 += ('0' + i);
			s2 += ('0' + 9 - i);
		}
		a[i] -= g, b[9 - i] -= g;
//		cout << i << " " << s1 << " | " << s2 << endl;
	}

	/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
	*/

	for(int i = 0; i < 10; i++)
	{
		for(int j = 0; j < a[i]; j++)
			s1 += ('0' + i);
		for(int j = 0; j < b[i]; j++)
			s2 += ('0' + i);
	}
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	cout << s1 << endl << s2 << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;;

int a[11], b[11];
vector <pair<int, pair<int, int> > > v;

int ans(int i)
{
	if (a[i] <= 0 || b[10 - i] <= 0)
		return 0;
	a[i]--;
	b[10 - i]--;
	int sum = 1;
	for(int i = 0; i < 5; i++)
		sum += min(a[i], a[9 - i]),
		sum += min(b[i], b[9 - i]);
	a[i]++;
	b[10 - i]++;
	return sum;
}

int main()
{
	int sefr = 0;
	string s, s1, s2;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		a[s[i] - '0']++;
		b[s[i] - '0']++;
	}
	sefr = a[0];
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
	for(int i = 1; i <= 5; i++)
	{
		v.push_back(make_pair(ans(i), make_pair(i, 10 - i)));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < sefr - a[9]; i++)
	{
		s1 += '0';
		s2 += '0';
	}
//	cout << "# " << v[4].first << endl;
	if (v[4].first > 0)
	{
		s1 += ('0' + v[4].second.first);
		s2 += ('0' + v[4].second.second);
		a[v[4].second.first]--, b[v[4].second.second]--;
	}
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
//	cout << s1 << " " << s2 << endl;

	for(int i = 0; i < 10; i++)
	{
		int g = min(a[i], b[9 - i]);
		for(int j = 0; j < g; j++)
		{
			s1 += ('0' + i);
			s2 += ('0' + 9 - i);
		}
		a[i] -= g, b[9 - i] -= g;
//		cout << i << " " << s1 << " | " << s2 << endl;
	}

	/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
	*/

	for(int i = 1; i < 10; i++)
	{
		for(int j = 0; j < a[i]; j++)
			s1 += ('0' + i);
		for(int j = 0; j < b[i]; j++)
			s2 += ('0' + i);
	}
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	cout << s1 << endl << s2 << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

char s[123456];
int freq[10], a[10], b[10];
int p[10];
vector<pair<int, int> > ans, ten;

int main() {
  int n = 0;
  scanf("%s", s);
  for(n = 0; s[n]; ++n) ++a[s[n] - '0'];
  for(int i = 0; i < 10; ++i) freq[i] = (b[i] = a[i]) << 1;
  for(int i = 0; i < 10; ++i) {
    int m = min(freq[i], freq[9 - i]);
    p[i] = m;
    freq[i] -= m; freq[9 - i] -= m;
  }
  while(freq[0]) {
    ans.push_back(make_pair(0, 0));
    freq[0] -= 2;
  }
  bool carry = 0;
  for(int i = 1; i < 10; ++i) if(freq[i] && freq[10 - i] > (i == 10 - i)) {
    carry = 1;
    ans.push_back(make_pair(i, 10 - i));
    freq[i]--; freq[10 - i]--;
    break;
  }
  if(!carry) {
    for(int i = 1; i < 10; ++i) if(freq[i] && p[10 - i]) {
      carry = 1;
      ans.push_back(make_pair(i, 10 - i));
      freq[i]--;
      freq[i - 1]++;
      p[10 - i]--;
      break;
    }else if(freq[10 - i] && p[i]) {
      carry = 1;
      ans.push_back(make_pair(i, 10 - i));
      freq[9 - i]++;
      freq[10 - i]--;
      p[i]--;
      break;
    }
  }
  if(!carry) {
    freq[9] += p[0];
    while(p[0]) {
      ans.push_back(make_pair(0, 0));
      p[0] -= 2;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(p[i]) {
      ans.push_back(make_pair(i, 9 - i));
      p[i]--;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(freq[i] && freq[10 - i] > (i == 10 - i)) {
      ten.push_back(make_pair(i, 10 - i));
      freq[i]--; freq[10 - i]--;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(freq[i] > 1) {
      ans.push_back(make_pair(i, i));
      freq[i] -= 2;
      if(i + i < 10 && ten.size()) {
        ans.push_back(ten.front());
        ten.pop_back();
      }
    }
  }
  for(int i = 0; i < 10; ++i) if(freq[i])
    for(int j = i + 1; j < 10; ++j) if(freq[j]) {
      ans.push_back(make_pair(i, j));
      freq[i]--; freq[j]--;
      if(i + j < 10 && ten.size()) {
        ans.push_back(ten.front());
        ten.pop_back();
      }
    }
  ans.insert(ans.end(), ten.begin(), ten.end());
  assert(n == (int)ans.size());
  for(auto &item : ans) {
    if(!a[item.first]) swap(item.first, item.second);
    if(!b[item.second]) swap(item.first, item.second);
    a[item.first]--;
    b[item.second]--;
  }
  for(auto &item : ans) {
    if(item.first == item.second) continue;
    if(a[item.first] > 0 && b[item.first] < 0) {
      a[item.first]--; b[item.first]++;
      a[item.second]++; b[item.second]--;
      swap(item.first, item.second);
    }else if(a[item.first] < 0 && b[item.first] > 0) {
      a[item.first]++; b[item.first]--;
      a[item.second]--; b[item.second]++;
      swap(item.first, item.second);
    }
  }
  string p1, p2;
  for(auto item : ans) {
    p1 += char('0' + item.first);
    p2 += char('0' + item.second);
  }
  reverse(p1.begin(), p1.end());
  reverse(p2.begin(), p2.end());
  puts(p1.c_str());
  puts(p2.c_str());
  return 0;
}

int DBG = 0;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#define sz(a) int(a.size())
using namespace std;

const int oo = 1000000000;
const int N = 0;

string s;
int cnt1[10], cnt2[10];

int compute(int f1, int f2) {
	cnt1[f1]--, cnt2[f2]--;
	if (cnt1[f1] < 0 || cnt2[f2] < 0) {
		cnt1[f1]++, cnt2[f2]++;
		return -1;
	}

	int ret = 1;
	for (int i = 1; i <= 8; ++i)
		ret += min(cnt1[i], cnt2[9-i]);

	cnt1[f1]++, cnt2[f2]++;
	return ret;
}

int main() {
	//read input
	cin >> s;

	for (int i = 0; i < sz(s); ++i) {
		cnt1[int(s[i]) - int('0')]++;
		cnt2[int(s[i]) - int('0')]++;
	}

	//do
	int res = 0, bestFirstNum = 0;
	for (int firstNum = 1; firstNum <= 5; ++firstNum) {
		int temp = compute(firstNum, 10 - firstNum);
		if (temp > res) {
			res = temp;
			bestFirstNum = firstNum;
		}
	}

	//***************************************
	//debug array cnt1
	DBG && cerr << "cnt1 = ";
	if (DBG) for (int debugit = 0; debugit <= 9; ++debugit)
		cerr << cnt1[debugit] << ',';
	DBG && cerr << endl;
	//***************************************
	//***************************************

	//***************************************
	//debug bestFirstNum
	DBG && cerr << "bestFirstNum = " << bestFirstNum << endl;
	//***************************************
	//***************************************

	//get result
	DBG && cout << res + cnt1[0] << endl;

	string s1, s2;
	s1.append(cnt1[0], '0');
	s2.append(cnt1[0], '0');

	if (bestFirstNum > 0) {
		s1.push_back(bestFirstNum + '0'), s2.push_back(10 - bestFirstNum + '0');
		cnt1[bestFirstNum]--;
		cnt2[10 - bestFirstNum]--;
	}
	if (res > 0)
		for (int i = 1; i <= 8; ++i) {
			int temp = min(cnt1[i], cnt2[9-i]);
			s1.append(temp, i + '0');
			s2.append(temp, 9 - i + '0');
			cnt1[i] -= temp;
			cnt2[9-i] -= temp;
		}

	for (int i = 1; i <= 9; ++i)
		s1.append(cnt1[i], i + '0'), s2.append(cnt2[i], i + '0');

	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	cout << s1 << '\n';
	cout << s2 << '\n';
	return 0;
}

#include <bits/stdc++.h>

using namespace std;;

#define int long long

long long a[11], b[11];
vector <pair<long long, pair<long long, long long> > > v;

int ans(int i)
{
	if (a[i] <= 0 || b[10 - i] <= 0)
		return 0;
	a[i]--;
	b[10 - i]--;
	long long sum = 1;
	for(int i = 0; i < 5; i++)
		sum += min(a[i], b[9 - i]),
		sum += min(b[i], a[9 - i]);
	a[i]++;
	b[10 - i]++;
	return sum;
}

main()
{
	int sefr = 0;
	string s, s1, s2;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		a[s[i] - '0']++;
		b[s[i] - '0']++;
	}
	sefr = a[0];
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
	for(int i = 1; i <= 5; i++)
	{
		v.push_back(make_pair(ans(i), make_pair(i, 10 - i)));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < sefr - a[9]; i++)
	{
		s1 += '0';
		s2 += '0';
	}
//	cout << "# " << v[4].first << endl;
	if (v[4].first > 0)
	{
		s1 += ('0' + v[4].second.first);
		s2 += ('0' + v[4].second.second);
		a[v[4].second.first]--, b[v[4].second.second]--;
	}
/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
*/
//	cout << s1 << " " << s2 << endl;

	for(int i = 0; i < 10; i++)
	{
		int g = min(a[i], b[9 - i]);
		for(int j = 0; j < g; j++)
		{
			s1 += ('0' + i);
			s2 += ('0' + 9 - i);
		}
		a[i] -= g, b[9 - i] -= g;
//		cout << i << " " << s1 << " | " << s2 << endl;
	}

	/*
	for(int r:a)
		cout << r << " ";
	cout << endl;

	for(int r:b)
		cout << r << " ";
	cout << endl;
	*/

	for(int i = 1; i < 10; i++)
	{
		for(int j = 0; j < a[i]; j++)
			s1 += ('0' + i);
		for(int j = 0; j < b[i]; j++)
			s2 += ('0' + i);
	}
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	if (s1.length() != s.length() || s2.length() != s.length())
	{
		cout << s.length() << " " << s1.length() << " " << s2.length() << endl;
	}
	cout << s1 << endl << s2 << endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define pb push_back
const int maxi=1e6+10;
string s;
int cnt[20], cur1[20],cur2[20];
int curAns;
string curFirst, curSecond, bestFirst, bestSecond;

void again()
{
    for (int i=1; i<10; i++)
    {
        cur1[i]=cnt[i];
        cur2[i]=cnt[i];
    }

    curFirst = "";
    curSecond = "";
    for (int i=0;i<cnt[0];i++)
    {
        curFirst+='0';
        curSecond+='0';
    }
    return ;
}

void solve(int carry, int ostalo)
{
    if (!ostalo)
        return;

    if (carry==1)
    {
        for (int i=0; i<=9; i++)
            if (cur1[i] && cur2[9-i])
            {
                cur1[i]--;
                curFirst+='0'+i;
                cur2[9-i]--;
                curSecond+='0'+(9-i);
                curAns++;
                solve(1,ostalo-1);
                return;
            }

        int nasaoFirst = -1;
        int nasaoSecond = -1;
        for (int i=0; i<=9; i++)
        {
            if (cur1[i] && nasaoFirst == -1)
                nasaoFirst =i;
        }

        for (int i=9;i>=0;i--)
            if (cur2[i] && nasaoSecond == -1 && nasaoFirst+i+1<10)
        {
              nasaoSecond = i;
        }

         for (int i=9;i>=0;i--)
            if (cur2[i] && nasaoSecond == -1 )
                 nasaoSecond = i;

        cur1[nasaoFirst]--;
        cur2[nasaoSecond]--;

        curFirst += ('0' +nasaoFirst);
        curSecond+= ('0' +nasaoSecond);

        int car = 0 ;
        if (nasaoFirst+nasaoSecond>9)
            car = 1;

        solve(car, ostalo-1);

        return;
    }

    for (int i=0; i<=9; i++)
        if (cur1[i] && cur2[(10-i)%10])
        {
            cur1[i]--;
            curFirst+='0'+i;
            cur2[(10-i)%10]--;
            curSecond+=('0' + ((10-i)%10));
            curAns++;
            solve(1,ostalo-1);
            return;
        }

    int nasaoFirst = -1;
    int nasaoSecond = -1;
    for (int i=0; i<=9; i++)
    {
        if (cur1[i])
            nasaoFirst =i;
        if (cur2[i])
            nasaoSecond = i;
    }

    cur1[nasaoFirst]--;
    cur2[nasaoSecond]--;

    curFirst += '0' +nasaoFirst;
    curSecond+= '0' +nasaoSecond;

    int car = 0 ;
    if (nasaoFirst+nasaoSecond>9)
        car = 1;

    solve(car, ostalo-1);
}
int main()
{
    cin>>s;

    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());

    int n=s.size();

    for (int i=0; i<n; i++)
        cnt[s[i]-'0']++;

    int best = 0;

    for (int i=0; i<=9; i++)
    {
        again();
        int fir = i;
        int sec = (10-i)%10;

        if (cur1[fir] && cur2[sec])
        {
            cur1[fir]--;
            cur2[sec]--;
            curAns = 1;
            curFirst += '0'+fir;
            curSecond += '0'+sec;

            if (i)
                solve(1, n-1);
            else
                solve(0,n-1);

            if (curAns>best)
            {
                best = curAns;
                reverse(curFirst.begin(),curFirst.end());
                reverse(curSecond.begin(),curSecond.end());
                bestFirst = curFirst;
                bestSecond = curSecond;
            }
        }
    }

    if (best==0)
    {
        cout<<s<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<bestFirst<<endl;
        cout<<bestSecond<<endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int digitsOcc1[10], digitsOcc2[10], arr[10];
    int n, start1=-1, start2=-1;
    int index1=0, index2=0;
    bool flag1=false, flag2=false;
    string num, p1="", p2="";
    cin>>num; n=num.size();
    memset(digitsOcc1,0,sizeof(digitsOcc1));
    for(int i=0;i<n;i++) digitsOcc1[((int)num[i])-48]++;
    memcpy(digitsOcc2,digitsOcc1,sizeof(digitsOcc1));

    for(int i=0;i<10;i++) {
        arr[i]=min(digitsOcc1[i],digitsOcc1[9-i]);
    }

    for(int i=1;i<6;i++){
        if((digitsOcc1[i]-arr[i])&&(digitsOcc1[10-i]-arr[10-i])) {
            flag1=flag2=true; start1=i; start2=10-i; break;
        }
    }

    if(start1==-1){
        for(int i=1;i<6;i++){
            if(digitsOcc1[i]&&digitsOcc1[10-i]) {
                start1=i; start2=10-i;
                flag1=(digitsOcc1[i]-arr[i]);
                flag2=(digitsOcc1[i]-arr[10-i]);
                if(flag1||flag2) break;
            }
        }
    }

    for(int j=0;j<digitsOcc1[0]-arr[0];j++){
        p1+=((char)(48));
    }

    for(int j=0;j<digitsOcc2[0]-arr[9];j++){
        p2+=((char)(48));
    }

    index1=p1.size();

    for(int i=0;i<10;i++){
        digitsOcc1[i]-=arr[i];
        digitsOcc2[9-i]-=arr[i];
        for(int j=0;j<arr[i];j++){
            p1+=((char)(i+48));
            p2+=((char)(9-i+48));
        }
    }

    index2=p1.size();

    for(int i=1;i<10;i++){
        for(int j=0;j<digitsOcc1[i];j++){
            p1+=((char)(i+48));
        }
    }

    for(int i=1;i<10;i++){
        for(int j=0;j<digitsOcc2[i];j++){
            p2+=((char)(i+48));
        }
    }

    if(start1!=-1){
        if(flag1&&flag2){
            int start1Index = p1.rfind((char)(start1+48));
            int start2Index = p2.rfind((char)(start2+48));
            p1.erase(start1Index,1);
            p2.erase(start2Index,1);
            p1.insert(p1.begin()+index1,(char)(start1+48));
            p2.insert(p2.begin()+index1,(char)(start2+48));
        }
        else if(flag1){
            int start1Index = p1.rfind((char)(start1+48));
            int start2Index = p2.find((char)(start2+48));
            swap(p1[start1Index],p1[start2Index]);
            p1.erase(start2Index,1);
            p2.erase(start2Index,1);
            p1.insert(p1.begin()+index1,(char)(start1+48));
            p2.insert(p2.begin()+index1,(char)(start2+48));
        }
        else if(flag2){
            int start1Index = p1.find((char)(start1+48));
            int start2Index = p2.rfind((char)(start2+48));
            swap(p2[start1Index],p2[start2Index]);
            p1.erase(start1Index,1);
            p2.erase(start1Index,1);
            p1.insert(p1.begin()+index1,(char)(start1+48));
            p2.insert(p2.begin()+index1,(char)(start2+48));
        }
        else{
            int start1Index = p1.find((char)(start1+48));
            int start2Index = p2.find((char)(start2+48));
            swap(p1[start1Index],p1[start2Index]);
            p1.erase(start2Index,1);
            p2.erase(start2Index,1);
            p1.insert(p1.begin()+index1,(char)(start1+48));
            p2.insert(p2.begin()+index1,(char)(start2+48));
            char temp1=p1[start1Index];
            char temp2=p2[start1Index];
            p1.erase(start1Index,1);
            p2.erase(start1Index,1);
            p1+=temp1;
            p2+=temp2;
        }
    }

    reverse(p1.begin(),p1.end());
    reverse(p2.begin(),p2.end());
    cout<<p1<<endl;
    cout<<p2<<endl;
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define P(n) printf("%lld",n)
#define S(n) scanf("%lld",&n)
#define Pl() printf("\n")
using namespace std;

int main()
{
    string s;
    cin>>s;
    map<char,ll>m2;
    map<char,ll>m1;
    string a1 = "",a2 = "";
    for(ll i = 0;i < s.length(); i++){
        char c = s[i];
        m1[c]++;
        m2[c]++;
    }
    map<char,ll>::iterator it1 = m1.begin();
    map<char,ll>::iterator it2 = m2.begin();
    bool f = false;
    for(it1 = m1.begin() ; it1 != m1.end(); it1++){
        if(it1->second <= 0)continue;
        for(it2 = m2.begin() ; it2 != m2.end(); it2++){
            if(it2->second <= 0)continue;
            if(it1->second <= 0)continue;
        //cout<<it1->first<<" "<<it2->first<<"\n";
            if(!f){
                ll a = it1->first - '0';
                ll b = it2->first - '0';

                if(a+b == 10){
                   //     cout<<"trueeee\n";
                    f = true;
                    a1 = it1->first + a1;
                    a2 = it2->first + a2;
                    m1[it1->first]--;
                    m2[it2->first]--;
                    it1 = m1.begin();
                    it2 = m2.begin();

                }
            }else{
                //cout<<"false"<<"\n";
                ll a = it1->first - '0';
                ll b = it2->first - '0';
                if(a+b == 9){
                    a1 = it1->first + a1;
                    a2 = it2->first + a2;
                    m1[it1->first]--;
                    m2[it2->first]--;
                    it1 = m1.begin();
                    it2 = m2.begin();
                }
            }
        }
    }
    it1 = m1.begin();
    for( ; it1 != m1.end(); it1++){
        if(it1->second <= 0)continue;
        while(it1->second > 0){
            a1 = it1->first + a1;
            m1[it1->first]--;
        }
    }
    it2 = m2.begin();
    for( ; it2 != m2.end(); it2++){
        if(it2->second <= 0)continue;
        while(it2->second > 0){
            a2 = it2->first + a2;
            m2[it2->first]--;
        }
    }
    cout<<a1<<"\n";
    cout<<a2<<"\n";
    return 0;

}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <ctime>

using namespace std;

char str[100005],a[100005],b[100005];

int main() {
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    gets(str);
    int cnt[10]={0},n=strlen(str);
    for(int i=0;i<n;i++)
        cnt[str[i]-'0']++;
    int mx=0,ii=1;
    for(int i=1;i<10;i++)
    {
        int cur=0,cnt1[10]={0},cnt2[10]={0};
        for(int j=0;j<10;j++) cnt2[j]=cnt1[j]=cnt[j];
        if (!cnt1[i]||!cnt2[10-i]) continue;
        cnt1[i]--,cnt2[10-i]--; cur=1;
        for(int j=1;j<9;j++)
            cur+=min(cnt1[j],cnt2[9-j]);
        if (cur>mx) mx=cur,ii=i;
    }
    if (ii!=-1)
    {
        int cur=0,cnt1[10]={0},cnt2[10]={0},ind=n-1;
        for(int j=0;j<10;j++) cnt2[j]=cnt1[j]=cnt[j];
        while(cnt1[0])
        {
            a[ind]=b[ind]='0'; ind--;
            cnt1[0]--; cnt2[0]--;
        }
        if (cnt1[ii]&&cnt2[10-ii])
        {
            a[ind]=ii+'0'; b[ind]=(10-ii)+'0'; ind--;
            cnt1[ii]--,cnt2[10-ii]--;
        }
        for(int j=1;j<9;j++)
        {
            int k=min(cnt1[j],cnt2[9-j]);
            for(int i=0;i<k;i++)
            {
                a[ind]=j+'0'; b[ind]=9-j+'0'; ind--;
                cnt1[j]--; cnt2[9-j]--;
            }
        }
        int ind1=ind;
        for(int i=1;i<10;i++)
            while(cnt1[i])
            {
                a[ind]=i+'0'; ind--; cnt1[i]--;
            }
        ind=ind1;
        for(int i=1;i<10;i++)
            while(cnt2[i])
            {
                b[ind]=i+'0'; ind--; cnt2[i]--;
            }
        puts(a); puts(b);
    }
    return 0;
}

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

inline int RD(){ int x; RD(x); return x;}
template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline void RC(char &c){scanf(" %c", &c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 0x7fffffff;
const DB PI = acos(-1.0);
const DB EPS = 1e-6;
const DB OO = 1e15;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,

inline bool _1(int x, int i){return x & 1<<i;}
inline int _1(int i){return 1<<i;}
inline int _U(int i){return _1(i) - 1;};

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

int ____Case;
template<class T> inline void OT(const T &x){
    //cout << x << endl;
    printf("%d\n", x);
    //printf("%.2lf\n", x);
    //printf("Case %d: %d\n", ++____Case, x);
}

#define For_each(it, A) for (SII::iterator it = A.begin(); it != A.end(); ++it)

/* .................................................................................................................................. */

int a[10], b[10]; string s;
int r, rr, x, y, xx, yy, zero;

void calc(int x){
    int y = 10 - x; if (!a[x] || !a[y]) return;
    int r = 0; REP(i, 10) rr += min(a[i] - i == x, a[9-i] - i == y);
    if (r > rr) rr = r, xx = x, yy = y;
}

int main(){

    //freopen("in.txt", "r", stdin);

    cin >> s; REP(i, SZ(s)) ++a[s[i] - '0'];

    r = -1; FOR_1(i, 0, a[0]){
        a[0] -= i, rr = -1, calc(1), calc(2), calc(3), calc(4), calc(5);
        if (rr + i > r) r = rr + i, zero = i, x = xx, y = yy;
        a[0] += i;
    }

    if (!x) --zero; a[0] -= zero, CPY(b, a), --a[x], --b[y];

    REP(i, 10) REP(j, a[i] - min(a[i], b[9-i])) printf("%d", i);
    REP(i, 10) REP(j, min(a[i], b[9-i])) printf("%d", i);
    printf("%d", x); REP(i, zero) putchar('0'); puts("");

    REP(i, 10) REP(j, b[9-i] - min(a[i], b[9-i])) printf("%d", 9-i);
    REP(i, 10) REP(j, min(a[i], b[9-i])) printf("%d", 9-i);
    printf("%d", y); REP(i, zero) putchar('0'); puts("");
}

#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define MAXN 2222
#define MAXM 222222
#define INF 1000000000
using namespace std;
int a[111111];
char s[111111];
int num1[11], num2[11];
char s1[111111], s2[111111];
int tmp1[11], tmp2[11];
bool ok()
{
    for(int i = 1; i < 10; i++)
        if(num1[i] && num2[10 - i]) return true;
    return false;
}
int main()
{
    scanf("%s", s);
    int len = strlen(s);
    reverse(s, s + len);
    for(int i = 0; i < len; i++)
    {
        a[i] = s[i] - '0';
        num1[a[i]] ++;
        num2[a[i]]++;
    }
    if(ok())
    {
        int x ;
        for(int i = 1; i < 10; i++)
            if(num1[i] && num2[10 - i])
            {
                num1[i]--;
                num2[10 - i]--;
                x = i;
                break;
            }
        int cnt1 = 0, cnt2 = 0;
        int jiu1 = min(num1[0], num2[9]);
        num1[0] -= jiu1;
        num2[9] -= jiu1;
        int jiu2 = min(num1[9], num2[0]);
        num1[9] -= jiu2;
        num2[0] -= jiu2;
        int tp = min(num1[0], num2[0]);
        for(int i = 0; i < tp; i++) s1[cnt1++] = '0',s2[cnt2++] = '0';
        num1[0] -= tp;
        num2[0] -= tp;
        s1[cnt1++] = '0' + x;
        s2[cnt2++] = '0' + 10 - x;
        for(int i = 0; i < jiu1; i++)
        {
            s1[cnt1++] = '0';
            s2[cnt2++] = '9';
        }
        for(int i = 0; i < jiu2; i++)
        {
            s1[cnt1++] = '9';
            s2[cnt2++] = '0';
        }
        for(int i = 1; i < 10; i++)
        {
            if(num1[i] && num2[9 - i])
            {
                int t = min(num1[i], num2[9 - i]);
                while(t--)
                {
                    s1[cnt1++] = '0' + i;
                    num1[i]--;
                    num2[9 - i]--;
                    s2[cnt2++] = '0' + 9 - i;
                }
            }
        }
        for(int i = 1; i < 10; i++)
        {
            int t1 = num1[i];
            int t2 = num2[i];
            while(t1--)
            {
                s1[cnt1++] = i + '0';
            }
            while(t2--)
            {
                s2[cnt2++] = i + '0';
            }
        }
        s1[cnt1] = '\0';
        s2[cnt2] = '\0';
        reverse(s1, s1 + cnt1);
        reverse(s2, s2 + cnt2);
        puts(s1);
        puts(s2);
        return 0;
    }
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < num1[0]; i++)
    {
        s1[cnt1++] = '0';
        s2[cnt2++] = '0';
    }
    for(int i = 1; i < 10; i++)
        {
            int t1 = num1[i];
            int t2 = num2[i];
            while(t1--)
            {
                s1[cnt1++] = i + '0';
            }
            while(t2--)
            {
                s2[cnt2++] = i + '0';
            }
        }
    s1[cnt1] = '\0';
    s2[cnt2] = '\0';
    reverse(s1, s1 + cnt1);
    reverse(s2, s2 + cnt2);
    puts(s1);
    puts(s2);
    return 0;
}

/*ptmllfkkoncrinobhdmbiqpftlcjrgcefohjljlfofpctjpseh*/

/// *********************************************** K
/// B *                                           * H
/// I *    Solved By : Bir Bahadur Khatri(B'ru)   * A
/// R *      Be Positive,be Happy.                * T
/// U *                                           * R
/// *********************************************** I

#include<bits/stdc++.h>

#define LL long long int
#define ULL unsigned LL
#define PI 2.0*acos(0.0)
#define D double
#define sz size()
#define PB push_back
#define cp printf("***** here here here here *****\n");
#define NL printf("\n")
#define CHR getchar()
#define SQR(n) (n*n)
#define xx first
#define yy second
#define MEM(a,val) memset(a,val,sizeof(a))
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define S1(a) a=in<int>()
#define S2(a,b) a=in<int>(),b=in<int>()
#define S3(a,b,c) a=in<int>(),b=in<int>(),c=in<int>()
#define SL1(a) a=in<LL>()
#define SL2(a,b) a=in<LL>(),b=in<LL>()
#define SL3(a,b,c) a=in<LL>(),b=in<LL>(),c=in<LL>()
#define F(i,a,b) for(int i=a;i<b; i++)
#define R(i,a,b) for(int i=a-1;i>=b; i--)
#define all(a) a.begin(),a.end()
#define BitCnt(a) __builtin_popcountll(a)
#define InpOut freopen("A.in","r",stdin),freopen("A1.out","w",stdout)
#include <time.h>

using namespace std;
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T Dist(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template<typename T>inline T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
long long Bigmod(long long base, long long power, long long MOD){long long ret=1;while(power){if(power & 1)ret=(ret*base)%MOD;base=(base*base)%MOD;power>>=1;}return ret;}
long long ModInverse(long long number, long long MOD){return Bigmod(number, MOD-2, MOD);}
int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Chkbit(int N,int pos){return (bool)(N & (1<<pos));}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
long long int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}

///**********************************************************//

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<28)
/// ==========================================////

int a[12],b[12],c[12],d[12];

int Solve()
{
    int ans=1;
    for(int i=0;i<=4;i++) {
        int tp=9-i;
       //cout<<i<< " "<<tp<< " "<<b[i]<< " . "<<d[tp]<<endl;
        while(b[i]&&d[tp]) {
            ans++,b[i]--,d[tp]--;
            //cout<<i<< " ** "<<tp<<endl;
        }
    }
//    cout<<ans<<endl;
    return ans;
}

int cnt;

void Prnt(int l,int r)
{
//    cout<<Cl<< " "<<r<<endl;
    string A,B;
    while(cnt--) {
        A+='0'; B+='0';
    }
    A+=(l+'0'),B+=(r+'0');
    for(int i=0;i<=4;i++) {
        int tp=9-i;
//        cout<<i<< " "<<tp<< " "<<b[i]<< " . "<<d[tp]<<endl;
        while(b[i]&&d[tp]) {
            b[i]--,d[tp]--;
//            cout<<i<< " , "<<tp<<endl;
            A+=(i+'0'),B+=(tp+'0');
        }
    }
//    cout<<A<< " "<<B<<endl;

    for(int i=0;i<10;i++) {
        while(b[i]--) {
            A+=(i+'0');
        }
    }

    for(int i=0;i<10;i++) {
        while(d[i]--) {
            B+=(i+'0');
        }
    }
    reverse(all(A));
    reverse(all(B));
    cout<<A<<endl;
    cout<<B<<endl;
    return;
}

int main()
{
    string s;
    cin>>s;

    F(i,0,s.sz) {
        a[ s[i]-'0' ]++;
    }
    for(int i=0;i<10;i++) c[i]=a[i];
//    F(i,0,10) cout<<c[i]<< " "; NL;

    cnt=(a[0]);
    a[0]=c[0]=0;
    vector<int> v;
    int ans=-1;
    for(int i=1;i<=5;i++) {
        int tp=10-i;
        for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
        //cout<<i<< " "<<tp<< " "<<b[i]<< " "<<d[tp]<<endl;
        if(b[i]&&d[tp]) {
            b[i]--;
            d[tp]--;
            ans=max(ans,Solve());
        }
    }
//    F(i,0,10) cout<<a[i]<< " "; NL;

    for(int i=1;i<=5;i++) {
        int tp=10-i;
        for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
        if(b[i]&&d[tp]) {
            b[i]--;
            d[tp]--;
            if(ans==Solve()) {
                for(int j=0;j<10;j++) b[j]=a[j],d[j]=c[j];
                b[i]--;
                d[tp]--;
                Prnt(i,tp); return 0;
            }
        }
    }

    return 0;
}

///============= Thank You ===================///

#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define N 200000
char a[ N ], b[ N ];
int ia[ 10 ], ib[ 10 ];
char linha[ N ];

int main(){
	scanf( "%s", linha );
	memset( ia, 0, sizeof ia );
	memset( ib, 0, sizeof ib );

	for( int i = 0; linha[i]; ++i ){
		++ia[ linha[i] - '0' ];
		++ib[ linha[i] - '0' ];
	}

	int maior = 0, index = 1;
	for( int i = 1; i < 10; ++i ){
		if( min( ia[ i ], ib[ 10 - i ] ) > 0 ){
			int tmp = 1;
			--ia[ i ];
			--ib[ 10 - i ];

			for( int j = 0; j <= 9; ++j ){
				int qtd = min( ia[ j ], ib[ 9 - j ] ) ;
				if( qtd > 0 ) tmp += qtd;
			}
			if( tmp > maior ){
				maior = tmp;
				index = i;
			}
			++ia[ i ];
			++ib[ 10 - i ];
		}
	}

	for( int i = 1; i < 10; ++i ){
		if( min( ia[ i ], ib[ 10 - i ] ) > 0 ){
			int tmp = 1 + ia[ 0 ];
			--ia[ i ];
			--ib[ 10 - i ];

			for( int j = 1; j < 9; ++j ){
				int qtd = min( ia[ j ], ib[ 9 - j ] ) ;
				if( qtd > 0 ) tmp += qtd;
			}
			if( tmp > maior ){
				maior = tmp;
				index = -i;
			}
			++ia[ i ];
			++ib[ 10 - i ];
		}
	}

	if( !maior ){
		int prt = strlen( linha ) - 1;
		for( int i = 0; i < 10; ++i ){
			while( ia[ i ] ){
				linha[ prt-- ] = i + '0';
				--ia[ i ];
			}
		}

		printf( "%s\n%s\n", linha, linha );
	}else{
		int prt = 0;
		if( index < 0 ){
			index = -index;
			while( ia[ 0 ] ){
				a[ prt ] = '0';
				b[ prt++ ] = '0';
				--ia[ 0 ];
				--ib[ 0 ];
			}
		}
		a[ prt ] = index + '0';
		b[ prt ] = 10 - index + '0';
		--ia[ index ];
		--ib[ 10 - index ];
		++prt;

		for( int i = 1; i < 10; ++i ){
			int qtd = min( ia[ i ], ib[ 9 - i ] );
			if( qtd > 0 ){
				for( int j = 0; j < qtd; ++j ){
					a[ prt ] = i + '0';
					b[ prt++ ] = 9 - i + '0';
				}
				ia[ i ] -= qtd;
				ib[ 9 - i ] -= qtd;
			}
		}

		int pa = prt, pb = prt;
		for( int i = 1; i < 10; ++i ){
			while( ia[ i ] ){
				a[ pa++ ] = i + '0';
				--ia[ i ];
			}

			while( ib[ i ] ){
				b[ pb++ ] = i + '0';
				--ib[ i ];
			}
		}

		while( ia[ 0 ] > ib[ 0 ] ){
			a[ pa++ ] = '0';
			--ia[ 0 ];
		}

		while( ib[ 0 ] > ia[ 0 ] ){
			b[ pb++ ] = '0';
			--ib[ 0 ];
		}
		reverse( a, a + pa );
		reverse( b, b + pb );

		while( ia[ 0 ] && ib[ 0 ] ){
			a[ pa++ ] = b[ pb++ ] = '0';
			--ia[ 0 ];
			--ib[ 0 ];
		}
		a[ pa ] = 0;
		b[ pb ] = 0;
		printf( "%s\n%s\n", a, b );
	}

}

#pragma comment(linker, "/stack:64000000")
#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <memory.h>
#include <vector>
#include <bitset>
#include <string>
#include <deque>
#include <queue>
#include <ctime>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cmath>
using namespace std;

typedef long long li;
typedef long double ld;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb push_back
#define pii pair <int, int>
#define vi vector <int>
#define mp make_pair

template <typename X> inline X abs (const X &a) {return a < 0? -a: a;}
template <typename X> inline X sqr (const X &a) {return a * a;}

const int INF = INT_MAX / 2;
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 100 * 1000 + 13;

int sz1 = 0, sz2 = 0;
int out[2][N];

inline int solve (const vector <int> &cnt1, const vector <int> &cnt2)
{
    int res = 0;
    forn (i, 10)
    {
        if (cnt1[i] > 0 && cnt2[9 - i] > 0)
        {
            res += min (cnt1[i], cnt2[9 - i]);
        }
    }

    return res;
}

inline void print (const vector <int> &cnt1, const vector <int> &cnt2)
{
    forn (i, 10)
    {
        int cur = min (cnt1[i], cnt2[9 - i]);

        forn (j, cnt1[i] - cur)
            out[0][sz1++] = i;

        forn (j, cnt2[9 - i] - cur)
            out[1][sz2++] = 9 - i;
    }

    assert (sz1 == sz2);

    forn (i, 10)
    {
        if (cnt1[i] > 0 && cnt2[9 - i] > 0)
        {
            int cur = min (cnt1[i], cnt2[9 - i]);

            forn (j, cur)
                out[0][sz1++] = i;

            forn (j, cur)
                out[1][sz2++] = 9 - i;
        }
    }

    assert (sz1 == sz2);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    vector <int> cnt (10, 0);
    string s;

    getline (cin, s);

    forn (i, sz (s))
        cnt[s[i] - '0']++;

    int cur = -1;

    vector <int> cnt1 = cnt, cnt2 = cnt;

    int x = -1, y = -1, z = -1;

    bool zero = false;

    int mem = cnt[0];

    for (int k = 0; k <= mem; k++)
    {
        cnt[0] = k;
        cnt1 = cnt2 = cnt;

        if (mem - k > cur)
        {
            z = k;
            x = -1;
            y = -1;
        }

        for (int i = 1; i < 10; i++)
        {
            int j = 10 - i;

            if (cnt1[i] > 0 && cnt2[j] > 0)
            {
                cnt1[i]--;
                cnt2[j]--;

                int res = solve (cnt1, cnt2) + 1;

                if (cur < res + mem - k)
                {
                    x = i;
                    y = j;
                    z = k;
                    cur = res + mem - k;
                }

                cnt1[i]++;
                cnt2[j]++;
            }
        }
    }

    cnt[0] = z;
    cnt1 = cnt2 = cnt;

    if (x != -1)
    {
        cnt1[x]--;
        cnt2[y]--;

        print (cnt1, cnt2);

        out[0][sz1++] = x;
        out[1][sz2++] = y;
    }
    else
    {
        forn (i, 10)
        {
            forn (j, cnt[i])
            {
                out[0][sz1++] = i;
                out[1][sz2++] = i;
            }
        }
    }

    forn (i, mem - z)
    {
        out[0][sz1++] = 0;
        out[1][sz2++] = 0;
    }

    assert (sz1 == sz2 && sz1 == sz (s));

    forn (i, 2)
    {
        forn (j, sz1)
        {
            printf ("%d", out[i][j]);
        }

        puts ("");
    }

    return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100001;
char s1[2][N], s2[2][N];
int k1, k2, f1[10], f2[10];
int  work (int i, int j, int flag)
{
    int m = min (f1[i], f2[j]);
    f1[i] -= m; f2[j] -= m;
    for (int l = 0; l < m; l ++)
    {
        s1[flag][-- k1] = i + '0';
        s2[flag][-- k2] = j + '0';
    }
    return m;
}
int main()
{
    char str[N];
    int i, j, l;
    while (gets (str))
    {
        int f[10] = {}, m = -1, mm, flag = 1;
        for (i = 0; str[i]; i ++) f[str[i] - '0'] ++;
        l = N - i;
        for (i = 1; i <= 9; i ++)
        {
             k1 = k2 = N; mm = 0;
             memcpy (f1, f, sizeof f); memcpy (f2, f, sizeof f);
             if (f1[i] && f2[10 - i])
             {
                 mm ++;
                 s1[flag][-- k1] = i + '0';
                 s2[flag][-- k2] = '0' + 10 - i;
                 f1[i] --; f2[10 - i] --;
                 for (j = 0; j <= 9; j ++) mm += work (j, 9 - j, flag);
             }
             if (f1[0] && f2[0]) mm += work (0, 0, flag);
             if (mm <= m) continue;
             else m = mm;
             for (j = 0; j <= 9; j ++)
             {
                 while (f1[j] --) s1[flag][-- k1] = j + '0';
                 while (f2[j] --) s2[flag][-- k2] = j + '0';
             }
             flag ^= 1;
        }
        flag ^= 1;
        puts (s1[flag] + l); puts (s2[flag] + l);
    }
    return 0;
}

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAX_N = 100010;

int len;
char str[MAX_N];
char num1[MAX_N], num2[MAX_N];
int cnt[10], cnt2[10];

int FindBestDigit() {
  int best_digit = str[0]-'0', max_zeros = 0;
  for (int i = 1; i < 10; ++i) {
    int rest = 10-i;
    if (cnt[i] > 0 && cnt[rest] > 0) {
      --cnt[i];
      int zeros = cnt[0] + 1;
      for (int j = 1; j < 10; ++j) {
           zeros += min(cnt[j], cnt2[9-j]);
      }
      if (zeros > max_zeros) {
        best_digit = i;
        max_zeros = zeros;
      }
      ++cnt[i];
    }
  }

  return best_digit;
}

void BuildSolution(int best_digit) {
  int pos1 = 0, pos2 = 0;
  while (cnt[0] > 0 && cnt2[0] > 0) {
    ++pos1;
    ++pos2;
    --cnt[0];
    --cnt2[0];
    num1[len-pos1] = '0';
    num2[len-pos2] = '0';
  }

  --cnt[best_digit];
  int rest = 10-best_digit;
  if (cnt2[rest] == 0) {
    for (int i = 0; i < 10; ++i) {
      if (cnt2[i] > 0) {
        rest = i;
      }
    }
  }
  ++pos1; ++pos2;
  --cnt2[rest];
  num1[len-pos1] = '0' + best_digit;
  num2[len-pos2] = '0' + rest;

  for (int i = 1; i < 10; ++i) {
    while (cnt[i] > 0 && cnt2[9-i] > 0) {
      ++pos1;
      ++pos2;
      --cnt[i];
      --cnt2[9-i];
      num1[len-pos1] = '0' + i;
      num2[len-pos2] = '0' + 9-i;
    }
  }

  for (int i = 0; i < 10; ++i) {
    while (cnt[i] > 0) {
      --cnt[i];
      ++pos1;
      num1[len-pos1] = '0' + i;
    }
    while (cnt2[i] > 0) {
      --cnt2[i];
      ++pos2;
      num2[len-pos2] = '0' + i;
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE

  freopen("b.in", "r", stdin);
#endif

  fgets(str, MAX_N, stdin);
  len = strlen(str)-1;

  for (int i = 0; i < len; ++i) {
    ++cnt[str[i]-'0'];
    ++cnt2[str[i]-'0'];
  }

  int best_digit = FindBestDigit();
  BuildSolution(best_digit);
  printf("%s\n", num1);
  printf("%s\n", num2);

  return 0;
}

#include<stdio.h>
#include<iostream>
#include<string.h>
#define N 300008
#define inf 100000
using namespace std;
char str[N];
int num[N],ans[N],num2[N],ans2[N];
int main()
{
	int i,len,len1,flag=0,st,en,j;
	scanf("%s",str);
	len=strlen(str);
	memset(num,0,sizeof(num));
	memset(num2,0,sizeof(num2));
	for(i=0;i<len;i++) {num[str[i]-'0']++;num2[str[i]-'0']++;}
	len1=len-1;
	st=en=inf;
	for(i=0;i<=9;i++)
		{
		  while(num[i]&&num2[9-i])
			{
			   ans[en]=i,ans2[en++]=9-i;
			   num[i]--,num2[9-i]--;
			}
		}
//	printf("flag==%d\n",flag);
	for(i=1;i<=9;i++) if(num[i]&&num2[10-i]) {flag=1,ans[en]=i,ans2[en++]=10-i,num[i]--,num2[10-i]--;break;}
	if(flag==0&&st!=en)
	for(i=2;i<=9;i++) for(j=10-i;j<=9;j++) if(num[i]&&num2[j]) {flag=1,ans[en]=i,ans2[en++]=j,num[i]--,num2[j]--;break;}
//	printf("flag==%d\n",flag);
	if(flag==0)
		{
		 if(st!=en) {
			    int  besti=0;
			     for(i=st;i<en;i++) if(ans[i]==5) {besti=i;flag=1;break;}
			     if(flag) {
					num[4]++,num2[4]++;
					besti--;
					for(i=besti;i<en-2;i++) {ans[i]=ans[i+2],ans2[i]=ans2[i+2];}
					en--;
					ans[en-1]=5,ans2[en-1]=5;
				  }
			    else
			     {
			     num[ans[st]]++,num2[ans[st]]++;
			     ans2[en-1]=ans[en-1];
		//	     printf("tm===%d\n",ans[st]);
			    st++;
			   }
			    }
		}
	for(i=1;i<=9;i++) while(num[i]) {printf("%d",i);num[i]--;}
	for(i=st;i<en;i++) printf("%d",ans[i]);
	while(num[0]) {printf("0");num[0]--;}
	printf("\n");
	for(i=1;i<=9;i++) while(num2[i]) {printf("%d",i);num2[i]--;}
	for(i=st;i<en;i++) printf("%d",ans2[i]);
	while(num2[0]) {printf("0");num2[0]--;}
	printf("\n");
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <cassert>
#include <sstream>
//~ #include <unordered_map>
//~ #include <unordered_set>

using namespace std;

#define INF 0x3f3f3f3f
#define ll long long
#define SZ(x) (int)((x).size())

void imprime(vector<int> &v) {
    reverse(v.begin(),v.end());
    for (int i=0; i<SZ(v); i++)
        printf("%d",v[i]);
    printf("\n");
}

char s[100010];

int main() {
    //~ cin.sync_with_stdio(false);
    scanf(" %s",s);
    vector<int> n1,n2;
    int n = strlen(s);
    int cnt1[10] = {0}, cnt2[10] = {0}, v[10] = {0};

    for (int i=0; i<n; i++)
        cnt1[s[i]-'0']++, cnt2[s[i]-'0']++;

    for (int i=0; i<=9; i++)
        v[i] = min(cnt1[i],cnt2[9-i]);

    for (int i=1; i<=9; i++)
        if (cnt1[i]>v[i] && cnt2[10-i]>v[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }
            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return 0;
        }

    for (int i=1; i<=9; i++)
        if (cnt1[i]>v[i] && v[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--; v[i-1]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }

            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return 0;
        }

    for (int i=1; i<=9; i++)
        if (cnt1[i] && cnt2[10-i]) {
            for (int j=v[0]; j<cnt1[0]; j++) n1.push_back(0), n2.push_back(0);
            cnt1[0] = cnt2[0] = v[0];
            n1.push_back(i); n2.push_back(10-i);
            cnt1[i]--; cnt2[10-i]--; v[i]--; v[i-1]--;
            for (int j=0; j<=9; j++) {
                while (v[j]>0) {
                    n1.push_back(j);
                    n2.push_back(9-j);
                    cnt1[j]--;
                    cnt2[9-j]--;
                    v[j]--;
                }
            }
            for (int j=0; j<=9; j++) {
                while (cnt1[j]>0) n1.push_back(j),cnt1[j]--;
                while (cnt2[j]>0) n2.push_back(j),cnt2[j]--;
            }
            imprime(n1);
            imprime(n2);
            return  0;
        }

    printf("%s\n",s);
    printf("%s\n",s);

    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 100010;
const int MAXA = 10;

int cnt[2][MAXA];
char s[MAXN];

char resa[MAXN], resb[MAXN];

int n;

inline int zero_tot()
{
  int tot = 1;
  for (int i = 0; i < 5; ++i) tot += min(cnt[0][i], cnt[1][9-i]);
  return tot;
}

void cal_res(int l0, int l1, int rm_zero)
{
  resa[n] = resb[n] = 0;

  int i = n-1, j;
  cnt[0][0] -= rm_zero;
  cnt[1][0] -= rm_zero;
  for (; rm_zero--; --i) resa[i] = resb[i] = '0';

  if (l0 != -1) {
    resa[i] = (char)l0 + '0';
    resb[i] = (char)l1 + '0';
    --i;
    --cnt[0][l0];
    --cnt[1][l1];
  }

  for (; i >= 0; --i)  {
    for (j = 0; j <= 9; ++j)
      if (cnt[0][j] && cnt[1][9-j]) break;

    if (j <= 9) {
      --cnt[0][j];
      --cnt[1][9-j];
      resa[i] = j + '0';
      resb[i] = (9-j) + '0';
    } else
      break;
  }

  for (; i >= 0; --i) {
    for (int j = 1; j < 10; ++j)
      if (cnt[0][j]) { --cnt[0][j]; resa[i] = j + '0'; break; }
    for (int j = 1; j < 10; ++j)
      if (cnt[1][j]) { --cnt[1][j]; resb[i] = j + '0'; break; }
  }
}

void solve()
{
  memset(cnt, 0, sizeof(cnt));

  n = strlen(s);
  for (int i = 0; i < n; ++i) ++cnt[0][s[i]-'0'], ++cnt[1][s[i]-'0'];

  int zero = cnt[0][0];
  int l0 = -1, l1 = -1, zero_max = 0, rm_zero = 0;

  for (int l = 0; l <= zero; ++l) {
    cnt[0][0] -= l;
    cnt[1][0] -= l;
    for (int tmp, i = 1; i <= 9; ++i)
      if (cnt[0][i] > 0 && cnt[1][10-i] > 0) {
	--cnt[0][i];
	--cnt[1][10-i];
	if ( (tmp = zero_tot()) + l > zero_max) {
	  zero_max = tmp + l;
	  rm_zero = l;
	  l0 = i;
	  l1 = 10-i;
	}
	++cnt[0][i];
	++cnt[1][10-i];
      }
    cnt[0][0] += l;
    cnt[1][0] += l;
  }

  if (l0 == -1) rm_zero = zero;
  cal_res(l0, l1, rm_zero);
  puts(resa);
  puts(resb);
}

int main()
{
  scanf("%s", s);
  solve();
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
const int maxn = 1e5+7;

char str[maxn];

int ar[10];
int br[10];
int main()
{
    cin>>str;
    vector<int> ans , ans1;
    int len = strlen(str);
    for(int i = 0 ; i < len ; i++){
        ar[str[i]-'0']++;
        br[str[i]-'0']++;
    }
    if(ar[0] > 0){
        while(ar[0]--)
            ans.push_back(0);
        while(br[0]--)
            ans1.push_back(0);
    }
   // cout<<"fdas";
    for(int i = 1 ; i < 10 ; i++){
      //      cout<<"fdas";
        if(ar[i] > 0 && ar[10 - i] > 0){
            ans.push_back(i);
            ans1.push_back(10-i);
            ar[i]--;
            br[10-i]--;
            break;
        }
    }
    for(int i = 0 ; i < 10 ;){
     //   cout<<"fdas";
        if(ar[i] > 0 && br[9 - i] > 0){
            ans.push_back(i);
            ans1.push_back(9-i);
            ar[i]--;
            br[9-i]--;
        }else{
            i++;
        }
    }
    for(int i = 0 ; i < 10 ; i++){
        while(ar[i] > 0) ans.push_back(i) , ar[i]--;
    }
   // for(int i = 0 ; i < 10 ; i++ ) cout<<br[i]<<" ";
    for(int i = 0 ; i < 10 ; i++){
        while(br[i] > 0) ans1.push_back(i) ,br[i]--;
    }
    for(int i = ans.size()-1 ; i>= 0  ; i--) cout<<ans[i];
    cout<<endl;
    for(int i = ans1.size()-1 ; i>= 0 ; i--) cout<<ans1[i];
    cout<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int calcans(int a, int b, vector <int> arr1)
{
	vector <int> arr2 = arr1;
	if (arr1[a] == 0 || arr2[b] == 0)
		return 0;
	int ans = 1;
	arr1[a] --;
	arr2[b] --;
	for (int i = 0; i <= 9; ++i)
	{
		int cnt = min(arr1[i], arr2[9-i]);
		ans += cnt;
		arr1[i] -= cnt;
		arr2[9-i] -= cnt;
	}
	ans += min (arr1[0],arr2[0]);
	return ans;
}

int zeros(int a, int b, vector <int> arr1)
{
	vector <int> arr2 = arr1;
	if (arr1[a] == 0 || arr2[b] == 0)
		return 0;
	int ans = 1;
	arr1[a] --;
	arr2[b] --;
	for (int i = 0; i <= 9; ++i)
	{
		int cnt = min(arr1[i], arr2[9-i]);
		ans += cnt;
		arr1[i] -= cnt;
		arr2[9-i] -= cnt;
	}
	return min (arr1[0],arr2[0]);
}

void genans(int a, int b, vector <int> arr1)
{
	vector <int> arr2 = arr1;
	int z = zeros(a,b,arr1);
	arr1[0] -= z;
	arr2[0] -= z;
	string ans1,ans2;
	for (int i = 0; i < z; i ++)
	{
		ans1 += '0';
		ans2 += '0';
	}
	ans1 += a+'0';
	ans2 += b+'0';
	arr1[a] --;
	arr2[b] --;
	for (int i = 0; i <= 9; ++i)
	{
		int cnt = min(arr1[i], arr2[9-i]);
		for (int j = 0; j < cnt; j ++)
		{
			ans1 += i + '0';
			ans2 += 9-i + '0';
		}
		arr1[i] -= cnt;
		arr2[9-i] -= cnt;
	}
	for (int i = 0; i <= 9; i ++)
		for (int j = 0; j < arr1[i]; j ++)
			ans1 += i+'0';
	for (int i = 0; i <= 9; i ++)
		for (int j = 0; j < arr2[i]; j ++)
			ans2 += i+'0';
	reverse(ans1.begin(), ans1.end());
	reverse(ans2.begin(), ans2.end());
	cout << ans1 << endl << ans2;
}

int main()
{
	vector <int> arr(10,0);
	string s;
	cin >> s;
	for (int i =0; i < s.size(); i++)
		arr[s[i]-'0'] ++;
	int ans = 0;
	int ansi = 0;
	for (int i = 1; i <= 5; ++ i)
	{
		int tmp = calcans(i, 10-i, arr);
		if (tmp > ans)
			ansi = i;
	}
	if (ansi == 0)
	{
		if (calcans(0,0,arr) > 0)
		{
			genans(0,0,arr);
			return 0;
		}

		cout << s << endl << s;
		return 0;
	}
	genans(ansi,10-ansi,arr);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

char s[123456];
int freq[10], a[10], b[10];
int p[10];
vector<pair<int, int> > ans, ten;

int main() {
  int n = 0;
  scanf("%s", s);
  for(n = 0; s[n]; ++n) ++a[s[n] - '0'];
  for(int i = 0; i < 10; ++i) freq[i] = (b[i] = a[i]) << 1;
  for(int i = 0; i < 10; ++i) {
    int m = min(freq[i], freq[9 - i]);
    p[i] = m;
    freq[i] -= m; freq[9 - i] -= m;
  }
  while(freq[0]) {
    ans.push_back(make_pair(0, 0));
    freq[0] -= 2;
  }
  bool carry = 0;
  for(int i = 1; i < 10; ++i) if(freq[i] && freq[10 - i] > (i == 10 - i)) {
    carry = 1;
    ans.push_back(make_pair(i, 10 - i));
    freq[i]--; freq[10 - i]--;
    break;
  }
  if(!carry) {
    for(int i = 1; i < 10; ++i) if(freq[i] && p[10 - i]) {
      carry = 1;
      ans.push_back(make_pair(i, 10 - i));
      freq[i]--;
      freq[i - 1]++;
      p[10 - i]--;
      break;
    }else if(freq[10 - i] && p[i]) {
      carry = 1;
      ans.push_back(make_pair(i, 10 - i));
      freq[9 - i]++;
      freq[10 - i]--;
      p[i]--;
      break;
    }
  }
  if(!carry) {
    freq[9] += p[0];
    while(p[0]) {
      ans.push_back(make_pair(0, 0));
      p[0] -= 2;
    }
    for(int i = 1; i < 10; ++i) {
      freq[i] += p[i];
      freq[9 - i] += p[i];
      p[i] = 0;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(p[i]) {
      ans.push_back(make_pair(i, 9 - i));
      p[i]--;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(freq[i] && freq[10 - i] > (i == 10 - i)) {
      ten.push_back(make_pair(i, 10 - i));
      freq[i]--; freq[10 - i]--;
    }
  }
  for(int i = 0; i < 10; ++i) {
    while(freq[i] > 1) {
      ans.push_back(make_pair(i, i));
      freq[i] -= 2;
      if(i + i < 10 && ten.size()) {
        ans.push_back(ten.front());
        ten.pop_back();
      }
    }
  }
  for(int i = 0; i < 10; ++i) if(freq[i])
    for(int j = i + 1; j < 10; ++j) if(freq[j]) {
      ans.push_back(make_pair(i, j));
      freq[i]--; freq[j]--;
      if(i + j < 10 && ten.size()) {
        ans.push_back(ten.front());
        ten.pop_back();
      }
    }
  ans.insert(ans.end(), ten.begin(), ten.end());
  assert(n == (int)ans.size());
  for(auto &item : ans) {
    if(!a[item.first]) swap(item.first, item.second);
    if(!b[item.second]) swap(item.first, item.second);
    a[item.first]--;
    b[item.second]--;
  }
  for(auto &item : ans) {
    if(item.first == item.second) continue;
    if(a[item.first] > 0 && b[item.first] < 0) {
      a[item.first]--; b[item.first]++;
      a[item.second]++; b[item.second]--;
      swap(item.first, item.second);
    }else if(a[item.first] < 0 && b[item.first] > 0) {
      a[item.first]++; b[item.first]--;
      a[item.second]--; b[item.second]++;
      swap(item.first, item.second);
    }
  }
  string p1, p2;
  for(auto item : ans) {
    p1 += char('0' + item.first);
    p2 += char('0' + item.second);
  }
  reverse(p1.begin(), p1.end());
  reverse(p2.begin(), p2.end());
  puts(p1.c_str());
  puts(p2.c_str());
  return 0;
}

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize ("-ffloat-store")
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
// #define ll int
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvl vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;++i)
#define repa(i,a,b) for(i=a;i<b;++i)
#define repb(i,a,b) for(i=a;i>=b;--i)
#define all(x) (x).begin(), (x).end()
#define s(v) (ll)v.size()
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define watch2(x,y) cerr << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << endl
#define Time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
#define inf 2000000000000000000
#define mod  1000000007
#define mod1 998244353
const int SZ = 5*1e6;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> // order_of_key() ; *( find_by_order() ) -> kth element in set;
// using namespace __gnu_pbds;  // order_of_key(k) -> Number of elements strictly smaller than k
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

// inline ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
// inline ll min( ll a, ll b, ll c) { return min(min(a, b), c);}
// inline ll max(ll a,ll b) {return (a>b) ? a : b;}
// inline ll min(ll a,ll b) {return (a<b) ? a : b;}
// inline ll mul(ll x, ll y, ll mod_){return ((x%mod_)*1LL*(y%mod_))%mod_;}
// ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
// ll powm(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=mul(p,a,mod_);} n>>=1; a=mul(a,a,mod_);} return p%mod_;}
// ll powi(ll a, ll mod_) {return powm(a,mod_-2,mod_);}
                          /*Code Begins*/

int main(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;
    // cout << setprecision(15);
    ll mn, mx;
    ll n, m, t, k, i, j, sum=0, flag=0, cnt=0;
    ll x=0, y=0, z, l , r, q;
    int TC=1;
    // cin >> TC;
while(TC--){
    string s;
    cin >> s;
    n = s(s);
    vll dig(10,0);
    fo(i,n) dig[s[i]-'0']++;
    vll dig2=dig;
    vll u, v;
    vll tmp=dig, tmp2=dig2;
    fo(i,10){
        tmp[i]-=min(dig[i],dig2[9-i]);
        tmp2[9-i]-=min(dig[i],dig2[9-i]);
    }
    x=min(tmp[0],tmp2[0]);
    // watch(tmp[0]);
    while(x--){
        u.pb(0);
        v.pb(0);
    }
    flag=0;
    repa(i,1,10){
        if(min(tmp[i],tmp2[10-i])>0){
            u.pb(i);
            v.pb(10-i);
            dig[i]--;
            dig2[10-i]--;
            flag=1;
            break;
        }
    }
    if(!flag){
        u.clear();
        v.clear();
        repa(i,1,10){
            if(min(dig[i],dig2[10-i])>0){
                u.pb(i);
                v.pb(10-i);
                dig[i]--;
                dig2[10-i]--;
                break;
            }
        }
        repa(i,0,10){
            fo(j,min(dig[i],dig2[9-i])){
                u.pb(i);
                v.pb(9-i);
            }
            x = min(dig[i],dig2[9-i]);
            dig[i]-=x;
            dig2[9-i]-=x;
        }
        fo(i,10){
            while(dig[i]--){
                u.pb(i);
            }
            while(dig2[i]--) v.pb(i);
        }
    }else{
        dig[0]-=min(tmp[0],tmp2[0]);
        dig2[0]-=min(tmp[0],tmp2[0]);
       repa(i,0,10){
            fo(j,min(dig[i],dig2[9-i])){
                u.pb(i);
                v.pb(9-i);
            }
            x = min(dig[i],dig2[9-i]);
            dig[i]-=x;
            dig2[9-i]-=x;
        }
        fo(i,10){
            while(dig[i]--){
                u.pb(i);
            }
            while(dig2[i]--) v.pb(i);
        }
    }
    reverse(all(u));
    reverse(all(v));
    // cout << s(u) << endl << s(v) << endl;
    for(auto x : u) cout << x;
    cout << endl;
    for(auto x : v) cout << x;
    cout << endl;

}
    Time;
    return 0;
}