#include <bits/stdc++.h>
using namespace std;
long long int wari(long long int a, long long int b) {
  long long int res = (long long int)a / b;
  if (a % b != 0) res++;
  return res;
}
bool vow(char a) {
  if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
    return true;
  else
    return false;
}
bool rsm(string a, string b, long long int k) {
  long long int aa = ((long long int)(a).size()),
                bb = ((long long int)(b).size());
  long long int count = 0;
  for (long long int i = 1; i < min(aa, bb) + 1; i++) {
    if (a[aa - i] != b[bb - i]) break;
    if (vow(a[aa - i])) count++;
    if (count >= k) return true;
  }
  return false;
}
long long int num(vector<int> a) {
  long long int res = 0;
  long long int n = ((long long int)(a).size());
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    res += a[i];
    res *= 10;
  }
  return res / 10;
}
int ju(long long int a) {
  if (a % 100000 == 0) return 5;
  if (a % 10000 == 0) return 4;
  if (a % 1000 == 0) return 3;
  if (a % 100 == 0) return 2;
  if (a % 10 == 0)
    return 1;
  else
    return 0;
}
int keta(long long int a) {
  if (a / 100000) return 6;
  if (a / 10000) return 5;
  if (a / 1000) return 4;
  if (a / 100) return 3;
  if (a / 10)
    return 2;
  else
    return 1;
}
int aatoi(char a) { return a - '0'; }
void print_num(long long int a, long long int b) {
  long long int ju = 1;
  long long int n = b;
  for (long long int i = (long long int)(1); i < ((long long int)(b)); i++) {
    ju *= 10;
  }
  while (n-- > 0) {
    cout << a / ju;
    a %= ju;
    ju /= 10;
  }
  puts("");
  return;
}
void acp(long long int a[], long long int b[], long long int n) {
  for (long long int i = 0; i < ((long long int)(n)); i++) a[i] = b[i];
  return;
}
long long int max9(long long int a[], long long int num) {
  long long int b[10];
  long long int res = 0, cd;
  acp(b, a, 10);
  a[num + 1]--;
  b[9 - num]--;
  for (long long int i = 0; i < ((long long int)(10)); i++) {
    cd = min(a[i], b[9 - i]);
    if (cd > 0) {
      res += cd;
      a[i] -= cd;
      b[9 - i] -= cd;
    }
  }
  return res;
}
int main() {
  long long int count[10] = {0}, tmp[10];
  long long int res = 0, rr, cd, now;
  string in;
  cin >> in;
  long long int n = ((long long int)(in).size());
  long long int ii = -1, jj = 0;
  short a[100000] = {0}, b[100000] = {0};
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    count[aatoi(in[i])]++;
  }
  for (long long int i = 0; i < ((long long int)(5)); i++) {
    if (count[i + 1] == 0 || count[9 - i] == 0)
      ;
    else {
      for (long long int j = 0;
           j < ((long long int)(min(count[0], count[9]) + 1)); j++) {
        acp(tmp, count, 10);
        rr = 1;
        rr += tmp[0] - j;
        tmp[0] = j;
        rr += max9(tmp, i);
        if (rr > res) {
          ii = i;
          jj = j;
          res = rr;
        }
      }
    }
  }
  acp(tmp, count, 10);
  if (res != 0) {
    for (long long int i = 0; i < ((long long int)(count[0] - jj)); i++) {
      a[n - i] = 0;
      b[n - i] = 0;
    }
    a[n - count[0] + jj - 1] = ii + 1;
    b[n - count[0] + jj - 1] = 9 - ii;
    now = n - count[0] + jj - 2;
    tmp[0] = jj;
    count[0] = jj;
    tmp[ii + 1]--;
    count[9 - ii]--;
    for (long long int i = 0; i < ((long long int)(10)); i++) {
      cd = min(tmp[i], count[9 - i]);
      if (cd > 0) {
        for (long long int j = 0; j < ((long long int)(cd)); j++) {
          a[now] = i;
          b[now] = 9 - i;
          now--;
        }
        tmp[i] -= cd;
        count[9 - i] -= cd;
      }
    }
  }
  now = 0;
  for (long long int i = 0; i < ((long long int)(10)); i++) {
    if (tmp[9 - i] > 0) {
      for (long long int j = 0; j < ((long long int)(tmp[9 - i])); j++) {
        a[now] = 9 - i;
        now++;
      }
      tmp[9 - i] = 0;
    }
  }
  now = 0;
  for (long long int i = 0; i < ((long long int)(10)); i++) {
    if (count[9 - i] > 0) {
      for (long long int j = 0; j < ((long long int)(count[9 - i])); j++) {
        b[now] = 9 - i;
        now++;
      }
      count[9 - i] = 0;
    }
  }
  for (long long int i = 0; i < ((long long int)(n)); i++) cout << a[i];
  puts("");
  for (long long int i = 0; i < ((long long int)(n)); i++) cout << b[i];
  puts("");
  return 0;
}
