#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
	char *s;
	struct node *next;
	struct node *lesser, *greater;
};

static void print(const struct node *np)
{
	if (!np)
		return;
	print(np->lesser);
	for (const struct node *ptr = np; ptr; ptr = ptr->next)
		fputs(ptr->s, stdout);
	print(np->greater);
}

static struct node *install(struct node **tree, struct node *np)
{
	int t;

	np->greater = np->lesser = 0;
	while (*tree) {
		if (!(t = strcmp(np->s, (*tree)->s)))
			return *tree;
		tree = t < 0 ? &(*tree)->lesser : &(*tree)->greater;
	}
	*tree = np;
	return 0;
}

static struct node *new(const char *s)
{
	struct node *np;

	if (!(np = malloc(sizeof *np)) || !(np->s = malloc(strlen(s) + 1)))
		exit(EXIT_FAILURE);
	strcpy(np->s, s);
	np->next = 0;
	return np;
}

int main(void)
{
	struct node *tree = 0, *np, *nt;
	char buf[8192];

	while (fgets(buf, sizeof buf, stdin))
		if ((np = install(&tree, nt = new(buf)))) {
			nt->next = np->next;	// Handle collision
			np->next = nt;
		}
	print(tree);
	return 0;
}