#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
int ihash[2][20];
int a[2][M];
int bhash[2][20];
int main() {
  string s;
  cin >> s;
  int len = s.length();
  for (int i = 0; i < len; i++) {
    int num = s[i] - '0';
    for (int j = 0; j < 2; j++) {
      ihash[j][num]++;
      bhash[j][num]++;
    }
  }
  int maxv = -1;
  int last0 = -1;
  int last10 = -1;
  for (int ilast0 = 0; ilast0 <= bhash[0][0]; ilast0++) {
    for (int j = 0; j <= 9; j++) {
      ihash[0][j] = bhash[0][j];
      ihash[1][j] = bhash[1][j];
    }
    int num = 0;
    ihash[0][0] -= ilast0;
    ihash[1][0] -= ilast0;
    num += ilast0;
    for (int i = 1; i <= 9; i++) {
      int inum = 0;
      if (ihash[0][i] > 0 && ihash[1][10 - i] > 0) {
        ihash[0][i]--;
        ihash[1][10 - i]--;
        inum++;
        for (int j = 0; j <= 9; j++) {
          int tmp = min(ihash[0][j], ihash[1][9 - j]);
          inum += tmp;
        }
        ihash[0][i]++;
        ihash[1][10 - i]++;
      }
      if (num + inum > maxv) {
        maxv = num + inum;
        last0 = ilast0;
        if (inum > 0) {
          last10 = i;
        }
      }
    }
  }
  for (int j = 0; j <= 9; j++) {
    ihash[0][j] = bhash[0][j];
    ihash[1][j] = bhash[1][j];
  }
  int id = len - 1;
  for (int i = 0; i < last0; i++) {
    a[0][id] = 0;
    a[1][id] = 0;
    id--;
  }
  ihash[0][0] -= last0;
  ihash[1][0] -= last0;
  if (last10 != -1) {
    a[0][id] = last10;
    a[1][id] = 10 - last10;
    id--;
    ihash[0][last10]--;
    ihash[1][10 - last10]--;
  }
  for (int i = 0; i <= 9; i++) {
    int tmp = min(ihash[0][i], ihash[1][9 - i]);
    for (int j = 0; j < tmp; j++) {
      a[0][id] = i;
      a[1][id] = 9 - i;
      id--;
    }
    ihash[0][i] -= tmp;
    ihash[1][9 - i] -= tmp;
  }
  int id2 = id;
  for (int k = 0; k < 2; k++) {
    id = id2;
    for (int i = 0; i <= 9; i++) {
      for (int j = 0; j < ihash[k][i]; j++) {
        a[k][id] = i;
        id--;
      }
    }
  }
  for (int k = 0; k < 2; k++) {
    for (int i = 0; i < len; i++) {
      cout << a[k][i];
    }
    cout << endl;
  }
  return 0;
}
