#include <bits/stdc++.h>
using namespace std;
string s;
int A[10];
int B[10];
int Acopy[10];
int Bcopy[10];
int solve() {
  for (int i = 0; i < 10; i++) {
    Acopy[i] = A[i];
    Bcopy[i] = B[i];
  }
  int res = 0;
  for (int i = 0; i < 10; i++) {
    int mx = min(Acopy[i], Bcopy[10 - i - 1]);
    res += mx;
    Acopy[i] -= mx;
    Bcopy[10 - i - 1] -= mx;
  }
  return res + min(Acopy[0], Bcopy[0]);
}
void make_answer(int u) {
  vector<int> a;
  vector<int> b;
  if (A[u] > 0) {
    a.push_back(u);
    A[u]--;
  }
  if (B[(10 - u) % 10] > 0) {
    b.push_back((10 - u) % 10);
    B[(10 - u) % 10]--;
  }
  for (int i = 0; i < 10; i++) {
    int mx = min(A[i], B[10 - i - 1]);
    for (int j = 0; j < mx; j++) {
      a.push_back(i);
      b.push_back(10 - i - 1);
    }
    A[i] -= mx;
    B[10 - i - 1] -= mx;
  }
  int maxnull = min(A[0], B[0]);
  A[0] -= maxnull;
  B[0] -= maxnull;
  for (int t1 = 0; t1 < 10;) {
    for (; A[t1] > 0; A[t1]--) cout << t1;
    t1++;
  }
  for (int i = int(a.size()) - 1; i >= 0; i--) cout << a[i];
  for (int i = 0; i < maxnull; i++) cout << 0;
  cout << endl;
  for (int t1 = 0; t1 < 10;) {
    for (; B[t1] > 0; B[t1]--) cout << t1;
    t1++;
  }
  for (int i = int(b.size()) - 1; i >= 0; i--) cout << b[i];
  for (int i = 0; i < maxnull; i++) cout << 0;
  cout << endl;
}
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    A[s[i] - '0']++;
    B[s[i] - '0']++;
  }
  int maxi = -2147483647;
  int maxinum = -1;
  for (int i = 1; i <= 9; i++) {
    if (A[i] > 0 && A[10 - i] > 0) {
      A[i]--;
      B[(10 - i) % 10]--;
      int sl = solve();
      if (sl > maxi) {
        maxi = sl;
        maxinum = i;
      }
      A[i]++;
      B[(10 - i) % 10]++;
    }
  }
  int maxnull = min(A[0], B[0]);
  if (maxinum == -1) {
    for (int t1 = 1; t1 < 10;) {
      for (; A[t1] > 0; A[t1]--) cout << t1;
      t1++;
    }
    for (int i = 0; i < maxnull; i++) cout << 0;
    cout << endl;
    for (int t1 = 1; t1 < 10;) {
      for (; B[t1] > 0; B[t1]--) cout << t1;
      t1++;
    }
    for (int i = 0; i < maxnull; i++) cout << 0;
    cout << endl;
    return 0;
  }
  make_answer(maxinum);
  return 0;
}
