#include
using namespace std;
class node
{
public:
int data;
nodenext;
node(int d)
{
data=d;
next=NULL;
}
};
void insert_head(node&head,int data)
{
noden=new node(data);
n->next=head;
head=n;
}
void insert_last(node&head,int data)
{ if(head==NULL)
{
insert_head(head,data);
}
else{
node*temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
node*n=new node(data);
n->next=temp->next;
temp->next=n;
}
}
void print_li(nodehead)
{
while(head!=NULL)
{
cout<data<<",";
head=head->next;
}
}
void build_li(node&head,int n)
{
while(n>0)
{ int data;
cin>>data;
insert_last(head,data);
n–;
}
}
nodereverse_k(node&head,int k)
{
nodec=head;
nodep=NULL;
noden;
int count=0;
while(c!=NULL && count<k)
{
n=c->next;
c->next=p;
p=c;
c=n;
count++;
}
if(n!=NULL)
head->next=reverse_k(n,k);
return p;
}
int main()
{
nodehead=NULL;
int n,k;
cin>>n>>k;
build_li(head,n);
head=reverse_k(head,k);
print_li(head);
}