#include<iostream.h>
#include<conio.h>
#include<malloc.h>
struct node
{
char str[20];
struct node *next;
struct node *Prev;
};
struct node *nod,*first,*last,*pre;
void main()
{
int a,n,i;
clrscr();
nod=first=last=pre=(struct node*)NULL;
cout<<"Enter the number"<<endl;
cin>>n;
nod=(struct node*) malloc(sizeof(struct node));
first=nod;
for(i=0;i<n;i++)
{
last = nod;
last->next=nod;
nod=(struct node*) malloc(sizeof(struct node));
pre=nod;
pre->Prev=last->next;
cin>>nod->str;
}
nod=pre;
for(i=0;i<n;i++)
{
cout<<nod->str<<endl;
nod=nod->Prev;
}
getch();
}