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>
using namespace std;
const double eps = 1e-10;
const int oo = ~0u >> 2, mo = (int)1e9 + 7;
const int mn = 10, mp = mn * 2 + 10, me = ((mp) * (mp));
struct Edge {
  int y, f, l;
} E[me];
int g[mp], la[mp], h[mp], vh[mp];
int s1[mn], s2[mn], S1[mn], S2[mn];
vector<pair<int, int> > Q;
int n, S(21), T(22), tt, Ans;
void add(int x, int y, int f) {
  E[++tt].y = y, E[tt].f = f, E[tt].l = g[x], g[x] = tt;
  E[++tt].y = x, E[tt].f = 0, E[tt].l = g[y], g[y] = tt;
}
int dfs(int m, int aug) {
  if (m == T) return aug;
  int mh = T, i = la[m];
  do {
    int j = la[m];
    if (E[j].f) {
      if (h[E[j].y] + 1 == h[m]) {
        int tmp = dfs(E[j].y, min(aug, E[j].f));
        if (tmp) return E[j].f -= tmp, E[j ^ 1].f += tmp, tmp;
      }
      if (h[S] >= T) return 0;
      (mh = min(mh, h[E[j].y]));
    }
    la[m] = E[j].l ? E[j].l : g[m];
  } while (i != la[m]);
  if (!--vh[h[m]]) h[S] = T;
  return ++vh[h[m] = mh + 1], 0;
}
int calc() {
  tt = 1, memset(&g, 0, sizeof(g));
  add(1, 11, oo);
  for (int i = 0; i <= 9; ++i) add(S, i + 1, s1[i]), add(i + 11, T, s2[i]);
  for (int i = 0; i <= 9; ++i) add(i + 1, 9 - i + 11, oo);
  int ret = 0;
  memcpy(&la, &g, sizeof(g)), memset(&h, 0, sizeof(h)),
      memset(&vh, 0, sizeof(vh)), vh[0] = T;
  while (h[S] < T) ret += dfs(S, oo);
  return ret;
}
void upd(int Now, int st, int ed) {
  memcpy(&S1, &s1, sizeof(s1)), memcpy(&S2, &s2, sizeof(s2));
  Ans = Now;
  Q.clear();
  while (E[3].f) --S1[0], --S2[0], --E[3].f, Q.push_back(make_pair(0, 0));
  --S1[st], --S2[ed], Q.push_back(make_pair(st, ed));
  for (int i = 0; i <= 9; ++i)
    for (int j = g[i + 1], y = E[j].y; j; j = E[j].l, y = E[j].y)
      if (E[j ^ 1].f && y < S && i + y - 11 == 9)
        for (int k = 1; k <= E[j ^ 1].f; ++k)
          --S1[i], --S2[y - 11], Q.push_back(make_pair(i, y - 11));
  int x = 0, y = 0;
  while (1) {
    while (x < 10 && !S1[x]) ++x;
    while (y < 10 && !S2[y]) ++y;
    if (x > 9 || y > 9) break;
    --S1[x], --S2[y];
    Q.push_back(make_pair(x, y));
  }
}
int main() {
  char ch;
  do {
    if (scanf("%c", &ch) == EOF) break;
    ++s1[ch - '0'], ++s2[ch - '0'];
  } while (ch >= '0' && ch <= '9');
  Ans = s1[0];
  for (int i = 0; i <= 9; ++i)
    for (int j = 1; j <= s1[i]; ++j) Q.push_back(make_pair(i, i));
  for (int i = 1; i <= 9; ++i)
    for (int j = i; j <= 9; ++j)
      if (i + j == 10 && s1[i] && s2[j]) {
        --s1[i], --s2[j];
        int Now = calc() + 1;
        ++s1[i], ++s2[j];
        if (Now > Ans) upd(Now, i, j);
      }
  for (int i = ((int)(Q).size()) - 1; i >= 0; --i) printf("%d", Q[i].first);
  printf("\n");
  for (int i = ((int)(Q).size()) - 1; i >= 0; --i) printf("%d", Q[i].second);
  printf("\n");
}