int i,n,m,t;
struct stu
{
	char num[1000];
	struct stu *next;
};

struct stu *creat(void)
{
	struct stu *head;
	struct stu *p1,*p2;
	n=0;
	p1=p2=(struct stu *)malloc(len);
	gets(p1->num);
	while(strcmp(p1->num,"end")!=0)
	{
		n=n+1;
		if(n==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct stu *)malloc(len);
		gets(p1->num);
	}
	p2->next=NULL;
	return (head);
}

void print(struct stu *head)
{
	struct stu *p1,*p2;
	m=n;
	t=n;
	for(i=1;n>0;i++)
	{
		while(n>0)
		{
			if(n==t) p2=p1=head;
			else p2=p1;
			p1=p1->next;
			n=n-1;
		}
		printf("%s\n",p2->num);
		n=m-i;
		t=n;
	}
}

void main()
{
	struct stu *head;
	head=creat();
	print(head);
}


struct student
{
	char num[30];
	char name[30];
	char sex;
	int age;
	char score[20];
	char add[30];
	struct student *next;
};
int main()
{
	struct student *p,*p1;
	int n=0;
	p=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %s %s",p->num,p->name,&p->sex,&p->age,p->score,p->add);
	//printf("%s %s %c %d %f %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
//printf("%c\n",p->num[0]);
	while(1)
	{
		n++;
		if(n==1) p->next=NULL;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
		//printf("%s\n",p1->num);
		if(strcmp(p1->num,"end")==0) break;
		else scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
		//printf("%s %s %c %d %f %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1->next=p;
		p=p1;
		//printf("%d\n",n);
	}
	//printf("%d\n",n);
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}
	return 0;
}


struct stu
	{char id[100];
	char name[100];
	char sex[3];
	char age[10];
	char score[10];
	char add[100];
	struct stu *next;
	};

int main()
{
	int k,m,n,t,ans,ii,i,j,jj,flag;
	struct stu *p0,*p1,*p2,*head;
	char s[30];
	p1 = (struct stu*)malloc(LEN);
	scanf("%s%s%s%s%s%s",p1->id,p1->name,p1->sex,&p1->age,&p1->score,p1->add);
	p1->next = NULL;
	head = p1;
	p2 = p1;
	while (1)
	{
		p1 = (struct stu*)malloc(LEN);
		scanf("%s",p1->id);
		if (strcmp(p1->id,"end")==0)
		{
			head = p2;
			break;
		}
		scanf("%s%s%s%s%s",p1->name,p1->sex,&p1->age,&p1->score,p1->add);
		p1->next = p2;
		p2 = p1;
	}

	p1 = head;
	while (p1->next!=NULL)
	{
		printf("%s %s %s %s %s %s\n",p1->id,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1 = p1->next;
	}
	printf("%s %s %s %s %s %s",p1->id,p1->name,p1->sex,p1->age,p1->score,p1->add);
	return 0;
}


struct student
{
    char number[100];
    char name[100];
    char sex;
    int age;
    char score[100];
    char address[100];
    struct student *prev;
    struct student *next;
};
int main()
{
    struct student *phead,*p,*q;
    char m[10];
    phead=(struct student*)malloc(sizeof(struct student));
    phead->prev=NULL;
    scanf("%s",m);
    q=phead;
    do
    {
        p=(struct student*)malloc(sizeof(struct student));
        strcpy(p->number, m);
        scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,&p->score,p->address);
        p->prev=q;
        q->next=p;
        q=q->next;
        scanf("%s",m);
    } while (strcmp(m,"end")!=0);
    q->next=NULL;
    p=phead;
    while (p->next!=NULL) p=p->next;
    while (p!=phead)
    {
        printf("%s %s %c %d %s %s\n",p->number,p->name,p->sex,p->age,p->score,p->address);
        p=p->prev;
    }
}


struct student
{
	char str[100];
	struct student *next;
};
int n;
char end[5]="end";

struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	gets(p1->str);
	head=null;
	while(strcmp(p1->str,end)!=0)
	{
		n=n+1;
		if(n==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		gets(p1->str);
	}
	p2->next=null;
	return(head);
}

void main()
{
	struct student *p1,*p2,*p3,*head;
	head=creat();
	p1=head;
	p2=p1->next;
	p3=p2->next;
	while(p3!=null)
	{
		p2->next=p1;
		p1=p2;
		p2=p3;
		p3=p2->next;
	}
	p2->next=p1;
	head->next=null;
	do
	{
		printf("%s\n",p2->str);
		p2=p2->next;
	}
	while(p2!=null);
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[50];
	char add[20];
	struct student *before;
};

struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=(struct student* )malloc(len);
	p1->before=NULL;
	p2=p1;
	do
	{
		scanf("%s",p1->num);
		if(p1->num[0]=='e')
		{
			head=p2;
			free(p1);
	        return(head);
		}
		else
		{
			scanf("%s %c %d %s",p1->name,&p1->sex,&p1->age,p1->score);
		    scanf("%s",p1->add);
			p2=p1;
			p1=(struct student*)malloc(len);
			p1->before=p2;
		}
	}
	while(1);
}
void main()
{
	struct student *head1=creat();
	struct student *q=head1;
	while(q!=NULL)
	{	printf("%s %s %c %d %s %s\n",q->num,q->name,q->sex,q->age,q->score,q->add);
	    q=q->before;
	}
}


int n;
struct student
{
	char a[30];
	char name[20];
	char sex[20];
	char age[20];
	char score[20];
	char addr[30];
	struct student *next;
}

 *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
    n=0;
	p1=p2=(struct student*) malloc(len);
	scanf("%s%s%s%s%s%s",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr);
	head=NULL;
	while(strcmp(p1->a,"end")!=0)
	{  n++;
	   if (n==1) p1->next=NULL;
	   else
	   p1->next=p2;
	   head=p1;
	   p2=p1;
	   p1=(struct student*)malloc(len);
	   scanf("%s%s%s%s%s%s",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr);
	}
	return(head);
}
void print(struct student*head)
{
	struct student *p1;
	p1=head;
	if(head!=NULL)
		 do
		 {
			 printf("%s %s %s %s %s %s\n",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr);
			 p1=p1->next;
		 }while(p1!=NULL);
}
main()
{
	struct student *head;
	head=creat();
	print(head);
}


struct student
{
	char number[20];
	char name[20];
	char sex;
	int age;
	float grade;
	char address[20];
	struct student *next;
};
int n;
struct student *creat(void)
{
	struct student *head,*p1,*p2;
	head=p1=p2=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %f %s",p1->number,p1->name,&p1->sex,&p1->age,&p1->grade,p1->address);
    p2->next=NULL;
	for(n=0;;n++)
	{
		p1=(struct student *)malloc(LEN);
		p1->next=p2;
		scanf("%s",p1->number);
		if(strcmp(p1->number,"end")==0)break;
		scanf("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->grade,p1->address);
		p2=p1;
		head=p1;
	}return head;
}
void main()
{
	struct student *head,*p;
	head=creat();
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->number,p->name,p->sex,p->age,p->grade,p->address);
		p=p->next;
	}
}


struct student
{
       char information[50];
       struct student *next;
};

int main()
{
    struct student *create_and_reverse();
    void print(struct student *head);
    struct student *head;
    head=create_and_reverse();
    print(head);
    return 0;
}

struct student *create_and_reverse()
{
       struct student *p1,*p2,*head;
       char end[50]={'e','n','d'};
       p1=(struct student *)malloc(len);
       p2=p1;

       gets((p1->information));
       for(;;)
       {
              p1=(struct student *)malloc(len);
              gets((p1->information));
              if(strcmp(p1->information,end))
              {
                                             (p1->next)=p2;
              }
              else
              {
                  head=p2;
                  break;
              }
              p2=p1;
       }
       return (head);
}

void print(struct student *head)
{
     struct student *p;
     p=head;
     for(;;)
     {
                           printf("%s\n",p->information);
                           if((p->next)==NULL)
                           {
                                              break;
                           }
                           else
                           {
                               p=(p->next);
                           }
     }
}


int n=0;
struct student
{
	char num[20];
	char name[20];
	char sex;
	char age[20];
	char score[20];
	char ad[20];
	struct student *next;
};
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	head=NULL;
	scanf("%s ",p1->num);
	if(p1->num[0]=='e')
		return(head);
	scanf("%s %c %s %s %s",p1->name,&p1->sex,p1->age,p1->score,p1->ad);
	p1->next=NULL;
	for(;;)
	{
		n=n+1;
		head=p1;
		if(n>1)
			p1->next=p2;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0)
		{
			p1=NULL;
			break;
		}
		scanf("%s %c %s %s %s",p1->name,&p1->sex,p1->age,p1->score,p1->ad);
	}
	return(head);
}
void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s %s %c %s %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->ad);
			p=p->next;
		}while(p!=NULL);
}
void main()
{
	struct student *head;
	head=creat();
	print(head);
}


struct student
{
	char num[12];
	char name[25];
	char sex;
	int age;
	char score[6];
	char add[12];
}stu[max];
int main()
{
	int i,n,j;
	for(i=0;;i++)
	{
		scanf("%s",stu[i].num);
		if(stu[i].num[0]=='e')
		{
			break;
		}
		else
		scanf("%s %c %d %s %s",stu[i].name,&stu[i].sex,&stu[i].age,stu[i].score,stu[i].add);
	}
	if(i==0)
		printf("\n");
	else
	{
	for(j=i-1;j>=0;j--)
		printf("%s %s %c %d %s %s\n",stu[j].num,stu[j].name,stu[j].sex,stu[j].age,stu[j].score,stu[j].add);
	}
	return 0;
}


struct student
{
	char info[100];
	struct student *next;
	struct student *former;
};
int main()
{
	struct student *head,*tail,*p;
	char s[100];
	p=(struct student*)malloc(sizeof(struct student));
	gets(p->info);
	head=p;
	head->former=NULL;
	tail=p;
	while (strcmp(p->info,"end")!=0)
	{
		p=(struct student*)malloc(sizeof(struct student));
		gets(p->info);
		tail->next=p;
		p->former=tail;
		tail=p;
	}
	while (p->former!=NULL)
	{
		p=p->former;
		printf("%s\n",p->info);
	}
	return 0;
}


int l;

struct students
{
    char num[10];
	char name[20];
    char sex;
	int age;
	float score;
	char addr[100];
	struct students *next;
};

struct students *ann()
{
	struct students *head=NULL,*newnode,*p;
	int i;
    for(i=0;;i++)
	{
        newnode=(struct students *)malloc(sizeof(struct students));

		scanf("%s",newnode->num);
		if(newnode->num[0]=='e')
		{
			l=i;
            head=p;
			break;
		}
		scanf("%s %c %d %f %s",newnode->name,&newnode->sex,&newnode->age,&newnode->score,newnode->addr);
		if(i==0)
		{
			newnode->next=NULL;
			p=newnode;
		}
		else
		{
			newnode->next=p;
            p=newnode;
		}
	}
	return(head);
}

void main()
{
	int i;
	struct students *p;
	p=ann();
	for(i=0;i<l;i++)
	{
        printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->addr);
		p=p->next;
	}

}


struct student
{
	char str[100];
	struct student *next;
};
int n;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	gets(p1->str);
	p1->next=NULL;
	p2=p1;
	while(strcmp(p2->str,"end")!=0)
	{
		n=n+1;
		if(n==1)head=p1;
		else {head=p2;p1=p2;}
		p2=(struct student *)malloc(LEN);
		p2->next=p1;
		gets(p2->str);
	}
	return(head);
}
void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
		while(p->next!=NULL)
		{
			puts(p->str);
			p=p->next;
		}
		puts(p->str);
}
void main()
{
	struct student *ip;
	ip=creat();
	print(ip);
}


char m[]="end";
struct student
{
 char studen[100];
 struct student *next;
};
 int n;
 struct student *creat(void)
 {
	 struct student *head,*p1,*p2;
	 n=0;
	 p1=p2=(struct student *)malloc(sizeof(struct student));
	 gets(p1->studen);
	 head=NULL;
	 while(strcmp(p1->studen,m)!=0)
	 {
      n=n+1;
	  if(n==1)head=p1;
	  else p2->next=p1;
	  p2=p1;
	  p1=(struct student *)malloc(sizeof(struct student));
	  gets(p1->studen);
	 }
	 p2->next=NULL;
	 return(head);
 }
 void print(struct student *head)
{
	 struct student *p,*q;
      p=q=head;/*p,q???????????*/
	  while(p->next!=NULL)
      p=p->next;/*?p??????????????*/
    printf("%s\n",p->studen);
   while(1)
   {
   while(q->next!=p)
     q=q->next;
     printf("%s\n",q->studen);
    p=q;
    q=head;
   if(p==head)
	   break;
   }
 }
int main()
{   struct student *ahead;
	ahead=creat();
    print(ahead);
}


struct student
{
	char num[10];
	char name[20];
	char sex;
	int age;
	float score;
	char adr[15];
	struct student *last;
};

char str[]="end";
int n=0;

void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->adr);
		    p=p->last;
		}while(p!=NULL);
}

void main()
{
	struct student *creat(void);
	void print(struct student *head);
	struct student *head;
	head=creat();
	print(head);
}

struct student *creat()
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s",&p1->num);
	head=NULL;
	while(strcmp(p1->num,str)!=0)
	{
		scanf("%s %c %d %f %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->adr);
		if(n==0){p1->last=NULL;n=1;}
		else {p1->last=p2;}
		p2=p1;
		p1=(struct  student*)malloc(LEN);
		scanf("%s",&p1->num);
	}
	head=p2;
	return(head);
}


struct student
{
	char num[20],na[30],sex[2],sc[10],old[3],ad[20];

	struct student *next;
};
int n;
void main()
{
	struct student *head,*p1,*p2,*p;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	head=NULL;
	while(scanf("%s",p1->num),p1->num[0]!='e')
	{

		n=n+1;
		head=p1;
		if(n>1)
		   p1->next=p2;
		else
           p1->next=NULL;
		p2=p1;
        scanf("%s%s%s%s%s",p1->na,p1->sex,p1->old,p1->sc,p1->ad);
		p1=(struct student *)malloc(LEN);

	}

    p=head;
    while(p!=NULL)
	{
		printf("%s %s %s %s %s %s\n",p->num,p->na,p->sex,p->old,p->sc,p->ad);
        p=p->next;
	};
}


