#include <bits/stdc++.h>
using namespace std;
const int N = 256;
int n, a[N], b[N], c[N], d[N];
vector<pair<int, int>> v;
pair<int, int> en = {-1, -1};
vector<pair<int, int>> res, zero;
string s;
void setup(string &s) {
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (char k : s) a[k - '0']++, b[k - '0']++;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  setup(s);
  for (int i = 0; i < 10; i++)
    while (a[i] && b[9 - i]) a[i]--, c[i]++, b[9 - i]--, d[9 - i]++;
  for (int i = 0; i < 10; i++)
    if (a[i] && b[10 - i]) en = {i, 10 - i};
  if (en.first < 0) {
    for (int i = 0; i < 10; i++)
      if (a[i] && d[10 - i]) en = {i, 10 - i};
    for (int i = 0; i < 10; i++)
      if (b[i] && c[10 - i]) en = {i, 10 - i};
  }
  if (en.first < 0)
    for (int i = 0; i < 10; i++)
      if (c[i] && d[10 - i]) en = {i, 10 - i};
  if (en.first < 0) {
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    return !(cout << s << endl << s << endl);
  }
  setup(s);
  res.push_back({en.first, en.second});
  a[en.first]--;
  b[en.second]--;
  for (int i = 0; i < 10; i++)
    while (a[i] && b[9 - i]) a[i]--, b[9 - i]--, res.push_back({i, 9 - i});
  while (a[0] && b[0]) zero.push_back({0, 0}), a[0]--, b[0]--;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      while (a[i] && b[j]) res.push_back({i, j}), a[i]--, b[j]--;
  reverse(res.begin(), res.end());
  for (auto it : zero) res.push_back(it);
  for (auto it : res) cout << it.first;
  cout << endl;
  for (auto it : res) cout << it.second;
  cout << endl;
}
