#include <bits/stdc++.h>
using namespace std;
int p[10];
int d[10];
string a, b;
int abs(int a) {
  if (a < 0)
    return -a;
  else
    return a;
}
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) p[s[i] - '0']++;
  for (int i = 0; i <= 9; i++) d[i] = p[i] - min(p[i], p[9 - i]);
  int j = -1;
  for (int i = 1; i <= 9; i++)
    if (min(d[i], d[10 - i]) > 0) j = i;
  if (j == -1) {
    for (int i = 1; i <= 9; i++)
      if (min(p[i], p[10 - i]) > 0) j = i;
  }
  if (j == -1) {
    for (int i = 1; i < 10; i++)
      for (int f = 0; f < p[i]; f++) a += char(i + '0');
    for (int f = 0; f < p[0]; f++) a += '0';
    cout << a << endl << a;
    return 0;
  }
  int p1[10];
  memcpy(p1, p, sizeof(p));
  a += (char(j + '0'));
  b += (char(10 - j + '0'));
  p[j]--;
  p1[10 - j]--;
  for (int i = 0; i < 10; i++)
    if (min(p[i], p1[9 - i]) > 0) {
      int c = min(p[i], p1[9 - i]);
      for (int f = 0; f < c; f++) {
        a += char(i + '0');
        b += char(9 - i + '0');
        p[i]--;
        p1[9 - i]--;
      }
    }
  for (int i = 1; i < 10; i++) {
    for (int f = 0; f < p[i]; f++) a += char(i + '0');
    for (int f = 0; f < p1[i]; f++) b += char(i + '0');
  }
  int q = p[0] - p1[0];
  for (int f = 0; f < q; f++) {
    a = +'0';
    p[0]--;
  }
  q = -q;
  for (int f = 0; f < p1[0] - p[0]; f++) {
    b += '0';
    p1[0]--;
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int f = 0; f < p[0]; f++) a += '0';
  for (int f = 0; f < p1[0]; f++) b += '0';
  cout << a << endl << b;
}