struct student
{
	char str[100];
    struct student *next;
	struct student *front;
};
struct student *create()
{
	struct student *head,*pf,*pa,*end;
	int n=1,flag=0;
	do
	{
		pa=(struct student *) malloc(LEN);
		gets(pa->str);
		if(strcmp(pa->str,"end")==0)
		{
			if(n==1) flag=1;
			break;
		}
		if(n==1)
		{
			head=pa;
			pf=pa;
			pa->front=NULL;
			n++;
		}
		else
		{
			pf->next=pa;
			pa->front=pf;
			pf=pa;
		}
	 }while(n!=0);
	if(flag==0){pf->next=NULL;
	end=pf;}
	else{head=pa; end=NULL;}
    return(end);
}
int main()
{
	struct student *end,*pt;
	end=create();
	pt=end;
	while(pt!=NULL)
	{
		printf("%s\n",pt->str);
		pt=pt->front;
	}

	return 0;
}


struct student//?????????????????
{
	char num[100];
	char name[100];
	char gender;
	int age;
	float grade;
	char address[100];
	struct student *next;
} ;
struct student *p1,*p2;

struct student *creat()//????????
{
	int n;
	struct student *head;
	n=0;
	p1=p2=(struct student *)malloc(LEN);//???????*????????????????
	scanf("%s %s %c %d %f %s",p1->num,p1->name,&p1->gender,&p1->age,&p1->grade,p1->address);
	head=NULL;
    while(strcmp(p1->num,"end")!=0)//????
	{
		n=n+1;
		if(n==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
        if(strcmp(p1->num,"end")!=0)
        scanf("%s %c %d %f %s\n",p1->name,&p1->gender,&p1->age,&p1->grade,p1->address);
	}
	p2->next=NULL;
	return(head);
}
void print(struct student *head)//????
{
	struct student *p1;
	for(p1=head; p1!=NULL; printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->gender,p1->age,p1->grade,p1->address),p1=p1->next);
}

//?????
struct student * turnback(struct student *head)
{
	struct student *new,*newhead=NULL;
	do
	{
		p2=NULL;
		p1=head;
		while(p1->next!=NULL){ p2=p1;p1=p1->next;}
		if(newhead==NULL) newhead=p1,new=newhead->next=p2;
		else new=new->next=p2;
		p2->next=NULL;
	}
	while(head->next!=NULL);
	return(newhead);
}
void main()
{
	struct student *head;
	head=creat();
	head=turnback(head);
	print(head);
}


struct stu
{
	char num[500];
	char name[500];
	char sex[2];
	char age[100];
	char score[100];
	char add[500];
	struct stu *next;
};
int n;
struct stu *tj(void)
{
	struct stu *head;
	struct stu *p1,*p2;

	n=0;
	p2=p1=(struct stu*)malloc(LEN);
	scanf("%s %s %s %s %s %s",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
	head=NULL;
	while(1)
	{
		n=n+1;
		if(n==1)
			head=p1;
		else
			p1->next=p2;
		p2=p1;
		p1=(struct stu*)malloc(LEN);
		scanf("%s",&p1->num);
		if(strcmp(p1->num,"end")==0)
			break;
		scanf("%s %s %s %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
	}
	head=p2;
	return(head);
}
void print(struct stu *head)
{
	struct stu *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %s %s %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}
}
void main()
{
	struct stu *z;
	z=tj();
	print(z);
}


struct student
{
       char name[100];
       struct student *next;
};

int main()
{
       struct student *head,*p1,*p2;int i=0,j=0,m=0,k=0,n;
       p1=(struct student *)malloc(Len);
       scanf("%s",p1->name);
       p1->next=NULL;head=p1;
       for(;strcmp(p1->name,"end")!=0;i++)
       {
           p2=p1;
           p1=(struct student*)malloc(Len);
           scanf("%s",p1->name);
           p1->next=NULL;
           p2->next=p1;
           p2=p1;
       }
     struct student *p; p=head; j=0;n=i/6;
     for(m=1;m<=n;m++)
     {   p=head;j=0;

         while(p&&j!=i-6*m)
         {
            p=p->next;
            j++;
         }

         if(p&&(j==i-6*m))
         {
                for(k=0;k<5;k++)
               {
               printf("%s ",p->name);p=p->next;
               }
               printf("%s",p->name);
         }
        printf("\n");
     }
     }


void main()
{

	struct st
	{
		char num[500];
		char name[500];
		char sex;
		int age;
		double mark;
		char adress[500];
		struct st *next;
	}*p,*p1,*p2;
	p2=NULL;

	while(1)
	{   p1=(struct st*)malloc(sizeof(struct st));p1->next=p2;p2=p1;
		scanf("%s",p1->num);if(strcmp("end",p1->num)==0){p=p1->next;break;}
		scanf("%s %c %d %lf %s",p1->name,&p1->sex,&p1->age,&p1->mark,p1->adress);

	}

	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->mark,p->adress);
		p=p->next;
	}
}


struct student
{
char num[20];
char name[40];
char sex[10];
int age;
char score[20];
char addr[100];
struct student *next;
};
main()
{
struct student *head,*p1,*p;
int n=0;
p1=( struct student*) malloc(LEN);
scanf("%s%s%s%d%s%s",p1->num,p1->name,p1->sex,&p1->age,p1->score,p1->addr);
head=NULL;
while(strcmp(p1->num,"end")!=0)
{
n=n+1;
if(n==1) {head=p1;p1->next=NULL;}
else {p1->next=head;head=p1;}
p1=(struct student*)malloc(LEN);
scanf("%s%s%s%d%s%s",p1->num,p1->name,p1->sex,&p1->age,p1->score,p1->addr);
}
p=head;
do
{
printf("%s %s %s %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->addr);
p=p->next;
} while(p!=NULL);
}


struct stu
{
	char num[9];
	char name[18];
	char sex[2];
	int age;
	float score;
	char addr[12];
	struct stu *pre;
};

struct stu *create()
{
	struct stu *head,*p1,*p2;
	char end[]={"end"};
	p1=(struct stu *)malloc(LEN);
	scanf("%s",p1->num);
	if(strcmp(p1->num,end)==0)
	{
		return p1;
	}
	scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->addr);
	p1->pre=NULL;
	p2=p1;
	while(1)
	{
		p1=(struct stu *)malloc(LEN);
		scanf("%s",p1->num);
		if(strcmp(p1->num,end)==0)
		{
			return p2;
		}
		scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->addr);
		p1->pre=p2;
		p2=p1;
	}
}

void print(struct stu *head)
{
	struct stu *p1;
	p1=head;
	while(p1)
	{
		printf("%s %s %s %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->addr);
		p1=p1->pre;
	}
}

void destroy(struct stu *head)
{
	struct stu *p1;
	while(head)
	{
		p1=head;
		head=p1->pre;
		free(p1);
	}
}

int main()
{
	struct stu *head;
	head=create();
	print(head);
	destroy(head);
	return 0;
}


struct student
{
	char ID[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char address[20];
	struct student *next;
	struct student *before;
};
struct student *create()
{
	struct student *head,*p1,*p2,*end;
	p1=(struct student*)malloc(LEN);
	scanf("%s",p1->ID);
	if(strcmp(p1->ID,"end")==0){free(p1);head=NULL;end=NULL;}
	else
	{
		head=p1;
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->address);
		p1->next=NULL;
		p1->before=NULL;
		p2=p1;

	do
	{
		p1=(struct student*)malloc(LEN);
		p1->before=p2;
		p1->next=NULL;
		scanf("%s",p1->ID);
		if(strcmp(p1->ID,"end")==0){p2->next=NULL;end=p2;free(p1);break;}
		else
		{
			scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->address);
			p2->next=p1;
			p1->before=p2;
			p1->next=NULL;
			p2=p1;
		}
	}while(1);
	}
	return(end);
}
void print(struct student *end)
{
	struct student *p;
	p=end;
	while(p)
	{printf("%s %s %c %d %s %s\n",p->ID,p->name,p->sex,p->age,p->score,p->address);
	p=p->before;
	}

}
int main()
{

	struct student *end;
	end=create();
	print(end);
}


struct student
{
     char number[30];
     char name[20];
     char sex;
     int age;
     char score[30];
     char address[20];
     struct student *next;
};
main()
{
     struct student *head,*end,*p,*q,*a;
     head=(struct student*)malloc(sizeof(struct student));
     end=(struct student*)malloc(sizeof(struct student));
     int i,n;
     end->next=NULL;
     a=head;
     for(i=1;;i++)
     {
         if(i==1)
         {
             p=(struct student*)malloc(sizeof(struct student));
             scanf("%s",p->number);
             if(p->number[0]=='e') break;
             scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,p->score,p->address);
             head->next=p;
             p->next=end;
             q=p;
         }
         else
         {
             p=(struct student*)malloc(sizeof(struct student));
             scanf("%s",p->number);
             if(p->number[0]=='e') break;
             scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,p->score,p->address);
             head->next=p;
             p->next=q;
             q=p;
         }
     }
     a=head->next;
     for(;a->next!=NULL;)
     {
         printf("%s %s %c %d %s %s\n",a->number,a->name,a->sex,a->age,a->score,a->address);
         a=a->next;
     }

}


struct student
{
	char id[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char addr[20];
	struct student *next;
};
int n;
struct student *head;
struct student *creat(void)
{
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s",p1->id);
	head=NULL;
	while(strcmp(p1->id,"end")!=0)
	{
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->addr);
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->id);
	}
	p2->next=NULL;
	return(head);
}
void main()
{
	head=creat();
    struct student *p,*p0;
	p=(struct student *)malloc(100*LEN);
	p0=(struct student *)malloc(LEN);
	p0=head;
	int i;
	for(i=0;i<n;i++,p++)
	{
		*p=*p0;
		p0=p0->next;
	}
	p--;
	printf("%s %s %c %d %s %s",&p->id,&p->name,p->sex,p->age,&p->score,&p->addr);
	p--;
	for(i=1;i<n;i++,p--)
		printf("\n%s %s %c %d %s %s",&p->id,&p->name,p->sex,p->age,&p->score,&p->addr);
}


struct student
{
	struct student *pre;
	char num[100];
	char name[20];
	char sex[2];
	char age[10];
	char score[10];
	char ad[100];
};
void main()
{
	int n=0;
	struct student *end,*p1,*p2,*p;
	p1=(struct student *)malloc(LEN);
	scanf("%s",p1->num);
	while(strcmp(p1->num,"end")!=0)
	{
		scanf("%s %s %s %s %s",p1->name,p1->sex,p1->age,p1->score,p1->ad);
		n=n+1;
		if(n==1)
			p1->pre=NULL;
		else
			p1->pre=p2;
			p2=p1;
			p1=(struct student *)malloc(LEN);
			scanf("%s",p1->num);
	}
	p=p2;
	do
	{
		printf("%s %s %s %s %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->ad);
		p=p->pre;
	}while(p!=NULL);

}


struct a
{
struct a*back;
char a[20];
char b[20];
char c;
int d;
char e[20];
char f[20];
struct a*next;
};
int main()
{
    struct a *pHeader,*pEnd,*p1;
    pHeader=(struct a*)malloc(sizeof(struct a));
    pHeader->back=NULL;
    p1=pHeader;
    struct a*p;
    char g;
    for(;;)
    {
    p=(struct a*)malloc(sizeof(struct a));
    scanf("%s",p->a);
    g=*p->a;
    if(g=='e')
    {
    pEnd=p;
    p->back=p1;
    p1->next=p;
    p->next=NULL;
    break;
    }
    p->back=p1;
    p1->next=p;
    p1=p;
    scanf("%s %c %d %s %s",p->b,&p->c,&p->d,&p->e,p->f);
    }
    printf("%s %s %c %d %s %s\n",p1->a,p1->b,p1->c,p1->d,p1->e,p1->f);
    p=pEnd;
    for(;;)
    {
    printf("%s %s %c %d %s %s\n",p1->back->a,p1->back->b,p1->back->c,p1->back->d,p1->back->e,p1->back->f);
   p1=p1->back;
   free(p1->next);

    if(p1->back->back==NULL) break;
    }

}


struct student
{
	char num[20];
	char name[20];
	char sex[20];
	char age[20];
	char score[20];
	char add[20];
	struct student *next;
};
int n;

void main()
{
	int i;
	struct student *head,*p1,*p2,*newhead,*new;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s",p1->num);
	while(strcmp(p1->num,"end")!=0)//built link;
	{
		scanf("%s%s%s%s%s",p1->name,p1->sex,p1->age,p1->score,p1->add);
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s",p1->num);
	}
	p2->next=NULL;
	for(i=0;i<n;i++)
	{
		p2=p1=head;
		while(p1->next!=NULL)
		{
			p2=p1;
			p1=p1->next;
		}
		if(i==0)newhead=new=p1;
		else new=new->next=p1;
		p2->next=NULL;
	}
	p1=newhead;
	for(i=0;i<n;i++)
	{
		printf("%s %s %s %s %s %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1=p1->next;
		printf("\n");
	}

}


struct student
{
	char inf[1000];
	struct student *pre,*next;
};
void main()
{
	struct student *head,*p1,*p2,*tail;
	int i,j,k;
	head=(struct student *)malloc(LEN);
	p1=head;p2=NULL;
	p1->pre=NULL;p1->next=NULL;
	for(;;)
	{
		gets(p1->inf);
		if (strcmp(p1->inf,"end")==0) {p1->pre=p2;tail=p2;break;}
		else
		{
			p1->pre=p2;
			p1->next=(struct student *)malloc(LEN);
			p2=p1;p1=p1->next;p1->next=NULL;
		}
	}
	p1=tail;
	while (p1)
	{
		puts(p1->inf);
		p1=p1->pre;
	}
}


struct node{
	char str[MAX];
	struct node *next;
}*head;

void main()
{
	struct node *p1,*p2,*p;
	p1=p2=(struct node *)malloc(LEN);
	gets(p1->str);
	p1->next=0;
	while(strcmp( p1->str , "end" )!=0){
		p1=(struct node *)malloc(LEN);
		gets(p1->str);
		p1->next=p2;
		head=p2;
		p2=p1;
	}

	p=head;
	while(p!=0){
		puts(p->str);
		p=p->next;
	}
}


int main()
{
    struct student
    {
        char num[20];
        char name[20];
        char sex;
        int age;
        float mark;
        char address[20];
        struct student *next;
        struct student *pre;
    };
    struct student *stu;
    stu=(struct student*)malloc(LEN);
    stu->pre=NULL;
    while (1)
    {
        scanf ("%s",stu->num);
        if (strcmp(stu->num,"end")==0)
        break;
        scanf ("%s %c %d %f %s",stu->name,&stu->sex,&stu->age,&stu->mark,stu->address);
        stu->next=(struct student*)malloc(LEN);
        stu->next->pre=stu;
        stu=stu->next;
    }
    stu=stu->pre;
    free(stu->next);
    for ( ;stu!=NULL; )
    {
        printf("%s %s %c %d %g %s\n",stu->num,stu->name,stu->sex,stu->age,stu->mark,stu->address);
        stu=stu->pre;
        if (stu!=NULL)
        free (stu->next);
    }
    return 0;
}


struct st
{
     char id[20];
     char name[20];
     char sex;
     int age;
     float goal;
     char address[20];
     struct st *last;
};

struct st *input(void)
{
       int n;
       struct st *end,*p1,*p2;
       n=0;
       p1=p2=(struct st *)malloc(sizeof(struct st));
       scanf("%s",p1->id);
       while(strcmp(p1->id,"end")!=0)
       {
            scanf("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->goal,p1->address);
            if(n==0) p1->last=NULL;
            else p1->last=p2;
            p2=p1;
            p1=(struct st *)malloc(sizeof(struct st));
            scanf("%s",p1->id);
            n=1;
       }
       end=p2;
       return(end);
}

void output(struct st *end)
{
     struct st *p;
     p=end;
     if(end!=NULL)
        do
        {
              printf("%s %s %c %d ",p->id,p->name,p->sex,p->age);
              if(floor(p->goal)==p->goal) printf("%.0f",p->goal);
              else printf("%.1f",p->goal);
              printf(" %s\n",p->address);
              p=p->last;
        }while(p!=NULL);
}

int main()
{
     struct st *end;
     end=input();
     output(end);
}


struct stu
	{
		char xh[10];
		char name[20];
		char xb;
		int age;
		char score[20];
		char add[20];
		struct stu *next;
	};
    struct stu *creat()
	{
	struct stu *head,*p1,*p2;
	int n=0;
    p1=p2=(struct stu *)malloc(sizeof (struct stu));
	head=0;
	while(strcmp(p1->xh,"end")!=0)
	{
		n++;
		if(n==1)
		{
			p1->next=0;
			head=p1;
		}
		else
		{
	    	p2=p1;
	    	p1=(struct stu *)malloc(sizeof (struct stu));
	    	p1->next=p2;
		}
		scanf("%s",&p1->xh);
		if(strcmp(p1->xh,"end")==0)
		{
			head=p2;
			break;
		}
		scanf(" %s %c %d %s %s",&p1->name,&p1->xb,&p1->age,&p1->score,&p1->add);
	}
	return (head);
	}
void print(struct stu *head)
{
	struct stu *p;
	p=head;
	while (p!=0)
	{
		printf("%s %s %c %d %s %s\n",p->xh,p->name,p->xb,p->age,p->score,p->add);
		p=p->next;
	}
}
    void main()
	{
		struct stu *head;
		head=creat();
		print(head);
	}


struct student
{char a[88];
struct student *next;
};
struct student *creat(void)
{struct student *p1,*p2,*head;
p1=p2=(struct student *)malloc(LEN);
gets(p1->a);
p1->next=0;
while(strcmp(p1->a,"end")!=0)
{p2=p1;
p1=(struct student *)malloc(LEN);
gets(p1->a);
p1->next=p2;

}
head=p2;
return(head);
}
void print(struct student *head)
{struct student *p;
p=head;
while(p!=0)
{puts(p->a);
p=p->next;}
}
void main()
{struct student *head;
head=creat();
print(head);
}


struct student
{
	char num[10];
	char name[20];
	char sex;
	int age;
	char score[10];
	char id[20];
	struct student *pre;
};
void main()
{
	struct student *p1,*p2,*end;
	p1=(struct student *)malloc(sizeof(struct student));
	end=p1;
	p2=p1;
	p1->pre=NULL;
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->id);
	for(;1;)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0){end=p2;break;}
		else scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->id);
		p1->pre=p2;
		p2=p1;
	}
	p1=end;
	for(;p1!=NULL;)
	{
	   printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->id);
	   p1=p1->pre;
	}
}


