#include<stdio.h>
#include<stdlib.h>
typedef struct TreeNode{
    int data;
    struct TreeNode *left;
    struct TreeNode *right;
}Node;
Node *root=NULL;
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(root->data<num){
        root->left=insertBST(root->left,num);
    }
    else
        root->right=insertBST(root->right,val);
    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;
}