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

struct node{
     struct node* left;  /* left child  */
     struct node* right; /* right child */
     int val;            /* value       */
};

/* add a new node under this node with the specified value */
void add_to_tree(struct node** node, int num);

/* print the tree, starting from this node */
void print_tree(struct node* node);

/* allocate a new node with this value and return it. can't fail */
struct node* new_node(int num);

int main()
{
     int num = 0;
     struct node* root = NULL; /* the root of the tree */

     while (fscanf(stdin, "%d", &num) == 1)
     {
	  add_to_tree(&root, num);
     }

     print_tree(root);
     return 0;
}

void add_to_tree(struct node** root, int num)
{
     assert (root);

     /* if this node is null, add the new node here */
     if (!*root){
	  *root = new_node(num);
	  return;
     }

     /* ok, it's not null. let's add it below this one */
     /* should it go on the left or on the right? */
     if (num < (*root)->val){
	  add_to_tree(&(*root)->left, num);
     }else if (num > (*root)->val){
	  add_to_tree(&(*root)->right, num);
     }
     /* we intentionally don't handle (nd->val == nul) */
}


void print_tree(struct node* node)
{
     /* check if this is the end of the recursion */
     if (!node)
	  return;

     /* first of all, print anything smaller than us */
     if (node->left){
	  print_tree(node->left);
     }

     /* now print us */
     fprintf(stdout, "%d - ", node->val);

     /* is there anyone bigger than us? print it*/
     if (node->right){
	  print_tree(node->right);
     }
}
	    

/* allocate and initialize a new node. cannot fail */
struct node* 
new_node(int num)
{
     struct node* nd = (struct node*)malloc(sizeof(struct node));
     if (!nd)
	  exit(1);

     memset(nd, 0, sizeof(struct node));

     nd->val = num;
     return nd;
}
