#include <bits/stdc++.h>
using namespace std;
int a[10];
int b[10];
int n;
string s;
int solve(int x, int y) {
  if ((x + y) % 10 != 0) return 0;
  int c[10] = {0};
  int d[10] = {0};
  for (int i = 0; i < 10; i++) {
    c[i] = a[i];
    d[i] = b[i];
  }
  if (c[x] == 0 || d[y] == 0) return 0;
  c[x]--;
  d[y]--;
  int res = 1;
  int ok = 0;
  if (x == 0 && y == 0) {
    ok = 1;
  }
  while (true) {
    int take = 0;
    for (int i = 0; i < 10; i++) {
      int rem = ok + 9 - i;
      if (rem == 10) rem = 0;
      if (i == 0 && rem == 0) continue;
      if (c[i] > 0 && d[rem] > 0) {
        ok = 0;
        res++;
        c[i]--;
        d[rem]--;
        take = 1;
      }
    }
    if (!take) {
      res += min(c[0], d[0]);
      break;
    }
  }
  return res;
}
void solve2(int x, int y) {
  if ((x + y) % 10 != 0) {
    cout << s << "\n" << s << endl;
    return;
  }
  int c[10] = {0};
  int d[10] = {0};
  for (int i = 0; i < 10; i++) {
    c[i] = a[i];
    d[i] = b[i];
  }
  if (c[x] == 0 || d[y] == 0) {
    cout << s << "\n" << s << endl;
    return;
  }
  string R1, R2;
  R1 += char('0' + x);
  R2 += char('0' + y);
  c[x]--;
  d[y]--;
  int res = 1;
  int ok = 0;
  if (x == 0 && y == 0) {
    ok = 1;
  }
  string suf;
  while (true) {
    int take = 0;
    for (int i = 0; i < 10; i++) {
      int rem = ok + 9 - i;
      if (rem == 10) rem = 0;
      if (i == 0 && rem == 0) continue;
      if (c[i] > 0 && d[rem] > 0) {
        ok = 0;
        res++;
        c[i]--;
        d[rem]--;
        R1 += char('0' + i);
        R2 += char('0' + rem);
        take = 1;
      }
    }
    if (!take) {
      res += min(c[0], d[0]);
      int minx = min(c[0], d[0]);
      for (int j = 0; j < minx; j++) {
        suf += '0';
        c[0]--;
        d[0]--;
      }
      for (int j = 0; j < 10; j++) {
        while (c[j] > 0) {
          R1 += char('0' + j);
          c[j]--;
        }
        while (d[j] > 0) {
          R2 += char('0' + j);
          d[j]--;
        }
      }
      reverse(R1.begin(), R1.end());
      reverse(R2.begin(), R2.end());
      break;
    }
  }
  R1 += suf;
  R2 += suf;
  cout << R1 << endl;
  cout << R2 << endl;
  return;
}
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    a[s[i] - '0']++;
    b[s[i] - '0']++;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (ans == solve(i, j)) {
        solve2(i, j);
        return 0;
      }
    }
  }
  return 0;
}
