#include "iostream"
using namespace std;
typedef struct da
{
int num;
struct da *left,*right;
}dat,*data;
data build(data temp)
{
int i = 0;
cin>>i;
if(i == 886)
temp = NULL;
else
{
temp = new dat;
temp ->num = i;
temp ->left = build(temp ->left);
temp ->right = build(temp ->right);
}
return temp;
}
void put(data top)
{
if(top)
{
cout<<top ->num<<' ';
put(top -> left);
put(top -> right);
}
}
int main()
{
data top = NULL;
top = build(top);
put(top);
cout<<endl;
getchar();
getchar();
return 0;
}