#include <bits/stdc++.h>
using namespace std;
char line[131072];
int cnt[11];
int tc1[11];
int tc2[11];
int use[11];
int n;
int p1[131072];
int p2[131072];
int best1[131072];
int best2[131072];
bool cmp(int x, int y) { return x > y; }
int findout(int num) {
  if (cnt[num] == 0 || cnt[10 - num] == 0) return 0;
  int ans = 1;
  memcpy(tc1, cnt, 44);
  memcpy(tc2, cnt, 44);
  tc1[num]--;
  tc2[10 - num]--;
  for (int i = 0; i < 10; i++) {
    use[i] = min(tc1[i], tc2[9 - i]);
    ans += use[i] * 2;
  }
  ans += tc1[0] - max(use[0], use[9]);
  int now = n;
  for (int i = 0; i < tc1[0] - max(use[0], use[9]); i++)
    p1[now - i] = p2[now - i] = 0;
  now -= tc1[0] - max(use[0], use[9]);
  p1[now] = num, p2[now] = 10 - num;
  now--;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < use[i]; j++) p1[now - j] = i, p2[now - j] = 9 - i;
    now -= use[i];
  }
  int bnow = now;
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j < tc1[i] - use[i]; j++) p1[now - j] = i;
    now -= tc1[i] - use[i];
  }
  now = bnow;
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j < tc2[i] - use[9 - i]; j++) p2[now - j] = i;
    now -= tc2[i] - use[9 - i];
  }
  return ans;
}
int main() {
  memset(cnt, 0, sizeof(cnt));
  gets(line + 1);
  n = strlen(line + 1);
  for (int i = 1; i <= n; i++) cnt[line[i] - 48]++;
  int ans = 0;
  for (int i = 1; i <= n; i++) best1[i] = best2[i] = line[i] - 48;
  sort(best1 + 1, best1 + 1 + n, cmp);
  sort(best2 + 1, best2 + 1 + n, cmp);
  for (int i = 1; i <= 5; i++) {
    int tmp = findout(i);
    if (tmp > ans) {
      ans = tmp;
      memcpy(best1, p1, sizeof(p1));
      memcpy(best2, p2, sizeof(p2));
    }
  }
  for (int i = 1; i <= n; i++) printf("%d", best1[i]);
  printf("\n");
  for (int i = 1; i <= n; i++) printf("%d", best2[i]);
  printf("\n");
  return 0;
}