struct student
{
	struct student *next;
	char num[20];
	char name[20];
	char sex[2];
	int age;
	float score;
	char address[40];
};
struct student *creat()
{
	struct student *head,*p1,*p2;
	p1=(struct student *)malloc(LEN);
	scanf("%s",p1->num);
	if(strcmp(p1->num,"end")!=0)
	{
		scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->address);
		p2=p1;
		p2->next=NUL;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
		while(strcmp(p1->num,"end")!=0)
		{
			scanf("%s%s",p1->name,p1->sex);
			scanf("%d%f%s",&p1->age,&p1->score,p1->address);
			p1->next=p2;
			p2=p1;
			p1=(struct student *)malloc(LEN);
			scanf("%s",p1->num);
		}
		head=p2;
	}
	else
		head=NUL;
	return(head);
}
void print(struct student *head)
{
struct student *p;
p=head;
while(p!=NUL)
{
printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
p=p->next;
}
}
int main()
{
struct student *head;
head=creat();
print(head);
return 0;
}


	struct stu
	{
		char num[100];
		char name[100];
		char sex[10];
		int age;
		char score[100];
		char add[100];
		struct stu *before;
	};
void main()
{
	struct stu *p2;
	struct stu * f();
	p2=f();
	while (p2!=0)
	{
		printf("%s %s %s %d %s %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->add);
		p2=p2->before;
	}
}

struct stu * f()
{
	struct stu *p1,*p2;
	p1=(struct stu *)malloc(sizeof (struct stu));
	p2=p1;
	scanf("%s",p1->num);
	p1->before=0;
	if (strcmp(p1->num,"end")!=0)
	{
	do
	{
		p2=p1;
		scanf("%s%s%d%s%s",p1->name,p1->sex,&p1->age,p1->score,p1->add);
		p1=(struct stu *)malloc(sizeof (struct stu));
		p1->before=p2;
		scanf("%s",p1->num);
	}
	while (strcmp(p1->num,"end")!=0);
	}
	return p2;
}


struct student
{
	char str[1000];
	struct student *next;
};

struct student *create(void)
{
	struct student *head;
	struct student *p1,*p,*p2;
	head=p1=(struct student *)malloc(len);
 	gets(p1->str);
	p1->next=0;
	p2=p1;
	while(strcmp(p1->str,"end")!=0)
	{
		p=head;
		head=p1;
		head->next=p;
		p1=(struct student *)malloc(len);
		gets(p1->str);
	}
	p2->next=0;
	return(head);
}

void print(struct student *head)
{
	struct student *p1;
	p1=head;
	if(head!=0)
		do
		{
			puts(p1->str);
			p1=p1->next;
		}while(p1!=0);
}

void main()
{
	struct student *head;
	head=create();
	print(head);
}


struct shuju
{
    char xh[20];
    char xm[20];
    char sex;
    int age;
   char fen[10];
    char dorm[20];
    struct shuju * next;
};

struct shuju *create()
{

    struct shuju *head,*p1,*p2;
    p1=(struct shuju* )malloc(len);
    scanf("%s %s %c %d %s %s",p1->xh,p1->xm,&p1->sex,&p1->age,p1->fen,p1->dorm);
    p1->next=NULL;
    while (1)
    {

    	p2=p1;
        p1=(struct shuju* )malloc(len);
        scanf("%s",p1->xh);
        if (strcmp(p1->xh,"end")==0) {free(p1);break;}
        else
        {scanf("%s %c %d %s %s",p1->xm,&p1->sex,&p1->age,p1->fen,p1->dorm);
        p1->next=p2;}
    }
    head=p2;
    return (head);
}

void print(struct shuju* head)
{

    struct shuju* p;
    p=head;
    while (p->next!=NULL)
    {
        printf("%s %s %c %d %s %s\n",p->xh,p->xm,p->sex,p->age,p->fen,p->dorm);
       p=p->next;}
     printf("%s %s %c %d %s %s\n",p->xh,p->xm,p->sex,p->age,p->fen,p->dorm);
}

void main()
{

    struct shuju *p;
    p=create();
    print(p);
}


struct student
{
       char num[100];
       struct student *pNext;
};
int main()
{
    int i,count=0;
    struct student a[1000],*pheader,*p;
    for(i=0;;i++)
    {
       gets(a[i].num);
       count++;
       if(strcmp(a[i].num,"end")==0)
          break;
    }
    pheader=&a[count-2];
    for(i=count-2;i>=1;i--)
    {
       a[i].pNext=&a[i-1];
    }
    a[0].pNext=NULL;
    p=pheader;
    while(p!=NULL)
    {
        puts(p->num);
        p=p->pNext;
    }
}


 struct student
 {
        char all[100];

        struct student *next;
        };

 main()
 {
       int k;
       int a=0;
       struct student *p;
       struct student *head;
       struct student *p1,*p2;
       p1=p2=(struct student *)malloc(n);
       head=NULL;
       k=0;
       for(k=0;;k++)
       {
       gets(p1->all);
       a++;
       if((p1->all)[0]!='e')
               {
                             if(a==1)
                              p1->next=NULL;
                                   else
                                   p1->next=p2;
                                   p2=p1;
                                   p1=(struct student *)malloc(n);
                             }

                            else
                             {
                                 head=p2;
                                 break;
                                 }
                                 }
                                 p=head;
                                 while(p!=NULL)
                                 {
                                               puts(p->all);
                                               p=p->next;
                                               }

                                       }


struct st
{
	char id[10000];
	struct st *next;
};

int main()
{
	struct st *head=NULL,*p=NULL,*q=NULL;
	char end;
	while (1)
	{
		p=(struct st*)malloc(sizeof(struct st));
		if(p!=NULL)
		{
			gets(p->id);
			p->next=q;
			if (p->id[0]=='e')
				break;
			else
			q=p;

		}
	}

	p=p->next;
	while(1)
	{
		puts(p->id);
		if (p->next==NULL)
			break;
		p=p->next;

	}

}


main()
{
      struct INF {char a1[20];char a2[20];
      char a3[20];char a4[20];char a5[20];
      char a6[20];struct INF *pp;} *p1,*p2;
      p1=(struct INF *)malloc(sizeof(struct INF));
      p2=NULL;
      int n=0,i;
      scanf("%s",p1->a1);
      while (strcmp(p1->a1,"end")!=0)
      {  scanf("%s",p1->a2);
         scanf("%s",p1->a3);
         scanf("%s",p1->a4);
         scanf("%s",p1->a5);
         scanf("%s",p1->a6);
         p1->pp=p2;
         p2=p1;
         p1=(struct INF *)malloc(sizeof(struct INF));
         scanf("%s",p1->a1);
         n++;     }
      for (i=0;i<n;i++)
      {printf("%s %s %s %s %s %s\n",p2->a1,p2->a2,p2->a3,p2->a4,p2->a5,p2->a6);
       p2=p2->pp;}
      }


struct student
{
	char num[100];
	char name[30];
	char sex;
	int age;
	float grade;
	char adress[30];
	struct student *next;
	struct student *before;
};
int n;
struct student *creat(void)
{
	struct student *head,*end;
	struct student *p1,*p2;
	char str[5]={"end"};
	n=0;
	p1=p2=( struct student *)malloc(LEN);
	scanf("%s %s %c %d %g %s",&p1->num,p1->name,&p1->sex,&p1->age,&p1->grade,p1->adress);
	head=NULL;
	do
	{
		n=n+1;
		if(n==1)  {head=p1;p1->before=NULL;}
		else
		{
			p2->next=p1;
			p1->before=p2;
		}
		p2=p1;
		p1=( struct student *)malloc(LEN);
		scanf("%s",&p1->num);
		if(strcmp(p1->num,str)==0)
			break;
		scanf("%s %c %d %g %s",p1->name,&p1->sex,&p1->age,&p1->grade,p1->adress);
	}while(n<1000);
	end=p2;
	p2->next=NULL;
	return (end);
}
void print(struct student *end)
{
	struct student *p;
	p=end;
	do
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->grade,p->adress);
		p=p->before;
	}while(p!=NULL);
}
void main()
{
	struct student *end;
	end=creat();
	print(end);
}


struct student
{
	char num[20];
	char name[20];
	char sex[2];
	int age;
	float score;
	char add[50];
	struct student*next;
};
int n;
struct student*creat(void)
{
	int juge=1;
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s",p1->num);
	scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->add);
	head=NULL;
	while(1)
	{

		head=p1;
		n=n+1;
		if(n==1)
		p1->next=NULL;

		if(n>1)
		{
			p1->next=p2;
			p2=p1;
			head=p1;
		}
		   p1=(struct student*)malloc(LEN);
		   scanf("%s",p1->num);

		   juge=strcmp(p1->num,"end");
		   if(juge==0)break;
		   scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->add);

	}

	return(head);
}
void print(struct student*head)
{
   struct student*p;
   p=head;
   if(head!=NULL)
   while(p!=NULL)
   {
     printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
	 p=p->next;
   }
}
void main()
{
	struct student *p;
	p=creat();
	print(p);
}


struct info{
	char num[10];
	char name[20];
	char sex;
	int age;
	float grade;
	char address[10];
	struct info *link;
};
int main(){
	struct info *p1,*p2;
	p1=p2=NULL;
	p1=(struct info *)malloc(sizeof(struct info));
	scanf("%s",p1->num);
	if(p1->num[0]=='e') return 0;
	do{
		scanf("%s %c%d%f%s",p1->name,&p1->sex,&p1->age,&p1->grade,p1->address);
		p1->link=p2;
		p2=p1;
		p1=(struct info *)malloc(sizeof(struct info));
		scanf("%s",p1->num);
	}while(p1->num[0]!='e');
	while(p2!=NULL){
		printf("%s %s %c %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->grade,p2->address);
		p1=p2->link;
		p2=p1;
	}
	return 0;
}


struct info
{
	char id[30];
	char name[30];
	char gen;
	int age;
	float grade;
	char add[30];
	struct info *next;
};
int n;

struct info *creat(void)
{
	struct info *head;
	struct info *p1;
	n=0;
	head=p1=(struct info*)malloc(LEN);
	scanf("%s",&p1->id);
	while(strcmp(p1->id,"end"))
	{   scanf("%s %c %d %f %s",&p1->name,&p1->gen,&p1->age,&p1->grade,&p1->add);
		n=n+1;
		if(n==1) {head=p1;p1->next=NULL;}
		else p1->next=head;
		head=p1;
		p1=(struct info*)malloc(LEN);
        scanf("%s",&p1->id);
	};
	return(head);
}

void print(struct info *head)
{
	struct info *p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s %s %c %d %g %s\n",p->id,p->name,p->gen,p->age,p->grade,p->add);
		    p=p->next;
		}while(p!=NULL);
}

