Problem: Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.

Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.

Given number n, can you find the two digit permutations that have this property?

Input

The first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.

Output

Print two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.

Examples

Input

198


Output

981
819


Input

500


Output

500
500

Solution (in CPP):

Solution:
#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;
}