#include <bits/stdc++.h>
using namespace std;
char s[256];
int n, i;
int main()
{
ifstream f("caractere.in");
f.getline(s, sizeof(s));
n = strlen(s);
sort(s, s + n);
for(i = 0; i < n; i ++)
cout << s[i] << " ";
cout << "\n";
reverse(s, s + n);
for(i = 0; i < n; i ++)
cout << s[i] << " ";
return 0;
}