void main()
{
	struct info *head;
	head=creat();
	print(head);
}


struct stu* create();
struct stu{
		char text[100];
		struct stu *prev;
	};
int main()
{
	struct stu *p;
	p=create();
	while (p){
         printf("%s\n", p->text);
         p = p->prev;
   }
	return 0;
}

struct stu* create(){
	struct stu *p1,*p2,*start;
	p1 = (struct stu *)malloc(sizeof(struct stu));
    gets(p1->text);
    if (p1->text == "end" ){
		free(p1);
        start = NULL;
        return start;  //?????
     }
	else{
		p1->prev = NULL;
		start = p1;
		p2 = p1;
		do{
			p1 = (struct stu *)malloc(sizeof(struct stu));
			start=p2;
			gets(p1->text);
			if ( strcmp(p1->text,"end")==0 ){
				free(p1);
				break;
			}
			else{
				p1->prev = p2;
				p2 = p1;
			}
		}	while (1);
		return start;   //?????
	}
}


struct student
{
    char num[16];
    char a[64];
    struct student *next;
};
int n;

struct student *creat(void)
{
    struct student *head,*p,*q;
    n=0;
    p=q=(struct student *)malloc(len);
    scanf("%s",p->num);
    head=null;
    while(strcmp(p->num,"end")!=0)
    {
        gets(p->a);
        n++;
        if(n==1)head=p,p->next=null;
        else head=p,p->next=q;
        q=p;
        p=(struct student *)malloc(len);
        scanf("%s",p->num);
    }
    return(head);
}

void print(struct student *head)
{
    struct student *p;
    p=head;
    int i;
    for(i=0;i<n;i++)
    {
        printf("%s",p->num);
        puts(p->a);
        p=p->next;
    }
}

void main()
{
    struct student *head;
    head=creat();
    print(head);
}


struct student
{char num[20];
char name[20];
char sex;
int age;
char score[20];
char add[20];
};
int main()
{int i=0,s=0;
int t=0;
struct student stu[1000];
scanf("%s",stu[0].num);
while(stu[i].num[0]!='e'){
scanf("%s %c %d %s %s",stu[i].name,&stu[i].sex,&stu[i].age,stu[i].score,stu[i].add);
i++;
s++;
scanf("%s",stu[i].num);
}
for(i=s-1;i>=0;i--){
printf("%s %s %c %d %s %s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].score,stu[i].add);
}
return 0;
}


struct student
{
	char c[100];
	struct student*next;
};
struct student*creat()
{
	struct student*p1,*p2,*p;
	int i;
	p1=p2=(struct student*)malloc(sizeof(struct student));
	p=p1;
	gets(p1->c);
	while(strcmp(p1->c,"end")!=0)
	{
		p1=(struct student*)malloc(sizeof(struct student));
		gets(p1->c);
		if(strcmp(p1->c,"end")==0) break;
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return p;
}
struct student*change(struct student*p)
{
	struct student*p1,*p2,*p3;
	p1=p;
	p2=p;
	p3=NULL;
	while(p1->next!=NULL)
	{
		p2=p1->next;
		p1->next=p3;
		p3=p1;
		p1=p2;
	}
	p1->next=p3;
	return(p1);
}
void print(struct student*p)
{
	struct student *p1,*p2;
	p1=p;
	while(p1!=NULL)
	{
		printf("%s\n",p1->c);
		p1=p1->next;
	}
}
void main()
{
	struct student *p,*p1;
	p=creat();
	p=change(p);
	print(p);
}


struct stu
{
	char inf[50];
	struct stu *next;
} a[500];
int main()
{
//	struct stu *head,*point;
	int sum=0,i=0,j;
//	point=(struct stu *)malloc(sizeof(struct stu));

	while(gets(a[i].inf)!=NULL)
	{
		i++;

	}
	for(j=i-2;j>=0;j--)
	{
		puts(a[j].inf);
	}
	return 0;
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char grade[20];
	char address[20];
	struct student *next;
};
struct student stud[200];
struct student * input()
{
	struct student *head,*p;
	head=NULL;
	p=(struct student *)malloc(LEN);
	scanf("%s",p->num);
	while(strcmp(p->num,"end")!=0)
	{
		scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,p->grade,p->address);
		p->next=head;
		head=p;
		p=(struct student *)malloc(LEN);
		scanf("%s",p->num);
	}
	return(head);
}
void output(struct student *head)
{
	struct student *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->grade,p->address);
		p=p->next;
	}
}
main()
{
	struct student *head;
	head=input();
	output(head);
	return 0;
}


struct student
{
	char message[300];
	struct student *next;
};
int n;

struct student *creat(void)
{struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student*)malloc(LEN);
gets(p1->message);
head=NULL;
while(strcmp(p1->message,"end")!=0)
{
    n=n+1;
	if(n==1)head=p1;
	else p1->next=p2;
	p2=p1;
	p1=(struct student*)malloc(LEN);
	gets(p1->message);
}
head->next=NULL;
return(p2);
}
void print(struct student *head)
{
	struct student*p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s\n",p->message);
			p=p->next;
		}
		while(p!=NULL);
}

	 void main()
{
		 struct student *head;
head=creat();
print(head);
}


struct student{
	char num[100];
	char name[100];
	char sex;
	int old;
	float score;
	char add[150];
	struct student *next;
};

void main()
{
	struct student *p1,*p2;
	int len=sizeof(struct student);
	p1=(struct student *)malloc(len);
	p1->next=NULL;
	scanf("%s",p1->num);
	while(strcmp(p1->num,"end")!=0){
		scanf("%s %c %d %g %s",p1->name,&p1->sex,&p1->old,&p1->score,p1->add);
		p2=p1;
		p1=(struct student *)malloc(len);
		p1->next=p2;
		scanf("%s",p1->num);
	}
	while(p1->next!=NULL){
		p1=p1->next;
		printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->old,p1->score,p1->add);
	}
}


struct student
{
 char inf[1000];
 struct student *pNext;
};
int main()
{
  int i,j,k,l,m,n;
  int count=0;
  struct student a[1000],*pHeader,*p;
  for(i=0;;i++)
  {
    gets(a[i].inf);
    count=count+1;
    if(strcmp(a[i].inf,"end")==0)
    break;
  }
  pHeader=&a[count-2];
  for(i=count-2;i>=1;i--)
  {
    a[i].pNext=&a[i-1];
  }
  a[0].pNext=NULL;
  p=pHeader;
  while(p!=NULL)
  {
    puts(p->inf);
    p=p->pNext;
  }
}


struct student
{
	char a[100];
	struct student *next;
};

int main()
{
	struct student *p1,*p2;
	p1=(struct student*)malloc(len);
	p1->next=NULL;
	gets(p1->a);
	while((strcmp(p1->a,"end"))!=0)
	{
		p2=p1;
		p1=(struct student*)malloc(len);
		p1->next=p2;
		gets(p1->a);
	}
	p1=p1->next;
	while(p1!=NULL)
	{
		printf("%s\n",p1->a);
		p1=p1->next;
	}
	return 0;
}


struct stu
{char num[9];
 char nam[50];
 char s;
 int old;
 double sco;
 char add[18];
 struct stu *next;
 struct stu *abv;
};
void main()
{struct stu*head,*p1,*p2;
 int i=0;
 head=NULL;
 do
 {p1=(struct stu*)malloc(LEN);
  scanf("%s",&p1->num);if(!strcmp(p1->num,"end"))break;
  scanf("%s %c %d %lf %s",&p1->nam,&p1->s,&p1->old,&p1->sco,&p1->add);
  if(i==0){head=p1;p1->abv=NULL;}
  else {p1->abv=p2;}
  p2=p1;
  i++;
 }while(1);
 p1=p2;
 do
 {if(p1->sco-(int)p1->sco==0)
  printf("%s %s %c %d %.0lf %s\n",p1->num,p1->nam,p1->s,p1->old,p1->sco,p1->add);
  else
  printf("%s %s %c %d %.1lf %s\n",p1->num,p1->nam,p1->s,p1->old,p1->sco,p1->add);
  p1=p1->abv;
 }while(p1!=NULL);
}


int n;

struct student{char stu[50];struct student *next;};
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	gets(p1->stu);
	head=NULL;
	while(strcmp(p1->stu,"end")!=0)
	{
		n=n+1;
		if(n==1)head=p1;
		else p2-> next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		gets(p1->stu);
	}
	p2-> next=NULL;
	return(head);
}

struct student *reverse(struct student *head)
{
	struct student *p1,*p2,*p3;
	p2=head;p3=head->next;
	do
	{
		p1=p2;p2=p3;p3=p2->next;p2->next=p1;
	}while(p3!=NULL);
	head->next=NULL;
	return(p2);
}

void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
	while(p)
	{
		if(p->stu!="end")
			printf("%s\n",p->stu);
		p=p->next;
	}
}

int main()
{
	struct student *head;
	head=creat();
	head=reverse(head);
	print(head);
        return 0;
}


struct student
{
	char num[1000];
	char name[1000];
	char sex;
	int age;
	char score[1000];
	char add[1000];
	struct student*next;
	struct student*pre;
};
int n;
struct student*creat()
{
	struct student*head,*end;
	struct student*p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	head=NULL;
   scanf("%s",p1->num);
	while(p1->num[0]!='e')
	{  	scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
		n=n+1;
		if(n==1){head=p1;p1->pre=NULL;}
		else {p2->next=p1;p1->pre=p2;}
		p2=p1;
		p1=(struct student*)malloc(LEN);
	   scanf("%s",p1->num);
	}
	p2->next=NULL;
	end=p2;
	return(end);
}

void print(struct student*end)
{
	struct student*p;
	p=end;
	do
	{
		printf("%s %s %c %d %s %s",p->num,p->name,p->sex,p->age,p->score,p->add);
		printf("\n");
		p=p->pre;
	}while(p!=NULL);
}
int main()
{
	struct student *end;
	end=creat();
	print(end);
  return 0;
}


struct student
{
char info[100];
struct student *next;
struct student *former;};
int i,j,k,n;
void main()
{
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student *)malloc(len);
gets(p1->info);
head=0;
while(strcmp(p1->info,"end")!=0)
{
n=n+1;
if(n==1) {head=p1;
p1->former=0;}
else {p2->next=p1;
p1->former=p2;}
p2=p1;
p1=(struct student *)malloc(len);
gets(p1->info);
}
p2->next=0;
p1=p2;

do{
puts(p2->info);
printf("\n");
p2=p2->former;}
while(p2!=0);
}


void main()
{
	struct stu
	{
		char num[20];
		char name[20];
		char sex;
		int age;
		float score;
		char addr[20];
		struct stu*next;
	}*p1,*p2;
	p1=malloc(sizeof(struct stu));
	scanf("%s",p1->num);
	if(*p1->num!='e')
	{
		scanf("%s %c%d%f%s",p1->name,&p1->sex,&p1->age,&p1->score,p1->addr);
		p1->next=0;
		for(;;)
		{
			p2=p1;
			p1=malloc(sizeof(struct stu));
			scanf("%s",p1->num);
			if(*p1->num=='e')break;
			scanf("%s %c%d%f%s",p1->name,&p1->sex,&p1->age,&p1->score,p1->addr);
			p1->next=p2;
		}
		p1=p2;
		for(;p1;p1=p1->next)printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->addr);
	}
}


struct student
{
	char a[1000];
	struct student *next;
};
void main()
{
	struct student *head,*p1,*p2;
	p1=head=(struct student*)malloc(LEN);
//	scanf("%s %s %c %d %d %s",p1->num,p1->name,&p1->sex,&p1->age,
//			&p1->score,p1->addr);
	p1->next=NULL;
	gets(p1->a);
	while(strcmp(p1->a,"end"))
	{
		p2=(struct student*)malloc(LEN);
		p2->next=p1;
	    p1=p2;
		gets(p1->a);
	}
	while(p1->next!=NULL)
	{
		p1=p1->next;
		printf("%s\n",p1->a);
	}
}


struct a {
char id[150];

struct a *pre;
};

struct a *creat(){

struct a *head, *p1, *p2;

p1=(struct a*)malloc(l);
gets(p1->id);
p1->pre=NULL;

p2=p1;

while(1){
p1=(struct a*)malloc(l);
gets(p1->id);
if (p1->id[0]=='e'){break;}
p1->pre=p2;
p2=p1;
}
free(p1);
head=p2;
return head;
}

void des(struct a *head){
struct a *p;
while(head){
p=head;
head=head->pre;
free(p);
}
}

int main (){
struct a *head, *p;
head=creat();

p=head;
while(p){
printf("%s\n", p->id);
p=p->pre;
}

des(head);
return 0;
}


void myPrint()
{
	char str[100];
	gets(str);
	if(strcmp(str,"end"))
		myPrint();
	else
		return;
	puts(str);
}

int main()
{
	myPrint();

	return 0;
}


int num=0;
void main()
{
	struct student
	{
		char xh[100];
		char xm[100];
		char xb;
		int nl;
		float df;
		char dz[100];
		struct student *af;
		struct student *bf;
	};
	int i,j,k,m,n;
	struct student *p1,*p2,*p3,*p4,*head;
	p1=p2=(struct student *)malloc(sizeof(struct student));
	scanf("%s %s %c %d %f %s",p1->xh,p1->xm,&p1->xb,&p1->nl,&p1->df,p1->dz);
	p1->bf=0;
	while(strcmp(p2->xh,"end")!=0)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		scanf("%s",p1->xh);
		if(strcmp(p1->xh,"end")==0)
		{
			head=p2;
			p1->bf=p2;
			p2->af=p1;
			p2=p1;
			num++;
			p1->af=0;
			break;
		}
		scanf("%s %c %d %f %s",p1->xm,&p1->xb,&p1->nl,&p1->df,p1->dz);
		p1->bf=p2;
		p2->af=p1;
		p2=p1;
		num++;
	}
	//if(strcmp(p1->xh,"end")==0)p1->af=0;
	//printf("%d",num);
	p1=head;
	//printf("%c",p1->xb);
	for(i=0;i<num;i++)
	{
		printf("%s %s %c %d %g %s\n",p1->xh,p1->xm,p1->xb,p1->nl,p1->df,p1->dz);
		p1=p1->bf;
	}

}


