#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <vector>
#include <set>
using namespace std;
int main()
{
istream_iterator<int> in(cin), end;
set<int> abc(in,end);
vector<int> ver;
copy( abc.begin(), abc.end(),
back_inserter(ver) );
copy(abc.begin(), abc.end(),
ostream_iterator<int>(cout, " "));
cout << endl;
copy(ver.rbegin(), ver.rend(),
ostream_iterator<int>(cout, " "));
cout << endl;
system("pause");
return 0;
}