#include
using namespace std;
class node
{
public:
int data;
node* next;
node(int d)
{
data=d;
next=NULL;
}
};
node* head=NULL;
void change(node* head,int k)
{
int count=0;
if (head->next==NULL)
{
cout<data<<" “;
return ;
}
node* temp=head;
node* prev=head;
node* curr=head;
node* naya;
while(temp)
{
count++;
temp=temp->next;
}
for (int i=0;i<count-k;i++)
{
prev=curr;
curr=curr->next;
}
naya=prev->next;
prev->next=NULL;
while(curr->next)
{
curr=curr->next;
}
curr->next=head;
while(naya)
{
cout<data<<” “;
naya=naya->next;
}
}
void kth(node* tempo, int k)
{
node* fast=tempo;
node* slow=tempo;
while(k–>0 && fast)
{
fast=fast->next;
}
while(fast)
{
fast=fast->next;
slow=slow->next;
}
cout<data;
}
int main()
{
node* temp;
int a,x,aa;
cin>>a;
aa=a;
while(aa–)
{
cin>>x;
if (head==NULL)
{
head=new node(x);
temp=head;
}
else
{
temp->next=new node(x);
temp=temp->next;
}
}
int k;
cin>>k;
if (k>=a)
{
while(head)
{
cout<data<<” ";
head=head->next;
}
return 0;
}
node* h=head;
cout<<endl;
change(head,k);
return 0;
}