#include <iostream>
#include <cstdio>
#include <stdlib.h>

using namespace std;

int compare (const void * a, const void * b)
{
  return ( *(int*)b - *(int*)a );
}

int main()
{
    int a[5];

    for(int i = 0; i < 5; i++) {
        scanf("%d", &a[i]);

        if (i != 4)
            printf(" ");
        
        else
            printf("\n");
    }  

    printf("\n");

    qsort (a, 5, sizeof(int), compare);

    for (int i = 0; i < 5; i++) {
        printf ("%d",a[i]);

        if (i != 4)
            printf(" ");
        
        else
            printf("\n");
    }

    return 0;
}