#include <stdio.h>
#include <stdlib.h>
struct node 
{
    int data;
    struct node *next;
};

// write your code here......

int main() {

    int n,i;
    scanf("%d%d",&n,&i);
    struct node *head=(struct node *)malloc(sizeof(struct node));
    if(head==NULL)
    exit(1);
    head->next=NULL;
    struct node *box=head;
    for(int j=0;j<n;j++)
    {
        struct node *p=(struct node *)malloc(sizeof(struct node));
        if(p==NULL)
        exit(1);
        p->next=NULL;
        scanf("%d",&p->data);
        box->next=p;
        box=box->next;

    }
    box=head->next;
    struct node *t=box->next;
    for(int k=2;k<=i;k++)
    {
        box=box->next;
        t=t->next;
    }
    struct node *pp=(struct node *)malloc(sizeof(struct node));
    if(pp==NULL)
    exit(1);
    pp->data=i;
    box->next=pp;
    pp->next=t;
    box=head->next;
    while(box!=NULL)
    {
        printf("%d ",box->data);
        box=box->next;
    }
    return 0;
}