struct student
{
	char locate[100];
	struct student *next;
	struct student *last;
};
int n;
char u[100];
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student*)malloc(LEN);
gets(p1->locate);
strcpy(u,p1->locate);
head=NULL;
while(strcmp(p1->locate,"end")!=0)
{n=n+1;
if(n==1){head=p1;}
else {p2->next=p1;p1->last=p2;}
p2=p1;
p1=(struct student*)malloc(LEN);
gets(p1->locate);
}
p1->last=p2;
p2->next=NULL;
return(p2);
}
void main()
{
	struct student *creat(void);
	struct student *p;
	p=creat();
	do
	{printf("%s\n",p->locate);
	p=p->last;
	}while(strcmp(p->locate,u)!=0);
	printf("%s",p->locate);
}


struct stu
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char grade[20];
	char add[20];
	struct stu *p;
};
int main ()
{
	struct stu *p1,*p2;
	p1=(struct stu*)malloc(sizeof(struct stu));
	p1->p=NULL;
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->grade,p1->add);
	while(1)
	{
		p2=p1;
		p1=(struct stu*)malloc(sizeof(struct stu));
		p1->p=p2;
		scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->grade,p1->add);
		if(p1->num[0]=='e')
			break;
	}
	while(p1->p!=NULL)
	{
		p1=p1->p;
		printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->grade,p1->add);
	}
	return 0;
}


// ???????????????

struct record
{
	char str[100];
};

struct YyxNode
{
	struct record m_rec;
	struct YyxNode *next;
};

struct YyxStack
{
	int n;
	struct YyxNode *top;
};

struct YyxStack *CreateNewStack()
{
	struct YyxStack *newSt;
	if((newSt=(struct YyxStack*)malloc(sizeof(struct YyxStack)))==NULL){
		printf("Error: memory out! (1)\n");
		exit(-1);
	}
	newSt->n = 0;
	newSt->top = NULL;

	return newSt;
}

struct YyxStack *Push(struct YyxStack *st, const struct record *rec)
{
	struct YyxNode *newNode;
	if((newNode=(struct YyxNode*)malloc(sizeof(struct YyxNode)))==NULL){
		printf("Error: memory out! (2)\n");
		exit(-1);
	}
	newNode->m_rec = *rec;
	newNode->next = st->top;
	st->top = newNode;
	st->n ++;

	return st;
}

struct YyxStack *Top(struct YyxStack *st, struct record *rec)
{
	*rec = st->top->m_rec;

	return st;
}

struct YyxStack *Pop(struct YyxStack *st)
{
	struct YyxNode *delNode = st->top;
	if (delNode==NULL)
		return st;
	st->top = delNode->next;
	st->n --;

	free(delNode);

	return st;
}

struct YyxStack *ClearStack(struct YyxStack *st)
{
	while(st->top!=NULL)
		Pop(st);

	return st;
}

int main()
{
	struct YyxStack *mainSt;
	struct record stu;
	mainSt = CreateNewStack();
	gets(stu.str);
	while(strcmp(stu.str, "end")){
		Push(mainSt, &stu);
		gets(stu.str);
	}
	while(mainSt->n>0){
		Pop(Top(mainSt, &stu));
		puts(stu.str);
	}

//	free(ClearStack(mainSt));

	return 0;
}


struct student
{
	char a[100];
	struct student *next;
	struct student *last;
};
struct student *creat(void)
{
	struct student *head,*p1,*p2;
	p1=(struct student *)malloc(sizeof(struct student));
	gets(p1->a);
	p1->last=NULL;
	int i;
	for(i=1;strcmp(p1->a,"end")!=0;i++)
	{
		if(i==1);
		else {p2->next=p1;p1->last=p2;}
		p2=p1;
		p1=(struct student *)malloc(sizeof(struct student));
		gets(p1->a);
	}
	p2->next=NULL;head=p2;
	return(head);
}
main()
{
	struct student *head,*p;
	head=creat();
	p=head;
	int i;
	for(i=0;p->last!=NULL;i++)
	{
		printf("%s\n",p->a);
		p=p->last;
	}
	printf("%s",p->a);
}


struct student
{
       char id[10];
       char name[100];
       char sex;
       int age;
       char score[100];
       char adr[100];
       struct student *next;
};
int n=0;
struct student *creat()
{
       struct student *head,*p1,*p2;
       head=NULL;
       p1=p2=(struct student*)malloc(LEN);
       scanf("%s %s %c%d%s%s",&p1->id,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->adr);
       while(p1->id[0]!='e')
       {
         n++;
         if(n==1)
         head=p1;
         else
         p2->next=p1;
         p2=p1;
         p1=(struct student*)malloc(LEN);
         scanf("%s %s %c%d%s%s",&p1->id,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->adr);
       }
       p2->next=NULL;
       return(head);
}
void print(struct student*head,int m)
{
     struct student*p1;
     p1=head;
     if(head!=NULL)
         do
         {
                   printf("%s %s %c %d %s %s\n",p1->id,p1->name,p1->sex,p1->age,p1->score,p1->adr);
                   p1=p1->next;
         }while(p1!=NULL);
}
struct student *turnback(struct student *head)
{
       struct student *p1,*p2,*news,*p;

       int i;

       for(i=n;i>=0;i--)
       {p2=p1=head;
       while(p1->next!=NULL)
       {
                            p2=p1;p1=p1->next;
       }

                            if(i==n)
                            p=news=p1;

                            else
                            {
                              p=p->next=p1;
                              p2->next=NULL;
                            }

       }
       return(news);
}

int main()
{
    struct student*head,*newhead;
    head=creat();
    newhead=turnback(head);
    print(newhead,n);
    getchar();
    getchar();
    getchar();
    getchar();
}


struct stu
{
  char num[50];
  char name[50];
  char sex;
  int age;
  float score;
  char add[50];
  struct stu *forward;
};

void main()
{  int n=0;
   struct stu *head,*p1,*p2;head=NULL;
   p1=p2=(struct stu *)malloc(LEN);
   while(1)
   {
	   n++;
   if(n==1){head=p1;head->forward=NULL;}
   else {p1->forward=p2;}
   scanf("%s",p1->num);
      if(strcmp(p1->num,"end")==0)break;

   scanf(" %s",p1->name);
   scanf(" %c",&p1->sex);
   scanf(" %d",&p1->age);
   scanf(" %f",&p1->score);
   scanf(" %s",p1->add);
   p2=p1;
   p1=(struct stu *)malloc(LEN);
   }

   struct stu *p;
   p=p2;
   if(p->forward!=NULL)
   {
     do
	 {
	 printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
	 p=p->forward;
	 }while(p!=NULL);

   }

}


struct student
{
    char str[50];
    struct student *next;
};
int n;
struct student *creat()
{
    struct student *head, *temp, *end;
    head = end = temp = (struct student*) malloc(LEN);
    gets(temp->str);
    while (temp->str[0] != 'e')
    {
        temp->next = head;
        head = temp;
        temp = (struct student*) malloc(LEN);
        gets(temp->str);
    }
    end->next = NULL;
    return (head);
}
void print(struct student *head)
{
    struct student *p;
    p = head;
    while (p != NULL)
    {
        puts(p->str);
        p = p->next;
    }
}
void main()
{
    struct student *head;
    head = creat();
    print(head);
}


struct stu
{
	char num[100];
	char name[100];
	char sex[3];
	char age[10];
	char score[10];
	char ad[100];
	struct stu*next;
	struct stu*pre;
};
int main(int argc, char* argv[])
{
	int cal=0,i=0;
	char end[100];
	struct stu*head,*p1,*p2;
	p1=(struct stu*)malloc(len);
	scanf(" %s %s %s %s %s %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->ad);
	p1->next=NULL;
	p1->pre=NULL;
	head=p1;
	p2=p1;
	while(1)
	{
		scanf("%s",end);
		if(end[0]=='e')
		{break;}
		p1=(struct stu*)malloc(len);
		strcpy(p1->num,end);
		scanf("%s %s %s %s %s",p1->name,p1->sex,p1->age,p1->score,p1->ad);
		cal++;
		p1->next=NULL;
		p1->pre=p2;
		p2->next=p1;
		p2=p1;
	}
	while(p2)
	{
		printf("%s %s %s %s %s %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->ad);
		p1=p2;
		p2=p2->pre;
		free(p1);
	}
	return 0;
}


void append()
{
    char str[50];
    gets(str);
    if (str[0] != 'e')
    {
        append();
        puts(str);
    }
}
void main()
{
    append();
}


struct w
{char id[100];
struct w *next;
};
struct w *head,*new,*newhead,*p1,*p2;
 int i,n;

void main()
{
	  n=0;
	head=null;
	p1=p2=(struct w *)malloc(len);
	gets(p1->id);
	while(strcmp(p1->id,"end")!=0)
	{
	n++;
	if(n==1)head=p1;
	else p2->next=p1;
	p2=p1;
	p1=(struct w *)malloc(len);
	gets(p1->id);
	}
	p2->next=null;
	for(i=0;i<n;i++)
	{p2=p1=head;
	while(p1->next!=null)
	{p2=p1;p1=p1->next;}
	if(i==0) newhead=new=p1;
	else new=new->next=p1;
	p2->next=null;
	}
	p1=newhead;
	for(i=0;i<n;i++)
	{printf("%s\n",p1->id);
	p1=p1->next;
	}
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	float score;
	char add[20];
	struct student * next;
};
struct student * input(void)
{
	struct student *p1,*p2,*head;
	p1=(struct student *)malloc(len);
	p1->next=NULL;
	scanf("%s %s %c %d %f %s",p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
	do
	{
		p2=(struct student *)malloc(len);
		scanf("%s %s %c %d %f %s",p2->num,p2->name,&p2->sex,&p2->age,&p2->score,p2->add);
		p2->next=p1;
		p1=p2;
	}while(strcmp(p2->num,"end")!=0);
	head=p2->next;
	return(head);
}
void print(struct student*head)
{
	struct student *p;
	p=head;
	do
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
			p=p->next;
	} while(p!=NULL);
}
void main()
{
	struct student * head;
	head=input();
	print(head);
}


struct shuju
{
    char str[100];
    struct shuju * next;
};

struct shuju *create()
{

    struct shuju *head,*p1,*p2;
    p1=(struct shuju* )malloc(len);
    gets(p1->str);
    p1->next=NULL;
    while (1)
    {

    	p2=p1;
        p1=(struct shuju* )malloc(len);
        gets(p1->str);
        if(strcmp(p1->str,"end")==0) {free(p1);break;}
        p1->next=p2;
    }
    head=p2;
    return (head);
}

void print(struct shuju* head)
{

    struct shuju* p;
    p=head;
    while (p->next!=NULL)
    {
        puts(p->str);
       p=p->next;}
    puts(p->str);
}

void main()
{

    struct shuju *p;
    p=create();
    print(p);
}


struct node
{
	struct node *back;
	char num[20];
	char name[20];
	char gender;
	int age;
	char score[10];
	char address[20];
	struct node *next;
};
void main()
{
	char end[]="end";
	char t[20];
	struct node *p,*head;
	p=(struct node *)malloc(sizeof(struct node));
	head=p;
	head->back=NULL;
	scanf("%s %s %c %d %s %s",p->num,p->name,&p->gender,&p->age,p->score,p->address);
	scanf("%s",t);
	while(strcmp(t,end)!=0)
	{
		p->next=(struct node *)malloc(sizeof(struct node));
		p->next->back=p;
		p=p->next;
		strcpy(p->num,t);
		scanf("%s %c %d %s %s",p->name,&p->gender,&p->age,p->score,p->address);
		scanf("%s",t);
	}
	do
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->gender,p->age,p->score,p->address);
		p=p->back;
	}while(p!=NULL);
}


struct s
{
      char a[100];
      char b[100];
      char c;
      int d;
      char e[100];
      char f[100];
      }k[1000];
int n;
int main(int argc, char *argv[])
{ int i;

  for(i=0;;i++)
  {
     scanf("%s",k[i].a);
     if(strcmp(k[i].a,"end")==0)
     break;
     scanf(" %s %c %d %s %s",k[i].b,&k[i].c,&k[i].d,k[i].e,k[i].f);
  }
  for(i=i-1;i>=0;i--)
  printf("%s %s %c %d %s %s\n",k[i].a,k[i].b,k[i].c,k[i].d,k[i].e,k[i].f);
  return 0;
}


struct student
{char num[1000];
struct student *next;
};
void main()
{struct student *head,*p1,*p,*p2,*end;
int n=0;
p=p1=p2=(struct student*)malloc(LEN);
gets(p1->num);
head=NULL;
while(strcmp(p1->num,"end")!=0)
 {n=n+1;
  head=p1;
  if(n==1) p1->next=NULL;
  else p1->next=p2;
  p2=p1;
  p1=(struct student*)malloc(LEN);
  gets(p1->num);
}
p=head;
if (head != NULL)
{do
{puts(p->num);
p=p->next;}
while(p != NULL);}
}


struct stu
{
   char xinxi[100];
   struct stu *down;
};
int n=0;

struct stu * creat()
{
    struct stu *top=NULL;
    struct stu *p1=NULL,*p2=NULL;
    p1=p2=(struct stu *)malloc(LEN);
   gets(p1->xinxi);
    while(p1->xinxi[0]!='e')
 {
  n++;
  if(n==1)
   p1->down=NULL;
  else
   p1->down=p2;
  top=p1;
  p2=p1;
  p1=(struct stu *)malloc(LEN);
  gets(p1->xinxi);
 }
 return(top);
}
void main()
{
 struct stu *top,*p;
 top=creat();
 p=top;
    while(n!=0)
 {n--;
 puts(p->xinxi);
 p=p->down;
 }
}


struct student
{

char num[20];

char name[100];

char sex;

int age;

char score[10];

char address[20];

struct student *next;
};
struct student *print()
{

struct student *head=NULL,*node;

do

{

node=(struct student*)malloc(sizeof(struct student));

scanf("%s",node->num);

if(strcmp(node->num,"end")==0)

break;

else

{

scanf("%s %c %d %s %s",node->name,&node->sex,&node->age,node->score,node->address);

node->next=head;

head=node;

}

}

while(1);

return head;
}
void main()
{

struct student *p;

p=print();

do

{

printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);

p=p->next;

}

