#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable : 4996)
#define BUFFER_LENGTH 1024

typedef struct LS {
	struct LS *Previous;
	char *String;
} LinkedString;

int main(){
	char input[BUFFER_LENGTH];
	int lineCount = 0;
	LinkedString *ls, *previous = NULL;
	
	while(NULL != gets(input)) {
		ls = (LinkedString *) malloc(sizeof(LinkedString));
		ls->Previous = previous;
		ls->String = (char *) malloc(sizeof(char) * (strlen(input) + 1));
		strcpy(ls->String, input);
		previous = ls;
		lineCount++;
	}

	LinkedString **allData = (LinkedString **) malloc(sizeof(LinkedString *) * lineCount);
	
	for (int i = lineCount - 1; i >= 0; i--){
		allData[i] = ls;
		ls = ls->Previous;
	}
	
	for (int i = 0; i < lineCount; i++){
		for (int j = i + 1; j < lineCount ; j++){
			if ( 0 < strcmp(
				allData[i]->String, allData[j]->String)){
					LinkedString *forswap = allData[i];
					allData[i] = allData[j];
					allData[j] = forswap;
			}
		}
	}
	
	for(int i = 0; i < lineCount; i++){
		printf("%s\n", allData[i]->String);
	}
	
	for(int i = 0; i < lineCount; i++){
		free(allData[i]->String);
		free(allData[i]);
	}
	free(allData);

	return 0;
}