#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cctype>
#include <numeric>
#include <queue>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <iterator>
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
#define ITER(v)      __typeof((v).begin())
#define FOREACH(i,v) for(ITER(v) i=(v).begin();i!=(v).end();i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
#define x first
#define y second

int bin[10] = {0};
string opt1, opt2;
int ans = -1;

int main() {
        char c;
        while ( (c=getchar()) != EOF && isdigit(c) )
                bin[c - '0'] ++;

        string tmp = "";
        FOR(i, 0, 10) FOR(j, 0, bin[i]) tmp += (char)('0' + i);
        opt1 = opt2 = tmp;
        ans  = 0;

        // exhaust . . .
//      FOE(x, 0, 9) {
        FOE(x, 1, 9) {
                int y = x ? 10 - x : 0;
                if (bin[x] > 0 && bin[y] > 0) {
                        int as[10], at[10];
                        memcpy(as, bin, sizeof(as));
                        memcpy(at, bin, sizeof(at));
                        as[x]--;
                        at[y]--;

                        int cur = 1;
                        string s, t;

                        // pad zero . . .
                        while (at[9] < as[0] && at[0] > as[9]) {
                                as[0]--;
                                at[0]--;
                                s += '0';
                                t += '0';
                                cur++;
                        }

                        s += (char)('0'+x);
                        t += (char)('0'+y);

                        FOE(i, 0, 9) {
                                while (as[i] > 0 && at[9-i] > 0) {
                                        s += (char)('0'+i);
                                        t += (char)('0'+(9-i));
                                        as[i]--;
                                        at[9-i]--;
                                        cur++;
                                }
                        }

                        if (cur > ans) {
                                ans = cur;
                                FOE(i, 0, 9) FOR(j, 0, as[i]) s += (char)('0'+i);
                                FOE(i, 0, 9) FOR(j, 0, at[i]) t += (char)('0'+i);
                                opt1 = s;
                                opt2 = t;
                        }
                }
        }
        reverse(ALL(opt1));
        reverse(ALL(opt2));
        cout << opt1 << endl << opt2 << endl;
        return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cctype>
#include <numeric>
#include <queue>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <iterator>
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
#define ITER(v)      __typeof((v).begin())
#define FOREACH(i,v) for(ITER(v) i=(v).begin();i!=(v).end();i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
#define x first
#define y second

int bin[10] = {0};
string opt1, opt2;
int ans = -1;

int main() {
        char c;
        while ( (c=getchar()) != EOF && isdigit(c) )
                bin[c - '0'] ++;

        string tmp = "";
        FOR(i, 0, 10) FOR(j, 0, bin[i]) tmp += (char)('0' + i);
        opt1 = opt2 = tmp;
        ans  = 0;

        // exhaust . . .
        FOE(i, 1, 9) {
                int as[10], at[10];
                memcpy(as, bin, sizeof(as));
                memcpy(at, bin, sizeof(at));
                if (as[i] > 0 && at[10-i] > 0) {
                        string s, t;
                        FOR(j, 0, bin[0]) {
                                s += '0';
                                t += '0';
                        }
                        s += (char)('0'+i);
                        t += (char)('0'+(10-i));
                        as[i]--;
                        at[10-i]--;

                        int cur = 1;
                        FOE(i, 1, 8) {
                                while (as[i] > 0 && at[9-i] > 0) {
                                        s += (char)('0'+i);
                                        t += (char)('0'+(9-i));
                                        as[i]--;
                                        at[9-i]--;
                                        cur++;
                                }
                        }
                        if (cur > ans) {
                                ans = cur;
                                FOE(i, 1, 9) FOR(j, 0, as[i]) s += (char)('0'+i);
                                FOE(i, 1, 9) FOR(j, 0, at[i]) t += (char)('0'+i);
                                opt1 = s;
                                opt2 = t;
                        }
                }
        }
        reverse(ALL(opt1));
        reverse(ALL(opt2));
        cout << opt1 << endl << opt2 << endl;
        return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cctype>
#include <numeric>
#include <queue>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <iterator>
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
#define ITER(v)      __typeof((v).begin())
#define FOREACH(i,v) for(ITER(v) i=(v).begin();i!=(v).end();i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
#define x first
#define y second

int bin[10] = {0};
string opt1, opt2;
int ans = -1;

int main() {
        char c;
        while ( (c=getchar()) != EOF && isdigit(c) )
                bin[c - '0'] ++;

        string tmp = "";
        FOR(i, 0, 10) FOR(j, 0, bin[i]) tmp += (char)('0' + i);
        opt1 = opt2 = tmp;
        ans  = 0;

        // exhaust . . .
        FOE(x, 0, 9) {
                int y = x ? 10 - x : 0;
                if (bin[x] > 0 && bin[y] > 0) {
                        int as[10], at[10];
                        memcpy(as, bin, sizeof(as));
                        memcpy(at, bin, sizeof(at));
                        as[x]--;
                        at[y]--;

                        int cur = 1;
                        string s, t;

                        // pad zero . . .
                        while (at[9] < as[0] && at[0] > as[9]) {
                                as[0]--;
                                at[0]--;
                                s += '0';
                                t += '0';
                                cur++;
                        }

                        s += (char)('0'+x);
                        t += (char)('0'+y);

                        FOE(i, 0, 9) {
                                while (as[i] > 0 && at[9-i] > 0) {
                                        s += (char)('0'+i);
                                        t += (char)('0'+(9-i));
                                        as[i]--;
                                        at[9-i]--;
                                        cur++;
                                }
                        }

                        if (cur > ans) {
                                ans = cur;
                                FOE(i, 0, 9) FOR(j, 0, as[i]) s += (char)('0'+i);
                                FOE(i, 0, 9) FOR(j, 0, at[i]) t += (char)('0'+i);
                                opt1 = s;
                                opt2 = t;
                        }
                }
        }
        reverse(ALL(opt1));
        reverse(ALL(opt2));
        cout << opt1 << endl << opt2 << endl;
        return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cctype>
#include <numeric>
#include <queue>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <iterator>
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
#define ITER(v)      __typeof((v).begin())
#define FOREACH(i,v) for(ITER(v) i=(v).begin();i!=(v).end();i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
#define x first
#define y second

int bin[10] = {0};
string opt1, opt2;
int ans = -1;

int main() {
        char c;
        while ( (c=getchar()) != EOF && isdigit(c) )
                bin[c - '0'] ++;

        string tmp = "";
        FOR(i, 0, 10) FOR(j, 0, bin[i]) tmp += (char)('0' + i);
        opt1 = opt2 = tmp;
        ans  = 0;

        // exhaust . . .
        FOE(x, 0, 9) {
                int y = x ? 10 - x : 0;
                if (bin[x] > 0 && bin[y] > 0) {
                        // pad zero
                        {
                                int as[10], at[10];
                                memcpy(as, bin, sizeof(as));
                                memcpy(at, bin, sizeof(at));
                                as[x]--; at[y]--;
                                as[0] = at[0] = 0;

                                int cur = bin[0] + 1;
                                string s, t;
                                FOR(j, 0, bin[0] - (x==0)) {
                                        s += '0';
                                        t += '0';
                                }
                                s += (char)('0'+x);
                                t += (char)('0'+y);

                                FOE(i, 1, 9) {
                                        while (as[i] > 0 && at[9-i] > 0) {
                                                s += (char)('0'+i);
                                                t += (char)('0'+(9-i));
                                                as[i]--;
                                                at[9-i]--;
                                                cur++;
                                        }
                                }
                                if (cur > ans) {
                                        ans = cur;
                                        FOE(i, 0, 9) FOR(j, 0, as[i]) s += (char)('0'+i);
                                        FOE(i, 0, 9) FOR(j, 0, at[i]) t += (char)('0'+i);
                                        opt1 = s;
                                        opt2 = t;
                                }
                        }
                        // don't pad zero
                        {
                                int as[10], at[10];
                                memcpy(as, bin, sizeof(as));
                                memcpy(at, bin, sizeof(at));
                                as[x]--; at[y]--;

                                int cur = 1;
                                string s, t;
                                s += (char)('0'+x);
                                t += (char)('0'+y);

                                FOE(i, 0, 9) {
                                        while (as[i] > 0 && at[9-i] > 0) {
                                                s += (char)('0'+i);
                                                t += (char)('0'+(9-i));
                                                as[i]--;
                                                at[9-i]--;
                                                cur++;
                                        }
                                }

                                while (as[0] > 0 && at[0] > 0) {
                                        as[0]--; at[0]--;
                                        s += '0';
                                        t += '0';
                                        cur++;
                                }

                                if (cur > ans) {
                                        ans = cur;
                                        FOE(i, 0, 9) FOR(j, 0, as[i]) s += (char)('0'+i);
                                        FOE(i, 0, 9) FOR(j, 0, at[i]) t += (char)('0'+i);
                                        opt1 = s;
                                        opt2 = t;
                                }

                        }
                }
        }
        reverse(ALL(opt1));
        reverse(ALL(opt2));
        cout << opt1 << endl << opt2 << endl;
        return 0;
}


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

#define mp make_pair
#define pb push_back

const int N = 100005;
int v1[12], v2[12];
int b1[12], b2[12];
string s;
int n;

vector<pair<int, pair<string, string> > > v;

inline void add(string &s, int b[], int t) {
	s += '0' + t;
	b[t]--;
}

void work(int fst) {
	int num = 0;
	copy(v1, v1 + 10, b1);
	copy(v2, v2 + 10, b2);
	int ed;
	if (b2[10 - fst]) {
		ed = 10 - fst;
	} else {
		ed = 0;
		while (!b2[ed]) ed++;
	}
	string r1, r2;
	add(r1, b1, fst);
	add(r2, b2, ed);
	if (fst + ed % 10 == 0) num++;
	// sum of '9's
	for (int i = 1; i < n; i++) {
		bool flag = false;
		for (int j = 0; j < 10; j++) {
			if (b1[j] && b2[9 - j]) {
				flag = true;
				add(r1, b1, j);
				add(r2, b2, 9 - j);
				num++;
				break;
			}
		}
		if (!flag) {
			break;
		}
	}
	vector<int> x, y;
	for (int i = 0; i < 10; i++) {
		if (b1[i]) {
			while (b1[i]) {
				x.pb(i);
				b1[i]--;
			}
		}
		if (b2[i]) {
			while (b2[i]) {
				y.pb(i);
				b2[i]--;
			}
		}
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int j = x.size() - 1;
	for (; j >= 0 && (x[j] + y[j] % 10); j--) {
		r1 += '0' + x[j];
		r2 += '0' + y[j];
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	for (; j >= 0; j--) {
		r1 += '0';
		r2 += '0';
		num++;
	}
	v.pb(mp(num, mp(r1, r2)));
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	for (int i = 0; i < 10; i++) {
		if (v1[i]) {
			work(i);
		}
	}
	sort(v.begin(), v.end());
	cout << v.back().second.first << "\n" << v.back().second.second << endl;
}


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

#define mp make_pair
#define pb push_back
#define PII pair<int, int>

vector<string> v;

int cal(const string &s, int ret = 0) {
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '0') ret++;
		else return ret;
	}
	return ret;
}

string n2s(int a) {
	if (!a) return "0";
	string ret = "";
	while (a) {
		ret.pb('0' + a % 10);
		a /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int s2n(string &s, int ret = 0) {
	int j = 0;
	while (s[j] == '0') j++;
	s = s.substr(j);
	for (int i = 0; i < s.size(); i++) {
		ret *= 10;
		ret += s[i] - '0';
	}
	return ret;
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	do {
		v.pb(s);
	} while (next_permutation(s.begin(), s.end()));

	int ret = 0;
	PII p = mp(0, 0);
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			//int n1 = s2n(v[i]);
			//int n2 = s2n(v[j]);
			//string s2 = n2s(n1 + n2);
			int tmp = cal(n2s(s2n(v[i]) + s2n(v[j])));
			if (tmp > ret) {
				ret = tmp;
				p = mp(i, j);
			}
		}
	}
	cout << v[p.first] << '\n' << v[p.second] << endl;;

	return 0;
}


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

#define mp make_pair
#define pb push_back

const int N = 100005;
int v1[12], v2[12];
int b1[12], b2[12];
string s;
int n;

vector<pair<int, pair<string, string> > > v;

inline void add(string &s, int b[], int t) {
	s += '0' + t;
	b[t]--;
}

void work(int fst) {
	int num = 0;
	copy(v1, v1 + 10, b1);
	copy(v2, v2 + 10, b2);
	int ed;
	if (b2[10 - fst]) {
		ed = 10 - fst;
	} else {
		ed = 0;
		while (!b2[ed]) ed++;
	}
	string r1, r2;
	add(r1, b1, fst);
	add(r2, b2, ed);
	bool yes = (fst + ed == 10);
	if (fst + ed % 10 == 0) num++;
	// sum of '9's
	for (int i = 1; i < n; i++) {
		bool flag = false;
		for (int j = 0; j < 10; j++) {
			if (b1[j] && b2[9 - j]) {
				flag = true;
				add(r1, b1, j);
				add(r2, b2, 9 - j);
				if (yes) {
					num++;
				}
				break;
			}
		}
		if (!flag) {
			break;
		}
	}
	vector<int> x, y;
	for (int i = 0; i < 10; i++) {
		if (b1[i]) {
			while (b1[i]) {
				x.pb(i);
				b1[i]--;
			}
		}
		if (b2[i]) {
			while (b2[i]) {
				y.pb(i);
				b2[i]--;
			}
		}
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int j = x.size() - 1;
	for (; j >= 0 && (x[j] + y[j] % 10); j--) {
		r1 += '0' + x[j];
		r2 += '0' + y[j];
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	for (; j >= 0; j--) {
		r1 += '0';
		r2 += '0';
		num++;
	}
	v.pb(mp(num, mp(r1, r2)));
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	for (int i = 0; i < 10; i++) {
		if (v1[i]) {
			work(i);
		}
	}
	sort(v.begin(), v.end());
	cout << v.back().second.first << "\n" << v.back().second.second << endl;
}


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

#define mp make_pair
#define pb push_back
#define PII pair<int, int>

vector<string> v;
int M[10000];

int cal(const string &s, int ret = 0) {
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '0') ret++;
		else return ret;
	}
	return ret;
}

string n2s(int a) {
	if (!a) return "0";
	string ret = "";
	while (a) {
		ret.pb('0' + a % 10);
		a /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int s2n(string &s, int ret = 0) {
	int j = 0;
	while (s[j] == '0') j++;
	s = s.substr(j);
	for (int i = 0; i < s.size(); i++) {
		ret *= 10;
		ret += s[i] - '0';
	}
	return ret;
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	do {
		v.pb(s);
	} while (next_permutation(s.begin(), s.end()));

	for (int i = 0; i < v.size(); i++) {
		M[i] = s2n(v[i]);
	}
	int ret = 0;
	PII p = mp(0, 0);
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			//int n1 = s2n(v[i]);
			//int n2 = s2n(v[j]);
			//string s2 = n2s(n1 + n2);
			int tmp = cal(n2s(M[j] + M[i]));
			if (tmp > ret) {
				ret = tmp;
				p = mp(i, j);
			}
		}
	}
	cout << v[p.first] << '\n' << v[p.second] << endl;;

	return 0;
}


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

#define mp make_pair
#define pb push_back
#define PII pair<int, int>

vector<string> v, b;
int M[10000];

int cal(int s, int ret = 0) {
	if (!s) return 1;
	while (s > 0) {
		if (s % 10 == 0) {
			ret++;
			s /= 10;
		} else {
			return ret;
		}
	}
}

int s2n(string &s, int ret = 0) {
	int j = 0;
	while (j < s.size() && s[j] == '0') {
		j++;
	}
	s = s.substr(j);
	for (int i = 0; i < s.size(); i++) {
		ret *= 10;
		ret += s[i] - '0';
	}
	return ret;
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	do {
		v.pb(s);
	} while (next_permutation(s.begin(), s.end()));

	b.resize(v.size());
	for (int i = 0; i < v.size(); i++) {
		b[i] = v[i];
		M[i] = s2n(v[i]);
	}
	int ret = 0;
	PII p = mp(0, 0);
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			int tmp = cal(M[j] + M[i]);
			if (tmp > ret) {
				ret = tmp;
				p = mp(i, j);
			}
		}
	}
	cout << b[p.first] << '\n' << b[p.second] << endl;;

	return 0;
}


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

#define mp make_pair
#define pb push_back

const int N = 100005;
int v1[12], v2[12];
int b1[12], b2[12];
string s;
int n;

vector<pair<int, pair<string, string> > > v;

inline void add(string &s, int b[], int t) {
	s += '0' + t;
	b[t]--;
}

void work(int fst) {
	int num = 0;
	copy(v1, v1 + 10, b1);
	copy(v2, v2 + 10, b2);
	int ed;
	if (b2[10 - fst]) {
		ed = 10 - fst;
	} else {
		ed = 0;
		while (!b2[ed]) ed++;
	}
	string r1, r2;
	add(r1, b1, fst);
	add(r2, b2, ed);
	if (fst + ed == 10) num++;
	// sum of '9's
	for (int i = 1; i < n; i++) {
		bool flag = false;
		for (int j = 0; j < 10; j++) {
			if (b1[j] && b2[9 - j]) {
				flag = true;
				add(r1, b1, j);
				add(r2, b2, 9 - j);
				num++;
				break;
			}
		}
		if (!flag) {
			break;
		}
	}
	vector<int> x, y;
	for (int i = 0; i < 10; i++) {
		if (b1[i]) {
			while (b1[i]) {
				x.pb(i);
				b1[i]--;
			}
		}
		if (b2[i]) {
			while (b2[i]) {
				y.pb(i);
				b2[i]--;
			}
		}
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int j = x.size() - 1;
	for (; j >= 0 && x[j] && y[j]; j--) {
		r1 += '0' + x[j];
		r2 += '0' + y[j];
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	for (; j >= 0; j--) {
		r1 += '0';
		r2 += '0';
		num++;
	}
	v.pb(mp(num, mp(r1, r2)));
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	for (int i = 0; i < 10; i++) {
		if (v1[i]) {
			work(i);
		}
	}
	sort(v.begin(), v.end());
	cout << v.back().second.first << "\n" << v.back().second.second << endl;
}


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

#define mp make_pair
#define pb push_back
#define PII pair<int, int>

int v1[10], v2[10];
string s;

int base[2] = {10, 9};
int fst;

inline int yes(int &w, int &h) {
	for (int i = 1 - (10 - base[fst]); i < 10; i++) {
		if (v1[i] && v2[base[fst] - i]) {
			w = i;
			h = base[fst] - i;
			return 1;
		}
	}
	w = h = 1;
	while (w < 10 && !v1[w]) w++;
	while (h < 10 && !v2[h]) h++;
	return (w < 10 && h < 10);
}

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

	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	int n = s.size();
	string r1 = "", r2 = "";

	for (int i = 0; i < n; i++) {
		int w, h;
		if (yes(w, h)) {
			r1.pb('0' + w);
			r2.pb('0' + h);
			v1[w]--;
			v2[h]--;
			if (i == 0) {
				fst = 1;
			}
		} else {
			break;
		}
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	for (int i = 0; i < v1[0]; i++) {
		r1.pb('0');
		r2.pb('0');
	}
	cout << r1 << "\n" << r2 << endl;
}


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

#define mp make_pair
#define pb push_back

const int N = 100005;
int v1[12], v2[12];
int b1[12], b2[12];
string s;
int n;

vector<pair<int, pair<string, string> > > v;

inline void add(string &s, int b[], int t) {
	s += '0' + t;
	b[t]--;
}

void work(int fst) {
	int num = 0;
	copy(v1, v1 + 10, b1);
	copy(v2, v2 + 10, b2);
	int ed;
	if (b2[10 - fst]) {
		ed = 10 - fst;
	} else {
		ed = 0;
		while (!b2[ed]) ed++;
	}
	string r1, r2;
	add(r1, b1, fst);
	add(r2, b2, ed);
	bool yes = (fst + ed == 10);
	if ((fst + ed) % 10 == 0) num++;
	// sum of '9's
	for (int i = 1; i < n; i++) {
		bool flag = false;
		for (int j = 0; j < 10; j++) {
			if (b1[j] && b2[9 - j]) {
				flag = true;
				add(r1, b1, j);
				add(r2, b2, 9 - j);
				if (yes) {
					num++;
				}
				break;
			}
		}
		if (!flag) {
			break;
		}
	}
	vector<int> x, y;
	for (int i = 0; i < 10; i++) {
		if (b1[i]) {
			while (b1[i]) {
				x.pb(i);
				b1[i]--;
			}
		}
		if (b2[i]) {
			while (b2[i]) {
				y.pb(i);
				b2[i]--;
			}
		}
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int j = x.size() - 1;
	for (; j >= 0 && (x[j] + y[j] % 10); j--) {
		r1 += '0' + x[j];
		r2 += '0' + y[j];
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	for (; j >= 0; j--) {
		r1 += '0';
		r2 += '0';
		num++;
	}
	v.pb(mp(num, mp(r1, r2)));
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	for (int i = 0; i < 10; i++) {
		if (v1[i]) {
			work(i);
		}
	}
	sort(v.begin(), v.end());
	cout << v.back().second.first << "\n" << v.back().second.second << endl;
}


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

#define mp make_pair
#define pb push_back
#define PII pair<int, int>

int v1[10], v2[10];
string s;
int one;

bool yes(int &w, int base) {
	for (int i = w; i < 10; i++) {
		if (v1[i] && v2[base - i]) {
			//one -= (10 - base);
			w = i;
			return true;
		}
	}
	return false;
}
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		v1[s[i] - '0']++;
		v2[s[i] - '0']++;
	}
	int n = s.size();
	string r1 = "", r2 = "";
	for (int i = 0; i < n; i++) {
		int w = 0, h = 0;
		while (!v1[w]) w++;
		while (!v2[h]) h++;
		if (!(w == 0 && h == 0)) {
			if (yes(w, 10 - one)) {
				h = 10 - one - w;
				one = 1;
				//	break;
			}
			//}
		}
		v1[w]--;
		v2[h]--;
		r1 += '0' + w;
		r2 += '0' + h;
	}
	reverse(r1.begin(), r1.end());
	reverse(r2.begin(), r2.end());
	cout << r1 << "\n" << r2 << endl;
}


/*
Spreading your lies
And preaching like a prophet
For all those gone beyond
I'll never sacrifice my life.
I should be in fear of your judgment
But for now and ever I rise above them.
I won't hear you
Never feel you I don't bare your marks.
I should be in fear of your judgment
But for now and ever I rise above them
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-9
//#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512
#define right adsgasgadsg
#define free adsgasdg

using namespace std;

string st;
long cnt[100],cnt1[100],cnt2[100],c[100],s,bst,ans;
vector<long> ans1,ans2;
long ansv;
long c1[100],c2[100];

int main(){
//freopen("alter.in","r",stdin);
//freopen("alter.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
//ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>st;
for (int i=0;i<st.size();i++)
{
 cnt[st[i]-48]++;
}

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

for (int zeros=0;zeros<=cnt[0];zeros++)
for (int pp=1;pp<=5;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);
  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;

cin.get();cin.get();
return 0;}


/*
Spreading your lies
And preaching like a prophet
For all those gone beyond
I'll never sacrifice my life.
I should be in fear of your judgment
But for now and ever I rise above them.
I won't hear you
Never feel you I don't bare your marks.
I should be in fear of your judgment
But for now and ever I rise above them
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-9
//#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512
#define right adsgasgadsg
#define free adsgasdg

using namespace std;

string st;
long cnt[100],cnt1[100],cnt2[100],c[100],s,bst,ans;
vector<long> ans1,ans2;
long ansv;
long c1[100],c2[100];

int main(){
//freopen("alter.in","r",stdin);
//freopen("alter.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
//ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>st;
for (int i=0;i<st.size();i++)
{
 cnt[st[i]-48]++;
}

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

for (int zeros=0;zeros<=cnt[0];zeros++)
for (int pp=1;pp<=5;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<=4;i++)
{
 for (int j=0;j<min(cnt1[i],cnt2[9-i]);j++)
 {
  ans1.push_back(i);
  ans2.push_back(9-i);
  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;

cin.get();cin.get();
return 0;}


/*
Spreading your lies
And preaching like a prophet
For all those gone beyond
I'll never sacrifice my life.
I should be in fear of your judgment
But for now and ever I rise above them.
I won't hear you
Never feel you I don't bare your marks.
I should be in fear of your judgment
But for now and ever I rise above them
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-9
//#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512
#define right adsgasgadsg
#define free adsgasdg

using namespace std;

string st;
long cnt[100],cnt1[100],cnt2[100],c[100],s,bst,ans;
vector<long> ans1,ans2;
long ansv;
long c1[100],c2[100];

int main(){
//freopen("alter.in","r",stdin);
//freopen("alter.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
//ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>st;
for (int i=0;i<st.size();i++)
{
 cnt[st[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);
 }
 long 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;

cin.get();cin.get();
return 0;}


/*
Spreading your lies
And preaching like a prophet
For all those gone beyond
I'll never sacrifice my life.
I should be in fear of your judgment
But for now and ever I rise above them.
I won't hear you
Never feel you I don't bare your marks.
I should be in fear of your judgment
But for now and ever I rise above them
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-9
//#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512
#define right adsgasgadsg
#define free adsgasdg

using namespace std;

string st;
long cnt[100],cnt1[100],cnt2[100],c[100],s,bst,ans;
vector<long> ans1,ans2;
long ansv;
long c1[100],c2[100];

int main(){
//freopen("alter.in","r",stdin);
//freopen("alter.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
//ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>st;
for (int i=0;i<st.size();i++)
{
 cnt[st[i]-48]++;
}

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

for (int zeros=0;zeros<=cnt[0];zeros++)
for (int pp=1;pp<=5;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){
ans2.push_back(ansv);
--cnt2[ansv];
ans1.push_back(10-ansv);
--cnt1[10-ansv];
}

for (int i=0;i<=4;i++)
{
 for (int j=0;j<min(cnt1[i],cnt2[9-i]);j++)
 {
  ans1.push_back(i);
  ans2.push_back(9-i);
  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;

cin.get();cin.get();
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, p, q, pp, qq;
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'];

    FOR_1(i, 0, a[0]){
        a[0] -= i, rr = 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;
    }

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

#define l a
#define r b

    --a[x], --b[y];

    REP(i, 10) REP(j, l[i] - min(l[i], r[9-i])) printf("%d", i);
    REP(i, 10) REP(j, min(l[i], r[9-i])) printf("%d", i);
    printf("%d", x); REP(i, zero) putchar('0'); puts("");

    DWN(i, 10, 0) REP(j, r[i] - min(l[i], r[9-i])) printf("%d", i);
    DWN(i, 10, 0) REP(j, min(l[i], r[9-i])) printf("%d", i);
    printf("%d", x); REP(i, zero) putchar('0'); puts("");

}

/*

int a[10],n,A[10],B[10];char s[100010];int S=-1,Sx,Sy,AS=-1,ASx,ASy,ASz;
void chk(int x,int y)
{
    memcpy(A,a,sizeof A),
    memcpy(B,a,sizeof B);
    A[x]--,B[y]--;
    if(A[x]<0||B[y]<0)return;
    int T=0;
    for(int i=0;i<10;i++)T+=min(A[i],B[9-i]);
    if(T>S)S=T,Sx=x,Sy=y;
}
int main()
{

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

    scanf("%s",s);n=strlen(s);
    for(int i=0;i<n;i++)a[s[i]-'0']++;
    for(int i=0;i<=a[0];i++)
    {
        a[0]-=i;S=-1,Sx=Sy=0;
        chk(1,9),chk(2,8),chk(3,7),chk(4,6),chk(5,5);a[0]+=i;
        if(S==-1)
        {
            if(i>=1&&i>=AS)AS=i,Sx=Sy=0,ASz=i;continue;
        }
        if(S+i+1>AS)AS=S+i+1,ASx=Sx,ASy=Sy,ASz=i;
    }
    if(AS<=0){printf("%s\n%s\n",s,s);return 0;}

    if (!ASx) --ASz;

    a[0]-=ASz;
    memcpy(A,a,sizeof A),
    memcpy(B,a,sizeof B);

    cout << AS << endl;

    A[ASx]--,B[ASy]--;
    for(int i=0;i<10;i++)
        for(int j=0;j<A[i]-min(A[i],B[9-i]);j++)printf("%d",i);
    for(int i=0;i<10;i++)
        for(int j=0;j<min(A[i],B[9-i]);j++)printf("%d",i);
    printf("%d",ASx);
    for(int i=0;i<ASz;i++)putchar('0');
    puts("");
    for(int i=0;i<10;i++)
        for(int j=0;j<B[9-i]-min(A[i],B[9-i]);j++)printf("%d",9-i);
    for(int i=0;i<10;i++)
        for(int j=0;j<min(A[i],B[9-i]);j++)printf("%d",9-i);
    printf("%d",ASy);
    for(int i=0;i<ASz;i++)putchar('0');
    puts("");
    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 = 0, 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;
    }

    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("");
}


/** ` 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)

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

const int N = 5;
int a[N], b[120], p, q, m;
int n, _n;

int f(int x){
    int res = 0;
    while (x){
        if (x % 10 == 0) ++res;
        x /= 10;
    }
    return res;
}

int main(){

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios::sync_with_stdio(false);

    RD(_n);
    while (_n){
        a[n++] = _n % 10;
        _n /= 10;
    }

    int Fn = 1; REP_1(i, n) Fn *= i;

    REP(i, Fn){

        b[i] = 0;
        REP(j, n){
            b[i] *= 10;
            b[i] += a[n-j-1];
        }

        next_permutation(a, a + n);
    }

    m = 0, p = b[0], q = b[0];
    REP(i, Fn) FOR(j, i, Fn){
        if (f(b[i] + b[j]) > m){
            m = f(b[i] + b[j]);
            p = b[i], q = b[j];
        }
    }

    OT(p), OT(q);
}


/** ` 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)

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

const int N = 5;
int a[N], b[120], p, q, m;
int n, _n;

int f(int x){
    int res = 0;
    while (x && x % 10 == 0){
        ++res, x /= 10;
    }
    return res;
}

int main(){

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios::sync_with_stdio(false);

    RD(_n);
    while (_n){
        a[n++] = _n % 10;
        _n /= 10;
    }

    int Fn = 1; REP_1(i, n) Fn *= i;

    REP(i, Fn){

        b[i] = 0;
        REP(j, n){
            b[i] *= 10;
            b[i] += a[n-j-1];
        }

        next_permutation(a, a + n);
    }

    m = 0, p = b[0], q = b[0];
    REP(i, Fn) FOR(j, i, Fn){
        if (f(b[i] + b[j]) > m){
            m = f(b[i] + b[j]);
            p = b[i], q = b[j];
        }
    }

    OT(p), OT(q);
}


/** ` 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) r += min(a[i] - (i == x), a[9-i] - (i == y));

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

    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("");
}