while(p->next!=NULL);

printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
}


int main()
{
	struct student
	{
		char s[500];
		struct student *next;
	}stu[2000],stup[2000];
	int i=0,j;
	struct student *p1,*p2,*head;
	p1=p2=(struct student *)malloc(LEN);
	head=NULL;
	gets(p1->s);
	while((*(p1->s)+0)!='e')
	{
		stu[i]=*p1;
		if(++i==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		gets(p1->s);
	}
	p2->next=NULL;
	for(j=0;j<i;j++) stup[j]=stu[i-1-j];
	for(j=0;j<i;j++) printf("%s\n",stup[j].s);
	return 0;
}


struct stu
{char c[100];
 struct stu *previous;
};
int n;
struct stu *creat(void)
{
	struct stu *p,*q;
	n=0;
	p=q=(struct stu *)malloc(Len);
	gets(p->c);
	for(;strcmp(p->c,"end")!=0;)
	{
		n++;
		if(n==1) p->previous=Null;
		else
		{
			p=(struct stu *)malloc(Len);
			p->previous=q;
			q=p;
			gets(p->c);
		}
	}
	return(p);
}
void main()
{
	struct stu *p;
	p=creat();
	p=p->previous;
	for(;p!=Null;)
	{
		printf("%s\n",p->c);
		p=p->previous ;

	}
}


struct Info
{
	char num[10];
	char name[20];
	char sex;
	int age;
	char score[10];
	char address[20];
	struct Info* next;
	struct Info* former;
};
int main()
{
	struct Info *head,*p1,*p2,*p,*tail;
	head=(struct Info*)malloc(sizeof(struct Info));
	p1=head;
	p2=head;
	char temp[10];
	scanf("%s %s %c %d %s %s",p2->num,p2->name,&p2->sex,&p2->age,p2->score,p2->address);
	head->former=NULL;
	head->next=NULL;
	p2=(struct Info*)malloc(sizeof(struct Info));
	while(1)
	{
		scanf("%s",temp);
		if (strcmp(temp,"end")!=0)
		{
			strcpy(p2->num,temp);
			scanf("%s %c %d %s %s",p2->name,&p2->sex,&p2->age,p2->score,p2->address);
			p2->former=p1;
			p2->next=NULL;
			p1->next=p2;
			p1=p2;
			p2=(struct Info*)malloc(sizeof(struct Info));
		}
		else
		{
				tail=p1;
				break;
		}
	}
	p=tail;
	do
	{
		if((p->score-(int)p->score)!=0)
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
		else
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
		p=p->former;
	}
	while(p!=NULL);
	return 0;}


struct student
	{ char num[20];
	char name[20];
	char sex;
	int age;
	double score;
	char add[100];
	struct student*next;
	}*head,*p1;
void main()
{
	int n=0;
	p1=(struct student*)malloc(LEN);
	scanf("%s",p1->num);
	while(p1->num[0]!='e')
	{
scanf("%s %c%d%lf%s",p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
		n++;
		if(n==1)p1->next=NULL;
		else p1->next=head;
head=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s",p1->num);
	}
	p1=head;
	do
	{
		printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1=p1->next;
	}
while(p1!=NULL);
}


struct stu_imformation
{
char num[16];
char name[20];
char sex;
int age;
char score[10];
char site[20];
struct stu_imformation *next;
};
void main()
{
struct stu_imformation *head,*p1,*p2;
head=(struct stu_imformation *)malloc(LEN);
scanf("%s %s %c %d %s %s",head->num,head->name,&head->sex,&head->age,head->score,head->site);
p2=head;
head->next=NULL;
p1=(struct stu_imformation *)malloc(LEN);
scanf("%s",p1->num);
while(strcmp(p1->num,"end"))
{
scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->site);
p1->next=p2;
head=p1;
p2=p1;
p1=(struct stu_imformation *)malloc(LEN);
scanf("%s",p1->num);
}
p1=head;
while(p1!=NULL)
{
printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->site);
p1=p1->next;
}
}


struct student
{
	char num[15];
	char name[20];
	char sex;
	int age;
	char score[10];
	char add[30];
	struct student *next;
};
int main()
{
	int n,i;
	struct student *head,*p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	p1->next=NULL;
	scanf("%s ",p1->num);
	while(strcmp(p1->num,"end")!=0)
	{
		n++;
		scanf("%s %c %d %s %s\n",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
		p2=(struct student *)malloc(LEN);
		p2->next=p1;
		p1=p2;
		scanf("%s ",p1->num);
	}
	head=p1->next;
	p1=p2=head;
	for(i=0;i<n;i++)
	{
		printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1=p2->next;
		p2=p1;
	}
}


struct student
{
	char stuID[20];
	char name[20];
	char sex;
	int age;
	char score[10];
	char add[20];
	struct student*next;
};
int main()
{
	struct student *p,*a;
	char str[10]={"end"};
	p=(struct student*)malloc(sizeof(struct student));
	scanf("%s",p->stuID);
	p->next=NULL;
	while(strcmp(p->stuID,str)!=0)
	{
		scanf("%s %c %d %s %s",p->name,&(p->sex),&(p->age),p->score,p->add);
		a=p;
		p=(struct student*)malloc(sizeof(struct student));
		p->next=a;
		scanf("%s",p->stuID);
	}
	while(p->next!=NULL)
	{
		p=p->next;
		printf("%s %s %c %d %s %s\n",p->stuID,p->name,p->sex,p->age,p->score,p->add);
	}
	return 0;
}


struct stu
{
	char num[20];
	char name[20];
	char s;
	int age;
	char point[10];
	char adr[50];
	struct stu *p;
};
void main()
{
	struct stu *stu1=NULL;
	int n=sizeof(struct stu);
	stu1=(struct stu *) malloc(n);
	struct stu *head=NULL,*curent=NULL;
	stu1->p=NULL;
	while(scanf("%s",stu1->num))
	{
		if((strcmp(stu1->num,"end"))==0)
			break;
		scanf("%s %c %d %s %s",stu1->name,&stu1->s,&stu1->age,&stu1->point,stu1->adr);
		stu1->p=curent;
		curent=stu1;
		stu1=(struct stu*) malloc(n);
	}
	while(curent!=NULL)
	{
		printf("%s %s %c %d %s %s\n",curent->num,curent->name,curent->s,curent->age,curent->point,curent->adr);
		stu1=curent;
		curent=curent->p;
		free(stu1);
	}
}


struct student
{
	int age;
	float score;
	char name[100],sex,add[20],num[20];
	struct student *p;
};
void main()
{
	struct student *p1,*head;
	p1=head=(struct student *) malloc(LEN);
	p1->p=NULL;
	scanf("%s %s %c %d %f %s",p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
	while (1)
	{
		p1=(struct student *) malloc(LEN);
		scanf("%s",p1->num);
		if (p1->num[0]!='e')
		{
		scanf("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
		p1->p=head;
		head=p1;
		}
		else break;
	}
	p1=head;
	while (p1!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1=p1->p;
	}
}


struct student
{
	char str[1000];
	struct student *next;
};
int main()
{
	struct student *p,*pnew,*head,*p1;
	pnew=(struct student *)malloc(sizeof(struct student));
	gets(pnew->str);
	pnew->next=NULL;
	if(strcmp(pnew->str,"end")==0)
	{
		free(pnew);
		head=NULL;
	}
	else
	{
		head=pnew;
		p=pnew;
	while(1)
	{
		pnew=(struct student *)malloc(sizeof(struct student));
		gets(pnew->str);
		pnew->next=NULL;
		if(strcmp(pnew->str,"end")==0)
		{
			free(pnew);
			break;
		}
		else
		{
			head=pnew;
			pnew->next=p;
			p=pnew;
		}
	}
	}
	p1=head;
	while(p1)
	{
		printf("%s\n",p1->str);
		p1=p1->next;
	}
	return 0;
}


struct student//?? ?? ?? ?? ?? ??
{
	char num[12];
	char name[20];
	char sex;
	int age;
	float grade;
	char add[12];
	struct student *next;
};
int n=1;
struct student *build(void)	//????
{
	struct student *pn, *pt;
	pn=(struct student*)malloc(sizeof(struct student));
	scanf("%s",pn->num);
	pn->next=NULL;
	while(pn->num[0]!='e')
	{
		scanf(" %s %c %d %f %s",&pn->name,&pn->sex,&pn->age,&pn->grade,&pn->add);
		pt=pn;
		pn=(struct student*)malloc(sizeof(struct student));
		pn->next=pt;
		scanf("%s",pn->num);
	}
	return (pt);
}
void main()
{
	struct student *p;
	p=build();
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->grade,p->add);
		p=p->next;
	}
}


struct student{char xh[20];char name[50];char sex;int age;char gra[10];char adds[50];struct student *next;};

void main()
{

	struct student *pa,*pb;
	int i;
	pa=pb=(struct student*)malloc(l);
	for(i=0; ;i++)
	{   scanf("%s",pa->xh);
	    if(pa->xh[0]=='e') break;
		scanf("%s %c %d %s %s",pa->name,&pa->sex,&pa->age,pa->gra,pa->adds);
		if(i==0) {pa->next=NULL;}
	    else pa->next=pb;
	    pb=pa;
	    pa=(struct student*)malloc(l);
	}

	while(pb!=NULL) {printf("%s %s %c %d %s %s\n",pb->xh,pb->name,pb->sex,pb->age,pb->gra,pb->adds);pb=pb->next;}
}


struct student
{
	char num[10];
	char name[20];
	char sex;
	int age;
	char score[10];
	char add[20];
	struct student *next;
};
struct student *creat(void)
{
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add);
	head=p1;
loop:
	p1=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add);
	if(strcmp(p1->num,"end")!=0)
	{
		p2->next=p1;
		p2=p1;
		goto loop;
	}
	else p2->next=NULL;
	return(head);
}
struct student *reverse(struct student *head)
{
	struct student *nowp,*prep,*nextp;
	prep=NULL;
	nowp=head;
	while(nowp!=NULL)
	{
		nextp=nowp->next;
		nowp->next=prep;
		prep=nowp;
		nowp=nextp;
	}
	return(prep);
}
int main()
{
	struct student *head,*head1;
	head=creat();
	head1=reverse(head);
	struct student *pt1;
	pt1=head1;
	while(pt1!=NULL)
	{
		printf("%s %s %c %d %s %s\n",pt1->num,pt1->name,pt1->sex,pt1->age,pt1->score,pt1->add);
		pt1=pt1->next;
	}
return 0;
}


struct stu
{   char num[20];
     char name[30];
     char sex;
     int age;
     float score;
     char add[30];
     struct stu *next;
     };
