#include <bits/stdc++.h>
using namespace std;
string toStr(int i) {
  string s = "x";
  s[0] = i + '0';
  return s;
}
int tensRemaining(map<int, int> mx, map<int, int> my) {
  int count = 0;
  for (int i = 1; i <= 9; i++)
    if (mx[i] > 0 && my[10 - i] > 0) {
      count++;
      if (count > 1) break;
    }
  return count;
}
int main() {
  string s;
  cin >> s;
  map<int, int> mx, my;
  for (int i = 0; i < (int)s.length(); i++) mx[s[i] - '0']++, my[s[i] - '0']++;
  string firstNinesX, firstNinesY;
  for (int i = 0; i <= 9; i++)
    if (tensRemaining(mx, my) != 1)
      while (mx[i] > 0 && my[9 - i] > 0) {
        mx[i]--, my[9 - i]--, firstNinesX.append(toStr(i)),
            firstNinesY.append(toStr(9 - i));
      }
  string tenX, tenY;
  for (int i = 1; i <= 9; i++)
    if (mx[i] > 0 && my[10 - i] > 0) {
      mx[i]--, my[10 - i]--, tenX = toStr(i), tenY = toStr(10 - i);
      break;
    }
  string secondNinesX, secondNinesY;
  for (int i = 0; i <= 9; i++)
    while (mx[i] > 0 && my[9 - i] > 0) {
      mx[i]--, my[9 - i]--, secondNinesX += toStr(i),
          secondNinesY += toStr(9 - i);
    }
  string zeroesX, zeroesY;
  while (mx[0] > 0 && my[0] > 0)
    mx[0]--, my[0]--, zeroesX.append("0"), zeroesY.append("0");
  string leadx, leady;
  for (int i = 0; i <= 9; i++)
    while (mx[i] > 0) mx[i]--, leadx += toStr(i);
  for (int i = 0; i <= 9; i++)
    while (my[i] > 0) my[i]--, leady += toStr(i);
  cout << leadx << secondNinesX << firstNinesX << tenX << zeroesX << endl;
  cout << leady << secondNinesY << firstNinesY << tenY << zeroesY << endl;
  return 0;
}
