#include <bits/stdc++.h>
using namespace std;
template <class T>
void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
void out(vector<T> A, int n = -1) {
  if (n == -1) n = ((int)A.size());
  if (n > ((int)A.size())) n = ((int)A.size());
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
template <class T>
void out(T A[], int n) {
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
string tostring(int v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
string tostring(long long v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
int low(int i) { return i & -i; }
int countbit(int i) { return (i == 0) ? 0 : (1 + countbit(i - low(i))); }
int toint(string s) {
  istringstream sin(s);
  int t;
  sin >> t;
  return t;
}
long long toint64(string s) {
  istringstream sin(s);
  long long t;
  sin >> t;
  return t;
}
const double pi = acos(-1.);
const double eps = 1e-11;
string s;
int a[200005], b[200005], f[200005], g[200005];
int main() {
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) a[(int)(s[i] - '0')]++, b[(int)(s[i] - '0')]++;
  int max = -1, last = 0, haha = 0;
  for (int k = 0; k <= a[0]; k++) {
    a[0] -= k;
    b[0] -= k;
    for (int i = 1; i < 10; i++)
      if (a[i] > 0 && b[10 - i] > 0) {
        a[i]--;
        b[10 - i]--;
        int t = k;
        for (int j = 0; j <= 9; j++) t += min(a[j], b[9 - j]);
        if (t > max) {
          max = t;
          last = i;
          haha = k;
        }
        a[i]++;
        b[10 - i]++;
      }
    a[0] += k;
    b[0] += k;
  }
  if (last == 0) {
    for (int i = 9; i >= 0; i--)
      while (a[i]) printf("%d", i), a[i]--;
    printf("\n");
    for (int i = 9; i >= 0; i--)
      while (b[i]) printf("%d", i), b[i]--;
    printf("\n");
  } else {
    int tot = 0;
    while (a[0]) {
      if (tot == haha) break;
      tot++, f[tot] = 0, g[tot] = 0, a[0]--, b[0]--;
    }
    tot++;
    f[tot] = last;
    g[tot] = 10 - last;
    a[last]--;
    b[10 - last]--;
    for (int j = 0; j <= 9; j++) {
      while (min(a[j], b[9 - j]) > 0) {
        tot++;
        f[tot] = j;
        g[tot] = 9 - j;
        a[j]--;
        b[9 - j]--;
      }
    }
    int t1 = tot, t2 = tot;
    for (int j = 0; j <= 9; j++) {
      while (a[j]) t1++, f[t1] = j, a[j]--;
      while (b[j]) t2++, g[t2] = j, b[j]--;
    }
    for (int i = n; i > 0; i--) printf("%d", f[i]);
    printf("\n");
    for (int i = n; i > 0; i--) printf("%d", g[i]);
    printf("\n");
  }
  return 0;
}