void main()
{ int i,len=1;
 struct stu *p1,*p2,*head,*new,*newhead;
 p1=p2=head=(struct stu*)malloc(sizeof(struct stu));
 printf("\n");
 scanf("%s %s %c %d %f %s" ,p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
 while(strcmp(p1->num,"end")!=0)
 {p1=(struct stu*)malloc(sizeof(struct stu));
  scanf("%s %s %c %d %f %s" ,p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add);
  printf("\n");
  if(strcmp(p1->num,"end")==0)
  p2->next=NULL;
  else
  {p2->next=p1;
  p2=p1;
  len++;}
 }
 p1=head;
 for(i=0;i<len;i++)
 { p1=p2=head;
 while(p1->next!=NULL)
   {p2=p1;
   p1=p1->next;
   }
   if(i==0)
   newhead=new=p1;
   else
   new=new->next=p1;
   p2->next=NULL;
}
p1=newhead;
for(i=0;i<len;i++)
{printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
p1=p1->next;
}
}


struct student
{
	char a[100];
	struct student *next;
};

struct student *create()
{
	struct student *p1,*p2;

	p1=(struct student*)malloc(len);
	gets(p1->a);
	p1->next=NULL;

	p2=p1;
	for(;;)
	{
		p1=(struct student*)malloc(len);
		gets(p1->a);
		if(strcmp(p1->a,"end")==0)
		{
			free(p1);
			break;
		}
		p1->next=p2;
		p2=p1;
	}
	return p2;
}

void main()
{
	struct student *head,*p1;
	struct student *create();
	head=create();
	p1=head;
	while(p1)
	{
		printf("%s\n",p1->a);
		p1=p1->next;
	}
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char address[20];
	struct student*next;
};

char t[4]={"end"};
struct student*p1,*p2;
struct student * creat(void)   //???????
{
	struct student*head;
    int	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s", p1->num);
	while ( strcmp(p1->num,t)!=0)
	{
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->address);
		n=n+1;
		if(n==1)
		{
			head = p1;
		}
		else
		{
			p2->next=p1;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
	}
	p2->next = NULL;
	return(head);
}

struct student*order(struct student*head) //???????
{
	struct student*ben,*rehead=NULL;
    while(head->next!=NULL)
	{
		p2=NULL;
		p1=head;
		while(p1->next!=NULL)
		{
			p2=p1;
			p1=p1->next;
		}
		if(rehead==NULL)
		{
			rehead=p1;
			ben=rehead->next=p2;
		}
			ben=ben->next=p2;
			p2->next=NULL;
	};
	return(rehead);
}

void print(struct student*head)  //???????
{
	struct student*p;
	p=head;
	if(head!=NULL)
	do
	{
    printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
	p=p->next;
	}while(p!=NULL);
}

int main()
{
	struct student*head;
	head=creat();
	head=order(head);
	print(head);
    return 0;
}


struct stu
{char num[50];
  char name[50];
  char sex[1];
  int age;
  char score[50];
  char add[50];
  struct stu *next;
};
int main()
{struct stu *head,*p1,*p2;
 p1=(struct stu*)malloc(LN);
 scanf("%s",p1->num);
 scanf("%s",p1->name);
 scanf("%s",p1->sex);
 scanf("%d",&p1->age);
 scanf("%s",p1->score);
 scanf("%s", p1->add);
 p1->next=NULL;
 p2=p1;head=p1;
  do
  { p1=(struct stu*)malloc(LN);
    scanf("%s",p1->num);
    if(*(p1->num)=='e')
    {free(p1);head=p2;break;}
     else
     {
  scanf("%s",p1->name);
  scanf("%s",p1->sex);
  scanf("%d",&p1->age);
  scanf("%s",p1->score);
  scanf("%s", p1->add);
    p1->next=p2;
    p2=p1;
     }
}while(1);
  while(head)
  {printf("%s %s %c %d %s %s\n",head->num,head->name,*(head->sex),head->age,head->score,head->add);
    head=head->next;
  }
}


struct student
{char information[100];
 struct student *next;
};
int n;
struct student *creat(void)
{struct student *head;
 struct student *p1,*p2;
 n=0;
 p1=p2=(struct student *)malloc(LEN);
 gets(p1->information);
 while(strcmp(p1->information,"end")!=0)
 {n=n+1;
  if(n==1) p1->next=NULL;
  else {p1->next=p2;p2=p1;}
  p1=(struct student *)malloc(LEN);
  gets(p1->information);
 }
 head=p2;
 return(head);
}
void print(struct student *p)
{
	do
	{
		printf("%s\n",p->information);
		p=p->next;
	}while(p!=NULL);
}
void main()
{
	struct student *head;
	head=creat();
	print(head);
}


main()
{
	struct stu
	{
	    char num[10];
    	char name[32];
     	char sex;
    	int age;
    	float score;
    	char address[32];
     	struct stu *next;
	};
	struct stu *p1,*p2;
	p1=(struct stu *)malloc(len);
	p1->next=NULL;
	int i;
	for(i=0;;i++)
	{
		scanf("%s",p1->num);
		if(!strcmp(p1->num,"end"))
			break;
    	scanf("%s %c %d %g %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
		p2=(struct stu *)malloc(len);
        p2->next=p1;
		p1=p2;
	}
	p1=p1->next;
	while(p1)
	{
		printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p1=p1->next;
	}
}


struct student
{
	char temp[50];
	struct student *previous;
};
void main()
{
	struct student *end,*head;
	struct student *p1,*p2, *p;
/*p1=(struct student *)malloc(LEN);*/
	p2=head=NULL;
	while(1)
	{
		p1=(struct student*)malloc(LEN);
		gets(p1->temp);
		if (strcmp(p1->temp,"end")==0)
		{
				/*delete p1;*/
			break;
		}

		if(head==NULL) {
			head=p1;
			head->previous=NULL;
		}
		else
			p1->previous=p2;
		p2=p1;
	}
/*p1->previous=p2;*/
	p=p2;
	if(p!=NULL)
		while(p) {
			puts(p->temp);
			p=p->previous;
		}

}


void main()
{
	struct li
	{
		char num[20],k[1000];
		struct li *next,*up;
	}*head,*p;
	head=(struct li *)malloc(sizeof(struct li));
	p=head;
	for(;;)
	{
		scanf("%s",p->num);
		if(p->num[0]=='e')
			break;
		gets(p->k);
		p->next=(struct li *)malloc(sizeof(struct li));
		(p->next)->up=p;
		p=p->next;
	}
	p=p->up;
	while(p!=head)
	{
		printf("%s%s\n",p->num,p->k);
		p=p->up;
	}
	printf("%s%s\n",head->num,head->k);

}


struct student
{
	char information[100];
	struct student *previous;
};

void main()
{
	struct student *p1,*p2,*p;
	p1=z;
	p1->previous=NULL;
	gets(p1->information);
	do{
		p2=z;//???p1,p2??????????????
		p2->previous=p1;
		p1=p2;
     	gets(p2->information);
	} while(strcmp(p1->information,"end"));
	p1=p1->previous;
	for(p=p1;p;p=p->previous)
	    puts(p->information);
}


struct student{
	struct student * formal;
	char xuehao[20];
	char xingming[20];
	char xingbie;
	int nianling;
	char defen[20];
	char dizhi[30];
	struct student * next;
};
int n=0;
struct student * creat(void);
void print(struct student *end);

void main()
{
	struct student * enda;
	enda=creat();
	print(enda);
	return 0;
}

struct student * creat(void)
{
	struct student * end;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s",p1->xuehao);
	while(p1->xuehao[0]!='e')
	{
		scanf("%s %c %d%s%s",p1->xingming,&p1->xingbie,&p1->nianling,p1->defen,p1->dizhi);
		n=n+1;
		if(n==1)
		{
			p1->formal=NULL;
		}
		else
		{
			p2->next=p1;
			p1->formal=p2;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->xuehao);
	}
	p2->next=NULL;
	end=p2;
	return(end);
}

void print(struct student *end)
{
	struct student *p;
	p=end;
	if(end!=NULL)
	{
		do
		{
	    printf("%s %s %c %d %s %s\n",p->xuehao,p->xingming,p->xingbie,p->nianling,p->defen,p->dizhi);
		p=p->formal;
		}while(p!=NULL);
	}
}


// 1209.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
struct data
{
	char num[200],name[200],sex,add[200];
	int age;
	char score[200];
	struct data *next;
};

struct data *creat()
{
	struct data *head,*p1 = NULL,*p2 = NULL;
	int n=0;
	do{
		p2=p1;
		p1=(struct data*)malloc(sizeof(struct data));
		scanf("%s",p1->num);
		if(*p1->num=='e')
		{
			head=p2;
			free(p1);
			break;
		}
		scanf("%s %c %d %s %s\n",p1->name,&(p1->sex),&(p1->age),p1->score,p1->add);

		if(n==0) p1->next=NULL;
		if(n!=0) p1->next=p2;
		n=1;
	}
	while(1);
	return head;
}
void print(struct data *head)
{
	struct data *p;
	p=head;
	while(p)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}
}

int main()
{
	struct data *head;
	head=creat();
	print(head);
	return 0;
}


struct q
{
	char a[100];
	struct q *last;
};
struct q * c()
{
	struct q *p1,*p2,*end;
	int t=1;
	while(0==0)
	{
		p1=(struct q *)malloc(sizeof(struct q));
		gets(p1->a);
		if(t==1)
		{
			p1->last=NULL;
			p2=p1;
			t=0;
		}
		else
		{
			if(p1->a[0]!='e')
			{
				p1->last=p2;
				p2=p1;
			}
			else
			{
				end=p2;
				break;
			}
		}
	}
	return end;
}
main()
{
	struct q *p1;
	p1=c();
	while(p1!=NULL)
	{
		puts(p1->a);
		p1=p1->last;
	}
}


struct student
{
	char a[100];
	struct student * next;
}*p1,*p2,*head;

int main()
{
	int n=0;
	p1=p2=(struct student *)malloc(Len);
	gets(p1->a);
	p2->next=NULL;
	while(1)
	{
		p1=(struct student *)malloc(Len);
		gets(p1->a);
		p1->next=p2;
		if(strcmp(p1->a,"end")==0)
		{
			head=p1->next;
			break;
		}
		else
		{
			p2=p1;
		}

	}
	p1=head;
	while(p1)
	{
		printf("%s\n",p1->a);
		p1=p1->next;
	}

}


struct student
{
	char num[10];
	char name[20];
	char sex;
	int age;
	char score[20];
	char address[50];
    struct student *next;
};
void main()
{
	struct student *head,*p,*q,*t;
	t=(struct student*)malloc(sizeof(struct student));
	t->next=NULL;
	head=(struct student*)malloc(sizeof(struct student));
	head->next=NULL;
	int i;
	for(i=0;;i++)
	{
		p=head->next;
		q=(struct student*)malloc(sizeof(struct student));
		q->next=NULL;
		scanf("%s",q->num);
        if(q->num[0]=='e')
			break;
		scanf("%s %c %d %s %s",q->name,&q->sex,&q->age,q->score,q->address);
		t->next=p;
		head->next=q;
		q->next=p;
	}
	head->next=p;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
		p=p->next;
	}
}


struct stu
{
	char zifu[200];
	struct stu *next;
};
struct stu stu[1000];
void main()
{   int i;
	struct stu *p=stu;
	for(i=0;i<1000;i++,p++)
	{
		gets(p->zifu);
		char str[10]="end";
		if((strcmp(p->zifu,str))==0)
			break;
		p->next=(p-1);
	}
	p=p-1;
	stu[0].next=NULL;
	while(p!=NULL)
	{
		puts(p->zifu);
		p=p->next;
	}
}


struct student
{
	char num[10];
	char name[20];
	char sex[2];
	int age;
	char score[30];
	char add[30];
	struct student *next;
};

int main()
{	struct student *head;
	struct student *p1,*p2,*p;
	p2=p=(struct student*)malloc(sizeof(struct student));
	scanf("%s%s%s%d%s%s",p2->num,p2->name,p2->sex,&p2->age,p2->score,p2->add);
	p2->next=NULL;
 	do
	{
		p2=(struct student*)malloc(sizeof(struct student));
		scanf("%s",p2->num);
		if(strcmp(p2->num,"end")==0)
			break;
		scanf("%s%s%d%s%s",p2->name,p2->sex,&p2->age,&p2->score,p2->add);
		p2->next=p;
		p=p2;

	}
	while(strcmp(p2->num,"end")!=0);
	head=p;
	for(p1=head;p1!=NULL;p1=p1->next)
	{
		printf("%s %s %s %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
	}
	return 0;
}


struct stu
{
	char num[21];
	char name[21];
	char sex;
	int age;
	char score[11];
	char addr[21];
	struct stu *pre,*next;
}head,end;

void create()
{
	struct stu *p1,*p2;
	p2=&head;
	p1=(struct stu *)malloc(sizeof(struct stu));
	scanf("%s",p1->num);
	while (strcmp(p1->num,"end")!=0)
	{
		p2->next=p1;
		p1->pre=p2;
		scanf("%s",p1->name);
		scanf(" %c",&p1->sex);
		scanf("%d",&p1->age);
		scanf("%s",p1->score);
		scanf("%s",p1->addr);
		p2=p1;
		p1=(struct stu *)malloc(sizeof(struct stu));
		scanf("%s",p1->num);
	}
	p2->next=&end;
	end.pre=p2;
}
void anti_print()
{
	struct stu *p;
	int flag=0;
	p=end.pre;
	while (p!=&head)
	{
		if (flag) printf("\n");

		printf("%s",p->num);
		printf(" %s",p->name);
		printf(" %c",p->sex);
		printf(" %d",p->age);
		printf(" %s",p->score);
		printf(" %s",p->addr);
		p=p->pre;

		flag=1;
	}
}
void main()
{
	head.pre=NULL;
	end.next=NULL;
	create();
	anti_print();
}


//???????
struct student
{       char info[50];
        struct student *next;
}*p1,*p2;
int n;
//????
struct student *creat (void)
{
        struct student *head;
        n=0;
        p1=p2=(struct student*)malloc(LEN);
        gets(p1->info);
        head = NULL;
        while(strcmp(p1->info,"end"))
        {
               n = n+1;
               if(n==1)
                       head = p1;
               else
                       p2->next = p1;
               p2 = p1;
               p1 = (struct student*)malloc(LEN);
               gets(p1->info);
        }
        p2->next = NULL;
        return(head);
}
struct student *turnback(struct student *head)
{
        struct student *p,*newhead=NULL;
        do
        {
               p2=NULL;
               p1=head;
               while(p1->next!=NULL)
               {
                       p2=p1;
                       p1=p1->next ;
               }
               if(newhead==NULL)
               {
                       newhead=p1;
                       p=newhead->next=p2;
               }
               p=p->next=p2;
               p2->next=NULL;
        }while(head->next!=NULL);
        return(newhead);
}
void output(struct student *outhead)
{
        for(p1=outhead;p1!=NULL;p1=p1->next)
               puts(p1->info);
}

void main()
{
        struct student *head;
        head=creat();
        head=turnback(head);
        output(head);
        printf("\n");
}


struct student
{
	char number[15];
	char name[20];
	char gender[3];
	int age;
	float score;
	char address[30];
	struct student *next;
};
struct student *creat(void)
{
	int i=1;
	struct student *head,*p1=(struct student *)malloc(LEN);
	head=p1;
	head->next=NULL;
	scanf("%s%s%s%d%f%s",p1->number,p1->name,p1->gender,&p1->age,&p1->score,p1->address);
	while(1)
	{
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->number);
		if((i=strcmp(p1->number,"end"))==0)break;
		scanf("%s%s%d%f%s",p1->name,p1->gender,&p1->age,&p1->score,p1->address);
		p1->next=head;
		head=p1;
	}
	return(head);
}
void print(struct student *p)
{
	do{printf("%s %s %s %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);p=p->next;}while(p->next!=NULL);
	printf("%s %s %s %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);
}
void main()
{
	struct student *p=creat();
	print(p);
}


void main()
{
char s[1024][128];
int i=0;

while(gets(s[i]))
{
if(strcmp(s[i],"end")==0) break;
i++;
}

while(i!=0)
{
i--;
puts(s[i]);
}
}


struct student{
char num[20];
char name[20];
char sex;
int age;
float score;
char address[20];
struct student *next;
};
int n;
struct student *create()
{
	struct student *head;
	struct student *p1,*p2;
	head=NULL;
	n=0;
	p1=p2=(struct student *)malloc(len);
	scanf("%s",p1->num);
	if(p1->num[0]=='e')
            return(head);
    scanf("%s %c %d%f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
	//printf("%s %s %c %d%d %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
	while(n!=-1)
	{
		n++;
		if(n==1)
			p1->next=NULL;
		else
			p1->next=p2;
		p2=p1;
		p1=(struct student *)malloc(len);
		scanf("%s",p1->num);
		if(p1->num[0]=='e')
            break;
		scanf("%s %c %d%f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
		//printf("%s %s %c %d%d %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
	}
	head=p2;
	return(head);
}
void print(struct student *p)
{
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
		p=p->next;
	}
}
void main()
{
	struct student *p;
	p=create();
	print(p);
}


struct student
{char num[20];
char name[20];
char sex[2];
int old;
float grade;
char address[100];
struct student *next;
};
int main()
{
	struct student *p1,*p2;
	p1=p2=NULL;
	p1=(struct student *)malloc(sizeof(struct student));
	scanf("%s",p1->num);
    if(p1->num[0]=='e')
		return 0;
do
	{

		scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->old,&p1->grade,p1->address);
		p1->next=p2;
		p2=p1;
		p1=(struct student *)malloc(sizeof(struct student));
		p1->next=p2;
scanf("%s",p1->num);

	}	while(p1->num[0]!='e');

	while(p2!=NULL)
	{
		printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->old,p2->grade,p2->address);
		p1=p2->next;
		p2=p1;
	}

	return 0;

}


struct stu
{char num[20];
 char name[20];
 char sex;
 int age;
 char score[10];
 char adr[20];
 struct stu *next;
};
int main(){
int n=0;
int i;
	struct stu *head;
    struct stu *p1,*p2,*re,*rehead;

	p1=p2=(struct stu *)malloc(len);
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->adr);
	head=null;

	for(i=0;;i++){

		n++;
		if(n==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;

		p1=(struct stu *)malloc(len);
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0){
				break;}
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->adr);
	}
	p2->next=null;
/*	p1=head;
	while(p1!=null){
			printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->adr);
			p1=p1->next;
		}*/
	for(i=0;i<n;i++){
		p2=p1=head;
		while(p1->next!=null){
			p2=p1;
			p1=p1->next;
		}
		if(i==0)
			re=rehead=p1;
		else
			re=re->next=p1;
		p2->next=null;
	}
		p1=rehead;
	while(p1!=null){
			printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->adr);
			p1=p1->next;
	}

	return 0;
}


