#include <bits/stdc++.h>
char s[100039];
int u[100039], v[100039];
int a[10];
int best, sx, sy, k;
int min(int x, int y) { return x < y ? x : y; }
void calc(int cur) {
  int b[10], c[10];
  if (cur > best) {
    best = cur;
    sx = -1;
    sy = -1;
  }
  for (int x = 1; x <= 5; ++x) {
    for (int i = 0; i < 10; ++i) {
      b[i] = a[i];
      c[i] = a[i];
    }
    int y = 10 - x;
    if (--b[x] < 0) continue;
    if (--c[y] < 0) continue;
    int zeroes = cur + 1;
    for (int i = 0; i < 10; ++i) zeroes += min(b[i], c[9 - i]);
    if (zeroes > best) {
      best = zeroes;
      sx = x;
      sy = y;
    }
  }
}
void print() {
  int b[10], c[10];
  for (int i = 0; i < 10; ++i) {
    b[i] = a[i];
    c[i] = a[i];
  }
  if (sx != -1) {
    u[k] = sx;
    b[sx]--;
    v[k] = sy;
    c[sy]--;
    k++;
    for (int i = 0; i < 10; ++i) {
      int q = min(b[i], c[9 - i]);
      for (int j = 0; j < q; ++j) {
        u[k] = i;
        b[i]--;
        v[k] = 9 - i;
        c[9 - i]--;
        k++;
      }
    }
  }
  int sk = k;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < b[i]; ++j) {
      u[k] = i;
      k++;
    }
  k = sk;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < c[i]; ++j) {
      v[k] = i;
      k++;
    }
  for (int i = k - 1; i >= 0; i--) printf("%d", u[i]);
  printf("\n");
  for (int i = k - 1; i >= 0; i--) printf("%d", v[i]);
  printf("\n");
}
int main() {
  gets(s);
  for (int i = 0; s[i]; ++i) a[s[i] - '0']++;
  best = 0;
  calc(0);
  int tmp1 = best;
  int z9 = a[0] - a[9];
  if (z9 < 0) z9 = 0;
  a[0] -= z9;
  calc(z9);
  int tmp2 = best;
  int z0 = a[0];
  a[0] = 0;
  calc(z0 + z9);
  int tmp3 = best;
  if (best == 0) {
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) printf("%d", i);
    printf("\n");
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) printf("%d", i);
    printf("\n");
    return 0;
  }
  k = 0;
  if (tmp3 > tmp2) {
    for (k = 0; k < z0 + z9; ++k) {
      u[k] = 0;
      v[k] = 0;
    }
  } else if (tmp2 > tmp1) {
    a[0] += z0;
    for (k = 0; k < z9; ++k) {
      u[k] = 0;
      v[k] = 0;
    }
  } else
    a[0] = z0 + z9;
  print();
  return 0;
}
