#include<bits/stdc++.h>
using namespace std;
struct node
{
    int data;
    node* next;
    node( int val)
    {
        data=val;
        next=NULL;
    }
};
node* insertatfront(node* head ,int val)
{
    node * nn= new node(val);
    if(head==NULL)
    {
        head=nn;
        tail =nn;
        
    }
    else
    {
        nn->next=head;
        nn=head;
    }
    return head;
}
node* insertatend(node* head,int val)
{
    node * nn= new node(val);
    if(head=NULL)
    {
        head=nn;
        tail=nn;
    }
    else
    {
        tail->next=nn;
        nn=tail;
    }
    return head;
}
node* insertatrandom(node * head,int val,int pos)
{
    node* nn=new node(val);
    if(head==NULL)
    {
        head=nn;
        tail=nn;
        
    }
    else if(pos==0)
    {
        head= insertatfront(head,val);
        
    }
    else
    {
        node*temp=head;
        for(int i=0;i<pos-1&&current->next!=NULL)
        {
            current=current ->next;
            
        }
        nn->next=current->next;
        current->next=nn;
    }
    
}
void printall(node* head)
{
    node*temp=head;
    while(temp!=NULL)
    {
        cout<<temp->data<<" ";
        temp=temp->next;
    }
}
int main()
{
    int n,val;
    cin>>>n;
    cin>>pos;
    for(int i=0;i,n;i++)
    {
        cin>>val;
        head= insertatfront(head,val);
        
    }
    cin>>val;
    head= insertatfront(head,val);
    cin>>val;
    head= insertatend(head,val);
    cin>>val;
    cin>>pos;
    head= insertatrandom(head,val);
    printall(head);
}