#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
double EPS = 1e-8;
string x, y;
vector<int> a, b, ca, cb;
bool carry(int c) {
  for (int i = 0; i < 10; ++i)
    if (a[i] && b[10 - c - i]) {
      x += i + '0';
      a[i]--;
      y += 10 - c - i + '0';
      b[10 - c - i]--;
      return true;
    }
  return false;
}
int solve(string s, int z) {
  x = y = "";
  a = ca, b = cb;
  int r = 0;
  if (a[z] && b[10 - z]) {
    x += z + '0';
    a[z]--;
    y += 10 - z + '0';
    b[10 - z]--;
    r++;
    while (carry(1)) r++;
  }
  int t = min(a[0], b[0]);
  x += string(a[0] - t, 0 + '0');
  y += string(b[0] - t, 0 + '0');
  for (int i = 1; i < 10; ++i) {
    x += string(a[i], i + '0');
    y += string(b[i], i + '0');
  }
  reverse((x).begin(), (x).end()), reverse((y).begin(), (y).end());
  x += string(t, '0');
  y += string(t, '0');
  return r;
}
void init(string &s) {
  ca.clear();
  ca.resize(10, 0);
  cb.clear();
  cb.resize(10, 0);
  for (int i = 0; i < (int)((s).size()); ++i) {
    ca[s[i] - '0'] = cb[s[i] - '0'] = ca[s[i] - '0'] + 1;
  }
}
int main() {
  string s;
  cin >> s;
  string r0 = s, r1 = s;
  int m = -1;
  init(s);
  for (int i = 1; i < 10; ++i) {
    int t = solve(s, i);
    if (t > m) {
      m = t;
      r0 = x;
      r1 = y;
    }
  }
  cout << r0 << endl << r1 << endl;
  return 0;
}
