#include<stdio.h>
typedef struct TreeNode{
    int data;
    struct TreeNode *left;
    struct TreeNode *right;
}Node;
Node *create(int num){
    Node *newnode=(node*)malloc(sizeof(node));
    newnode->data=num;
    newnode->left=newnode->right=NULL;
    return newnode;
}
Node *insertBST(Node *root,int num){
    if(root==NULL)return create(num);
    if(rroot->data<num){
        root->left=insertBST(root->left,num);
    }
    else
        root-right=insertBST(root->right,num);
    return root;
}
void sort(Node *root){
    if(root!=NULL){
        sort(root->left);
        printf("%d ",root->data);
        sort(root->right);
    }
}
int main(){
    int size,val,num;
    scanf("%d",&size);
    scanf("%d",&val);
    for(int i=0;i<size;i++){
        scanf("%d",&num);
        root=insertBST(root,val);
        sort(root);
    }
    return 0;
}