#include "iostream"
#include "string"
using namespace std;
typedef struct node{
string data;
struct node *next;
node(string str){
data=str;
next=NULL;
}
}Node;
Node *head=new node("hfirst");
Node *back=new node("bfirst");
Node *current=NULL;
Node *pre=head;
void add(string str){
Node *temp;
if(back->data=="bfirst")
temp=new Node(str);
else{
temp=back->next;
back->next=temp->next;
temp->data=str;
temp->next=NULL;
}
temp->next=head->next;
head->next=temp;
current=temp;
}
void move(int p){
int i=;
for(;i<p;i++){
pre=current;
if(current==NULL){
cout<<"worng!!!"<<endl;
current=head->next;
pre=head;
break;
}
else
current=current->next;
}
}
void del(int i){
Node *temp=current;
Node*tp;
while(i!=&¤t!=NULL){
tp=current;
current=current->next;
i--;
}
if(current==NULL){
back->next=pre->next;
pre->next=NULL;
pre=head;
current=head->next;
}
else{
pre->next=current;
tp->next=NULL;
temp->next=back->next;
back->next=temp;
}
}
void _print(){
cout<<current->data;
}
void main(){
string choice,str;
int i;
while(){
cin>>choice;
if (choice==("ADD")){cin>>str;add(str);}
if (choice==("MOVE")){cin>>i;move(i);}
if (choice==("DEL")){cin>>i;del(i);}
if (choice==("PRINT"))_print();
}
getchar();
}