#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[100001];
  scanf("%s", a);
  int c[10] = {0}, sz = strlen(a);
  for (int i = 0; i < sz; i++) c[a[i] - '0']++;
  int res = 0, z = 0;
  vector<int> v1, v2;
  for (int s = 1; s <= 5; s++) {
    int t = 10 - s;
    int c1[10], c2[10];
    for (int i = 0; i < 10; i++) c1[i] = c2[i] = c[i];
    int r = 0;
    vector<int> vv1, vv2;
    if (c1[s] > 0 && c2[t] > 0) {
      c1[s]--;
      c2[t]--;
      r = 1;
      vv1.push_back(s);
      vv2.push_back(t);
    } else
      continue;
    for (int i = 0; i <= 9; i++) {
      int b = min(c1[i], c2[9 - i]);
      c1[i] -= b;
      c2[9 - i] -= b;
      r += b;
      for (; b; b--) {
        vv1.push_back(i);
        vv2.push_back(9 - i);
      }
    }
    int zz = min(c1[0], c2[0]);
    c1[0] -= zz;
    c2[0] -= zz;
    for (int i = 0; i < 10; i++) {
      for (; c1[i]; c1[i]--) vv1.push_back(i);
      for (; c2[i]; c2[i]--) vv2.push_back(i);
    }
    if (res < r) {
      res = r;
      z = zz;
      v1 = vv1;
      v2 = vv2;
    }
  }
  if (res == 0) {
    for (int k = 0; k < 2; k++) {
      for (int i = 9; i >= 0; i--)
        for (int j = 0; j < c[i]; j++) printf("%d", i);
      printf("\n");
    }
  } else {
    for (int i = v1.size() - 1; i >= 0; i--) printf("%d", v1[i]);
    for (int i = 0; i < z; i++) printf("0");
    printf("\n");
    for (int i = v2.size() - 1; i >= 0; i--) printf("%d", v2[i]);
    for (int i = 0; i < z; i++) printf("0");
    printf("\n");
  }
  return 0;
}