struct student
{
	char num[100];
	char name[100];
	char sex;
	int age;
	float score;
	char add[100];
	struct student *next;
};
int n;
struct student*input(void)
{
	struct student *head,*p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf ("%s %s %c %d %f %s",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
	p1->next=NULL;
	head=NULL;
	while (strcmp("end",p1->num)!=0)
	{

		n++;
		p2=(struct student*)malloc(LEN);
		p2->next=p1;
		p1=p2;
		scanf ("%s",&p1->num);
		if (strcmp("end",p1->num)==0) break;
		else scanf ("%s %c %d %f %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
	}
	head=p1->next;
	return (head);
}
void main ()
{
	struct student *p;
	p=input();
	while (p!=NULL)
	{
		printf ("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}
}


struct student
{  char id[100];
   char name[100];
   char sex;
   int age;
   char score[100];
   char adress[100];
   struct student *next;
   struct student *formal;
};
int n;
int main ()
{  struct student *head,*p1,*p2;
   n=0;
   int i=0;
   p1=p2=(struct student*)malloc(len);
   head=NULL;
   while(0==0)
   {   n=n+1;

   scanf("%s ",p1->id);
   if((*p1).id[0]=='e') break;
   scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,
   p1->adress);
   if(n==1) {head=p1;
   p1->formal=NULL;}
   else {p2->next=p1;
   p1->formal=p2;}
   p2=p1;
       p1=(struct student*) malloc(len);

   }
    p2->next=NULL;
   while (0==0)
   {  printf("%s %s %c %d %s %s\n",p2->id,p2->name,p2->sex,p2->age,p2->score,
   p2->adress);
   if(p2->formal==NULL) break;
   p2=p2->formal;
   }
   return 0;
}


struct stu
{
	char xuehao[100];

	struct stu*next;
};
void main()
{
	int n=0;
	struct stu *head=NULL,*p1=NULL,*p2=NULL;
	p1=p2=(struct stu*)malloc(LEN);
    gets(p1->xuehao);

	while(strcmp(p1->xuehao,"end")!=0)
	{

		n++;
		if(n==1)
		{

			p1->next=NULL;
		}
		else

			p1->next=p2;
			p2=p1;
		    p1=(struct stu*)malloc(LEN);
			gets(p1->xuehao);

	}
	while(p2->next!=NULL)
	{
		printf("%s\n",p2->xuehao);
		p2=p2->next;
	}
    printf("%s\n",p2->xuehao);

}


struct student
{
	char info[50];
	struct student *pre;
	struct student *next;
};

void main()
{
	int i=0,n=0;
	struct student *p,*head,*p0;
	p=head=(struct student *)malloc(sizeof(struct student));
	while(strcmp((gets((*p).info)),"end")!=0)
	{
		n+=1;
		p0=p;
		p=(*p).next=(struct student *)malloc(sizeof(struct student));
		(*p).pre=p0;
	}

	while(i++<n)
	{
		p=(*p).pre;
		printf("%s\n",(*p).info);
	}
}


struct student
{
	struct student *next;
	char a[100];
};
int n;
struct student *creat()
{
	struct student *p1,*p2,*head;
	n=0;
	p1=(struct student *)malloc(sizeof(struct student ));
	gets(p1->a);
	p2=p1;
	head=NULL;
	while (strcmp(p1->a,"end")!=0)
	{
		n=n+1;
		if(n==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(sizeof(struct student ));
		gets(p1->a);
	}
	p2->next=NULL;
	return(head);
}
/*void main()
{
	struct student *p,*head;
	head=creat();
	p=head;
	while(p!=NULL)
	{
		printf("%s\n",p->a);
		p=p->next;
	}

}*/
void main()
{
    struct student *p1,*head,*p2;
	head=creat();
	p1=head;

	while(1)
	{

		if(p1->next!=NULL) {p2=p1;p1=p1->next;}
		if(p1->next==NULL&&p2!=head)
		{

			printf("%s\n",p1->a);
			p2->next=NULL;
			p1=head;
		}
		if(p1->next==NULL&&p2==head) break;

	}
	printf("%s\n%s",p1->a,head->a);
}


struct student
{
	char num[30];
	char name[20];
	char a[3];
	int age;
	char score[10];
	char add[30];
	struct student *next;
};
int n;
void *malloc(unsigned int size);
void main()
{
	int l=0,i=0;
    struct student *head,*p1,*p2,*newhead,*new1;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s%s%s%d%s%s",&p1->num,&p1->name,&p1->a,&p1->age,&p1->score,&p1->add);
	head=NULL;
	while(strcmp(p1->num,"end")!=0)
	{
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s%s%s%d%s%s",&p1->num,&p1->name,&p1->a,&p1->age,&p1->score,&p1->add);
	}
	p2->next=NULL;
    for(i=0;i<n;i++)
	{
		p2=p1=head;
        while(p1->next!=NULL)
		{
             p2=p1;
	       	p1=p1->next;
		}
		if(i==0)
			newhead=new1=p1;
		else new1=new1->next=p1;
		p2->next=NULL;
	}
    p1=newhead;
	for(l=0;l<n;l++)
	{
		printf("%s %s %s %d %s %s\n",p1->num,p1->name,p1->a,p1->age,p1->score,p1->add);
		p1=p1->next;
	}
}


int main()
{
	struct student{
		char number[20];
		char name[20];
		char sex;
		int age;
		float score;
		char address[20];
		struct student *fomer;
		struct student *next;
	};
	struct student *head,*p,*wei;
	int i,j;
	head=(struct student *)malloc(sizeof(struct student));
	p=head;
	p->fomer=NULL;
	if (p==NULL)
		{
			printf("fail!!!");
			exit(-1);
		}
	scanf("%s%s %c %d%f%s",&p->number,&p->name,&p->sex,&p->age,&p->score,&p->address);
	for (i=1;i<=1000;i++)
	{
		p->next=(struct student *)malloc(sizeof(struct student));
		p->next->fomer=p;
		p=p->next;
		scanf("%s%s %c %d%g%s",&p->number,&p->name,&p->sex,&p->age,&p->score,&p->address);
		//printf("%s %s %c %d %g %seeererrtttre\n",p->fomer->number,p->fomer->name,p->fomer->sex,p->fomer->age,p->fomer->score,p->fomer->address);
		if (*p->number=='e')
		{
			p->fomer->next=NULL;
			wei=p->fomer;
			//printf("%s %s %c %d %g %s\n",wei->number,wei->name,wei->sex,wei->age,wei->score,wei->address);
			break;
		}
	}
	//printf("%s %s %c %d %g %s\n",wei->number,wei->name,wei->sex,wei->age,wei->score,wei->address);
	p=wei;
	for (;p!=NULL;)
	{
	   printf("%s %s %c %d %g %s\n",p->number,p->name,p->sex,p->age,p->score,p->address);
	   p=p->fomer;
	}

}


void main()
{struct student
{char a[100];
 struct student *next;
} *p1,*p2,*head;
int n=0;
p1=p2=(struct student *)malloc(sizeof(struct student));
head=NULL;
gets(p1->a);
while(strcmp(p1->a,"end"))
{n++;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *)malloc(sizeof(struct student));
gets(p1->a);
}
p2->next=NULL;
for(;;)
{ for(p2=head;;p2=p2->next)
  { p1=p2->next;
	  if(p1->next==NULL)
	  {printf("%s\n",p1->a);
        p2->next=NULL;
		break;
	  }
  }
if(p2==head)
{printf("%s\n",head->a);
break;
}

}

}


struct stu
{char num[20];
 char name[20];
 char sex;
 int age;
 char score[10];
 char add[20];
 struct stu *next;};

void main()
{
	struct stu *p1,*p2;
	int n=0;
	p1=p2=(struct stu*)malloc(LEN);
	scanf("%s",p1->num);
	if(strcmp(p1->num,"end")==0) {n=-1;p2=NULL;}
	else scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
	while(n>=0)
	{n+=1;
     if(n==1)p1->next=NULL;
	 else p1->next=p2;
	 p2=p1;
	 p1=(struct stu*)malloc(LEN);
	 scanf("%s",p1->num);
	 if(strcmp(p1->num,"end")==0)break;
	 scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);}
    while(p2!=NULL)
	{printf(A,p2->num,p2->name,p2->sex,p2->age,p2->score,p2->add);
	p2=p2->next;}
}


struct student{
       char num[20];
	   char name[30];
	   char sex;
	   int age;
	   float score;
	   char adress[30];
	   struct student *next;
	   struct student *last;
};

int n=1;

struct student *ANewNode(void)
{
	struct student *head=NULL,*newnode,*thisnode;

	do
	{
		newnode=(struct student *)malloc(sizeof(struct student));
		scanf("%s",newnode->num);
	    if(strcmp(newnode->num,"end")==0)
		{
			thisnode->next=NULL;
			head=thisnode;
			break;
		}
		else;
        scanf("%s %c %d %f %s",newnode->name,&newnode->sex,&newnode->age,&newnode->score,newnode->adress);
		if(n==1)
		{
			head=newnode;
			thisnode=head;
			thisnode->last=NULL;
		}
		else
		{
			thisnode->next=newnode;
			newnode->last=thisnode;
		}
			thisnode=newnode;
			n=n+1;

	}while(strcmp(newnode->num,"enff")!=0);
	return(head);
}

int main()
{
    struct student *head,*p;

	head=ANewNode();

	p=head;
	do
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->adress);
		p=p->last;
	}while(p!=NULL);
	scanf("%d",&n);
 return 0;
}


struct student{
		char name[100];
		char ind[100];
		char sex;
		int age;
		float score;
		char dizhi[100];
		struct student *next;
};//?? ?? ?? ?? ?? ??
int n;
struct student *creat()
{
	struct student *p1,*p2;
	n=0;
	p1=(struct student *)malloc(LEN);
	p2=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %f %s",&p1->ind,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->dizhi);
	p1->next=0;
	while(strcmp(p2->ind,"end")!=0)
	{
		n++;
		if(n==1)scanf("%s %s %c %d %f %s",&p2->ind,&p2->name,&p2->sex,&p2->age,&p2->score,&p2->dizhi);
		else scanf("%s %c %d %f %s",&p2->name,&p2->sex,&p2->age,&p2->score,&p2->dizhi);
		p2->next=p1;
		p1=p2;
		p2=(struct student *)malloc(LEN);
		scanf("%s",&p2->ind);

	}
	return p1;
}
void main()
{
	struct student *wr;
	wr=creat();
	printf("%s %s %c %d %g %s\n",wr->ind,wr->name,wr->sex,wr->age,wr->score,wr->dizhi);
       //printf("10630018 zouan m 20 10 28#46000\n");
	while(wr->next!=0){
				wr=wr->next;
		printf("%s %s %c %d %g %s\n",wr->ind,wr->name,wr->sex,wr->age,wr->score,wr->dizhi);

		}

}


struct node
{
	char num[20];
	char name[20];
	char gender;
	int age;
	char score[10];
	char addr[20];
	struct node *next;
	struct node *back;
};
void main()
{
	char scan[100],constant[]="end";
	struct node beginning,*head,*p,*ending,*t;
	int count=1,i;
	head=&beginning;
	beginning.next=NULL;
	beginning.back=NULL;
	p=head;
	ending=p;
	scanf("%s %s %c %d %s %s",beginning.num,beginning.name,&beginning.gender,&beginning.age,beginning.score,beginning.addr);
	scanf("%s",scan);
	while(strcmp(scan,constant)!=0)
	{
		p->next=(struct node *)malloc(sizeof(struct node));
		t=p;
		p=p->next;
		strcpy(p->num,scan);
		scanf("%s %c %d %s %s",p->name,&p->gender,&p->age,p->score,p->addr);
		p->back=t;
		ending=p;
		scanf("%s",scan);
		count++;
	}
	p=ending;
	for(i=1;i<=count;i++)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->gender,p->age,p->score,p->addr);
		p=p->back;
	}
}


struct aa
	{
		char data[100];
		struct aa* next;
	};
void print(struct aa* p)
{
	if (p->next!=NULL) print(p->next);
	cout <<p->data<<endl;
}
int main()
{

	struct aa *head,*p,*q;
	int si=sizeof(struct aa);
	head=(struct aa*)malloc(si);
	p=head;q=head;
	char s[100];
	while (cin.getline(s,100))
		if (strcmp(s,"end"))
		{
			q=(struct aa*)malloc(si);
			p->next=q;
			strcpy(q->data,s);
			q->next=NULL;
			p=q;
		}
		else break;
	print(head->next);
	return 0;
}


struct student
{
	char xh[1000];
	struct student *next;
	struct student *last;
};
int n;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=(struct student*)malloc(sizeof(struct student));
	p2=p1;
	gets(p1->xh);
         head=NULL;
	p1->last=NULL;
	for(n=1;strcmp(p1->xh,"end")!=0;n++)
	{
		if(n==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(sizeof(struct student));
		gets(p1->xh);
		if(strcmp(p1->xh,"end")==0) break;
		p1->last=p2;
	}
	head=p2;
	p2->next=NULL;
	return(head);
}
void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
		for(;p!=NULL;)
		{
			printf("%s\n",p->xh);
			p=p->last;
		}
}
void main()
{
	struct student *head;
	head=creat();
	print(head);
}


struct stu
{
       char ss[10000];
       struct stu *next;
};
int main()
{
    long int i,j,k,l,m,n;
    struct stu *p,*p1;
    p1=p=(struct stu*)malloc(len);
    p1=null;
    while (1)
    {
          p=(struct stu*)malloc(len);
          gets(p->ss);
          p->next=p1;
          p1=p;
          if (strcmp(p->ss,"end\0")==0) break;
    }
    p=p->next;
    while (p!=null)
    {
          puts(p->ss);
          p=p->next;
    }
    scanf("%d",&i);
}