#include <bits/stdc++.h>
using namespace std;
char str[100050];
int xx[10], yy[10];
int main() {
  scanf("%s", str);
  int h[10];
  memset(h, 0, sizeof(h));
  int l = strlen(str);
  for (int i = 0; i < l; i++) {
    h[str[i] - '0']++;
  }
  int ans = 0, cwj = 0;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      xx[j] = h[j];
      yy[j] = h[j];
    }
    bool ch = true;
    if (xx[i] > 0)
      xx[i]--;
    else
      ch = false;
    if (yy[10 - i] > 0)
      yy[10 - i]--;
    else
      ch = false;
    if (!ch) continue;
    int cnt = 1;
    for (int j = 0; j < 10; j++) {
      int tmp = min(xx[j], yy[9 - j]);
      cnt += tmp;
      xx[j] -= tmp;
      yy[9 - j] -= tmp;
    }
    cnt += min(xx[0], yy[0]);
    if (cnt > ans) {
      ans = cnt;
      cwj = i;
    }
  }
  if (cwj == 0) {
    for (int i = 9; i >= 0; i--) {
      for (int j = 0; j < h[i]; j++) {
        putchar('0' + i);
      }
    }
    putchar('\n');
    for (int i = 9; i >= 0; i--) {
      for (int j = 0; j < h[i]; j++) {
        putchar('0' + i);
      }
    }
    putchar('\n');
  } else {
    for (int j = 0; j < 10; j++) {
      xx[j] = h[j];
      yy[j] = h[j];
    }
    xx[cwj]--;
    yy[10 - cwj]--;
    int buf[11];
    for (int i = 0; i < 10; i++) {
      int tmp = min(xx[i], yy[9 - i]);
      buf[i] = tmp;
      xx[i] -= tmp;
      yy[9 - i] -= tmp;
    }
    buf[10] = min(xx[0], yy[0]);
    xx[0] -= buf[10];
    yy[0] -= buf[10];
    for (int i = 9; i >= 0; i--) {
      for (int j = 0; j < xx[i]; j++) {
        putchar('0' + i);
      }
    }
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < buf[i]; j++) {
        putchar('0' + i);
      }
    }
    putchar('0' + cwj);
    for (int i = 0; i < buf[10]; i++) {
      putchar('0');
    }
    putchar('\n');
    for (int i = 9; i >= 0; i--) {
      for (int j = 0; j < yy[i]; j++) {
        putchar('0' + i);
      }
    }
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < buf[i]; j++) {
        putchar('0' + 9 - i);
      }
    }
    putchar('0' + 10 - cwj);
    for (int i = 0; i < buf[10]; i++) {
      putchar('0');
    }
    putchar('\n');
  }
  return 0;
}
