#include <bits/stdc++.h>
using namespace std;
int data[2][10], t, l[10];
char s[100005], ss[2][100005];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  memset(data, 0, sizeof(data));
  for (int i = 0; i < n; i++) l[s[i] - '0']++;
  memcpy(data[0], l, sizeof(l));
  memcpy(data[1], l, sizeof(l));
  bool flag = false;
  int ans = -1, w;
  for (int i = 1; i <= 5; i++) {
    int j = 10 - i;
    if (data[0][i] == 0 || data[0][j] == 0) continue;
    data[0][i]--;
    data[1][j]--;
    int k = 0;
    for (int g = 0; g < 10; g++) {
      int h = 9 - g;
      int o = min(data[0][g], data[1][h]);
      k += o;
      data[0][g] -= o;
      data[1][h] -= o;
    }
    k += min(data[0][0], data[1][0]);
    flag = true;
    if (ans == -1 || k > ans) {
      ans = k;
      t = i;
      w = min(data[0][0], data[1][0]);
    }
    memcpy(data[0], l, sizeof(l));
    memcpy(data[1], l, sizeof(l));
  }
  int cnt = 0;
  if (flag) {
    data[0][t]--;
    data[1][10 - t]--;
    data[0][0] -= w;
    data[1][0] -= w;
    for (int j = 0; j < w; j++) {
      ss[0][cnt] = ss[1][cnt] = '0';
      cnt++;
    }
    ss[0][cnt] = t + '0';
    ss[1][cnt] = 10 - t + '0';
    cnt++;
    for (int i = 0; i < 10; i++) {
      int o = min(data[0][i], data[1][9 - i]);
      for (int j = 0; j < o; j++) {
        ss[0][cnt] = i + '0';
        ss[1][cnt] = 9 - i + '0';
        cnt++;
      }
      data[0][i] -= o;
      data[1][9 - i] -= o;
    }
  }
  int cntt = cnt;
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < data[0][i]; j++) {
      ss[0][cnt] = i + '0';
      cnt++;
    }
  cnt = cntt;
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < data[1][i]; j++) {
      ss[1][cnt] = i + '0';
      cnt++;
    }
  for (int i = cnt - 1; i >= 0; i--) printf("%c", ss[0][i]);
  printf("\n");
  for (int i = cnt - 1; i >= 0; i--) printf("%c", ss[1][i]);
  printf("\n");
}
