struct student
{
     char id[15];
     char name[20];
     char sex;
     int age;
     char grade[20];
     char add[20];
     struct student *next;
};

struct student *set(void)
{
     struct student *head,*p1,*p2;
     head=(struct student *)malloc(LEN);
     p1=head;
     p2=head;
     scanf("%s%s %c %d %s %s",head->id,head->name,&head->sex,&head->age,head->grade,head->add);
     p1=(struct student *)malloc(LEN);
     scanf("%s%s %c %d %s %s",p1->id,p1->name,&p1->sex,&p1->age,p1->grade,p1->add);
     p2->next=p1;
     p2=p1;
     while(1)
     {
          p1=(struct student *)malloc(LEN);
          scanf("%s",p1->id);
          if(strcmp(p1->id,"end")==0)
          {
               p2->next=NULL;
               break;
          }
          scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->grade,p1->add);
          p2->next=p1;
          p2=p1;
     }
     return(head);
}

int main()
{
     struct student *p,*p1,*p2,*p3;
     int i,j,n=1;
     p=set();
     p1=p;p1=p1->next;p1=p1->next;
     p2=p;p2=p2->next;
     p3=p;
     while(p1!=NULL)
     {
          p2->next=p3;
          p3=p2;p2=p1;p1=p1->next;
     }
     p2->next=p3;        //????????????????p2????
     p->next=NULL;       //???????p??????

     p1=p2;           //?p1???????????????????
     while(p1!=NULL)
     {
          printf("%s %s %c %d %s %s\n",p1->id,p1->name,p1->sex,p1->age,p1->grade,p1->add);
          p1=p1->next;
     }

     return 0;
}


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


int main()
{
	struct stu{
		char a[20];
		char b[30];
		char c;
		int d;
		char e[6];
		char f[20];
		struct stu *be;
	};
	int n=0;
	struct stu *head=NULL,*p1,*p2;
	p2=p1=(struct stu *) malloc(LEN);
	scanf("%s",p1->a);
	while ( strcmp(p1->a,"end") )
	{
		if(n) p1->be=p2;
		else  p1->be=NULL;
		n++;
		scanf("%s %c %d %s %s",(*p1).b,&(*p1).c,&(*p1).d,(*p1).e,(*p1).f);
		p2=p1;
		p1=(struct stu *) malloc(LEN);
		scanf("%s",p1->a);
	}
	while (p2!=NULL)
	{
		printf("%s %s %c %d %s %s\n",(*p2).a,(*p2).b,(*p2).c,(*p2).d,(*p2).e,(*p2).f);
		p2=p2->be;
	}
	return 0;
}


struct student
{
	char xuehao[200];
	struct student *next;
};
struct student *create(n)
{
	struct student *p1,*p2,*head;
	p1=p2=(struct student*)malloc(sizeof(struct student));
	p1->next=0;
	gets(p1->xuehao);
	while(p1->xuehao[0]!='e')
	{
		p2=p1;
		p1=(struct student*)malloc(sizeof(struct student));
		p1->next=p2;
		gets(p1->xuehao);
	}
	head=p2;
	return(head);
}
int main()
{
	struct student *p1;
	int n;
	p1=create(n);
	while(p1!=0)
	{
		printf("%s\n",p1->xuehao);
		p1=p1->next;
	}
}


struct student
{
	char information[200];
	struct student *next;
};
struct student *creat(void)
{
	int n=0;
	struct student *head;
	struct student *p1,*p2;
	p1=(struct student *)malloc(LEN);
	gets(p1->information);
	p1->next=NULL;
	p2=p1;
		do
		{
			p1=(struct student *)malloc(LEN);
			gets(p1->information);
			if(strcmp(p1->information,"end")==0)
			{
				free(p1);
				head=p2;
				break;
			}
			else
			{
				p1->next=p2;
				head=p1;
				p2=p1;
			}
		}
		while(1);

	return(head);
}

void print(struct student *head)
{
	struct student *p;
	p=head;
	if(head!=NULL)
	{
		do
		{
			puts(p->information);
			p=p->next;
		}
		while(p!=NULL);
	}
}
void main()
{
	struct student *head;
	head=creat();
	print(head);
}


struct Stu
{
	char num[20];
	char name[50];
	char sex;
	int age;
    char mark[50];
	char add[50];
	struct Stu *link;
};
void main()
{
	struct Stu *p1,*p2;
	p1=(struct Stu *)malloc(LEN);
	p2=p1;
	scanf("%s",p1->num);
	p1->link=NULL;
	while(strcmp(p1->num,"end")!=0)
	{
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->mark,p1->add);
		p1=(struct Stu *)malloc(LEN);
		p1->link=p2;
		scanf("%s",p1->num);
		p2=p1;
	}
	struct Stu *p;
	p=p1->link;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->mark,p->add);
		p1=p->link;
		free(p);
		p=p1;
	}
}


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


int n=0;
struct student
{
    char s[200];
    struct student *next;
};
struct student *creat()
{
    char k[200];
    struct student *p,*head;
    head=p=(struct student *)malloc(LEN);
    while(1)
    {
        gets(k);
        if(!(strcmp(k,"end")))
        break;
        else
        {
            if(n==0)
            {head->next=NULL;n=1;}
            else
            p->next=head;
            head=p;
            strcpy(p->s,k);
            p=(struct student *)malloc(LEN);
        }
    }
    free(p);
    return (head);
}
void print(struct student *p)
{
    if(p!=NULL)
    {
        puts(p->s);
        print(p->next);
    }
}
int main()
{
    struct student *head;
    head=creat();
    print(head);
    return 0;
}


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

struct student *create(void)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(length);
	scanf("%s",p1->num);
	head=null;
	while(strcmp(p1->num,"end")!=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(length);
		scanf("%s",p1->num);
	}
	p2->next=null;
	return head;
}
void print(struct student *head)
{
	struct student *p,*q;
	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);
			q=p;
			p=p->next;
			free(q);
		}
		while(p!=null);

	}
}

struct student *converse(struct student *head)
{
	struct student *p1,*p2,*p3;
	p1=p2=head;

	if(head!=null)
	{
		while(p2->next!=null)
		{
			p3=p2->next;
			if(p2==head) p2->next=null;
			else p2->next=p1;
			p1=p2;
			p2=p3;
		}
		p2->next=p1;
		head=p2;
	}
	return head;
}

void main()
{

	struct student *p=create();
	p=converse(p);
	print(p);
}


struct stu
{
	char infor[1000];
	struct stu *next;
} *p1,*p2;
struct stu *creat(void)
{   struct stu *head=NULL;
	   p2=p1=(struct stu*)malloc(sizeof(struct stu));
   gets(p1->infor);
	while(strcmp(p1->infor,"end"))
	{
		if(head==NULL) head=p1;
	else  p2->next=p1;p2=p1;
	p1=(struct stu*)malloc(sizeof(struct stu));
	gets(p1->infor);
	}

p2->next=NULL;
return(head);
}
struct stu *back(struct stu *head)
{
	struct stu *newp,*newhead=NULL;
	do{ p2=NULL;p1=head;
	while(p1->next!=NULL) {p2=p1;p1=p1->next;}
		if(newhead==NULL) newhead=p1,newp=newhead->next=p2;
		newp=newp->next=p2;
		p2->next=NULL;
	}while(head->next!=NULL);
return (newhead);
}
void main()
{struct stu *head;
head=creat();
  head=back(head);
 for(p1=head;p1!=NULL;p1=p1->next)
  printf("%s\n",p1->infor);

}


struct s
{
      char a[100];
      char b[100];
      char c;
      int d;
      char e[100];
      char f[100];
      struct s *t;
      }k[1000];
int n;
int main(int argc, char *argv[])
{ int i;
    struct s *head,*p;
  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);
     if(i>0)
     k[i].t=&k[i-1];
     if(i==0)
     k[i].t=NULL;
  }
  head=&k[i-1];
  p=head;
  do{
  printf("%s %s %c %d %s %s\n",p->a,p->b,p->c,p->d,p->e,p->f);
  p=p->t;}
  while(p!=NULL);
  return 0;
}


char info[1000][1000];
int main() {
	int k=0;
	while(1) {
		cin.getline(info[k],999);
		if (info[k++][0]=='e') break;
	}
	k-=2;
	for (;k>=0;k--) {
		cout<<info[k]<<endl;
	}
	return 0;
}


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

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

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

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


struct student
{
	char id[100],name[100],sex[2];
	char sco[100];
	int age;
	char pos[100];
	struct student *pre;
};
int n;
struct student*creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s",&p1->id);
	if(strcmp(p1->id,"end")!=0)
	{
		scanf("%s%s%d%s%s",&p1->name,&p1->sex,&p1->age,&p1->sco,&p1->pos);
	}
	head=NULL;
	while(strcmp(p2->id,"end")!=0)
	{
		n=n+1;
		if(n==1)
		{
			head=p1;
			p1->pre=NULL;
		}
		else
			p2->pre=p1;
		p1=p2;
		p2=(struct student*)malloc(LEN);
		scanf("%s",&p2->id);
		if(strcmp(p2->id,"end")!=0)
		{
			scanf("%s%s%d%s%s",&p2->name,&p2->sex,&p2->age,&p2->sco,&p2->pos);
		}
	}
	return p1;
}
void print(struct student*head)
{
		struct student*p;
		p=head;
		if(head!=NULL&&strcmp(head->id,"end")!=0)
		{
			do
			{
				printf("%s %s %s %d %s %s\n",p->id,p->name,p->sex,p->age,p->sco,p->pos);
				p=p->pre;
			}while(p!=NULL);
		}
}
main()
{
	struct student*last;
	last=creat();
	print(last);
	return 0;
}


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

	  gets(p1->info);
	}
 return(head);
}
void print(struct student*head)
{struct student*p;
 p=head;
 while(p!=null)
	{printf("%s\n",p->info);
     p=p->next;
	}
}
main()
{struct student*head;
 head=creat();
 print(head);
}


void main()
{
	int n;
	struct student
	{
		char num[50];
		char name[100];
		char sex;
		int age;
		char score[20];
		char add[100];
		struct student *before;
	}*thisNode,*newNode;
	for(n=1;;n++)
	{
		newNode=(struct student *)malloc(sizeof(struct student));
		if(newNode==NULL)
		{
			printf("error!");
			exit(-1);
		}
		scanf("%s",newNode->num);
		if(n==1)
			newNode->before=NULL;
		else
			newNode->before=thisNode;
		if(newNode->num[0]=='e')
			break;
		scanf("%s %c %d %s %s",newNode->name,&newNode->sex,
			&newNode->age,newNode->score,newNode->add);
		thisNode=newNode;
	}
	for(;;)
	{
		printf("%s %s %c %d %s %s\n",thisNode->num,thisNode->name,thisNode->sex,
			thisNode->age,thisNode->score,thisNode->add);
		if(thisNode->before==NULL)
			break;
		thisNode=thisNode->before;
	}
}


struct stu
{
	char num[1000];
	struct stu*next;
};
struct stu*f()
{
	struct stu*head;
	struct stu*p,*q;
	p=q=0;
	p=(struct stu*)malloc(l);
	p->next=q;
	gets(p->num);
	q=p;
	while(1)
	{
		p=(struct stu*)malloc(l);
		p->next=q;
		q=p;
		gets(p->num);
		if(p->num[0]=='e') break;
	}
	head=p;
	return(head);
}
void y(struct stu*head)
{
	struct stu*p,*q;
	p=q=head;
	p=q->next;
	while(p!=0)
	{
		puts(p->num);
		q=p;
		p=q->next;
	}
}
main()
{
	y(f());
	return 0;
}


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

void main()
{
	struct node *head=NULL, *element;
	char str[100];
	gets(str);
	while(strcmp(str,"end"))
	{
		element=(struct node *)malloc(sizeof(struct node));
		strcpy(element->str,str);
		element->next=head;
		head=element;
		gets(str);
	}
	while(head!=NULL)
	{
		puts(head->str);
		head=head->next;
	}
}


struct stu
{char num[50];
char name[50];
char gentle;
int age;
int score;
char add[50];
struct stu *next;
};
int n;
struct stu *creat(void)
{
	struct stu *head,*p1,*p2;
	n=0;
	p1=p2=(struct stu *)malloc(sizeof(struct stu));
         gets(p1->num);
	head=NULL;
	while(strcmp(p1->num,"end")!=0)
	{
	n++;
	if(n==1) p1->next=NULL;
	else {p1->next=p2;}
	p2=p1;
	head=p2;
	p1=(struct stu *)malloc(sizeof(struct stu));
	gets(p1->num);
	}
	return head;
}
void print(struct stu *head)
{
	struct stu *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s\n",p->num);
		p=p->next;
	}
}
void main()
{
	struct stu *head;
	head=creat();
	print(head);
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char adress[20];
	struct student *next;
};
int n;
struct student *input(void)
{
	struct student *p,*q,*head;
	int n=0;
	p=q=(struct student *)malloc(sizeof(struct student));
	scanf("%s %s %c %d %s %s\n",p->num,p->name,&p->sex,&p->age,p->score,p->adress);
	head=null;
	while(strcmp(p->num,"end")!=0)
	{
		n=n+1;
		if(n==1)
		{
			head=p;
		}
		else
		{
			q->next=p;
		}
		q=p;
		p=(struct student*)malloc(sizeof(struct student));
		scanf("%s %s %c %d %s %s\n",p->num,p->name,&p->sex,&p->age,p->score,p->adress);
	}
	q->next=null;
	return(head);
}
void output(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->adress);
			p=p->next;
		}
		while(p!=null);
}
struct student *exchange(struct student * head)
{
	struct student *p,*q,* n,* nhead=null;
	do{
		q=null;
		p=head;
		while(p->next!=null)
		{
			q=p;
			p=p->next;
		}
		if(nhead==null)
		{
			nhead=p;
			n=nhead->next=q;
		}
		n=n->next=q;
		q->next=null;
	}while(head->next!=null);
	return(nhead);
}
int main()
{
	struct student *input(void);
	struct student *exchange(struct student *);
	void output(struct student *);
	struct student *a,*b;
	a=input();//??input???????a
	b=exchange(a);
	output(b);
	return 0;
}


struct STUDENT
{
	struct STUDENT *former;
	char num[20];
	char name[20];
	char sex;
	int age;
	float score;
	char address[20];
	struct STUDENT *next;
};
struct STUDENT stu;

void main()
{
	struct STUDENT *head,*p1,*p2,*p3;
	head=p1=p2=&stu;
	p3=NULL;
	for (;;)
	{
		scanf ("%s",p1->num);
		if (p1->num[0]=='e')
		{
			p2=p1->next;
			p2=NULL;
			p1=p3;
			break;
		}
		scanf ("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
		p2=p1->next;
		p2=(struct STUDENT *)malloc(LEN);
		p1->former=p3;
		p3=p1;
		p1=p2;
	}
	for (;;)
	{
		printf ("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p2=p1->former;
		p1=p2;
		if (p2==NULL)
			break;
	}
}


struct student
{
	char a[200];

	struct student *next;
};

struct student *creat ()
{
	struct student *p1,*p2,*head;
	int 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,*q;
	head=creat();
	p=head;
	while(1)
	{
		if(p->next!=NULL){q=p;p=p->next;}

	if(p->next==NULL&&q!=head)
			{
				printf("%s\n",p->a);
				q->next=NULL;p=head;
			}
			if(p->next==NULL&&q==head)
			{
				printf("%s\n",p->a);
				printf("%s",q->a);break;
			}
	}

}


struct student
{
	char NO[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char add[20];
	struct student *prev;
};
void main()
{
	struct student *END;
	struct student *p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s %s %c %d %s %s",&p1->NO,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
	p1->prev=0;
	p1=(struct student*)malloc(LEN);
	for(;;)
	{
		scanf("%s",&p1->NO);
		if(strcmp(p1->NO,"end")==0)
		{
			END=p2;
			break;
		}
		scanf(" %s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
		p1->prev=p2;
		p2=p1;
		p1=(struct student*)malloc(LEN);
	}
	for(p1=END;p1!=0;)
	{
		printf("%s %s %c %d %s %s\n",p1->NO,p1->name,p1->sex,p1->age,p1->score,p1->add);
		p1=p1->prev;
	}
}


struct student
{
	char infor[100];
	struct student *next;
}*p1,*p2;
struct student *creat(void)
{
	struct student *head;
	head=0;
	p1=0;
	p2=0;
	while(1)
	{
		p1=(struct student *)malloc(LEN);
		gets(p1->infor);
		if(strcmp(p1->infor,"end")==0)
			break;
		if(head==0)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
	}
	p2->next=0;
	return(head);
}
struct student *turnback(struct student *head)
{
	struct student *newhead=0,*p,*q,*r;
	do
	{
		p=head;
		q=0;
		while(p->next!=0)
		{
			q=p;
			p=p->next;
		}
		if(newhead==0)
		{
			newhead=p;
			newhead->next=q;
		}
		else
		{
			r=p;
			r->next=q;
		}
		q->next=0;
	}while(head->next!=0);
	return(newhead);
}

void output(struct student *head)
{
	struct student *p;
	for(p=head;p->next!=0;p=p->next)
		printf("%s\n",p->infor);
	printf("%s\n",p->infor);
}
void main()
{
	struct student *head;
	head=creat();
	head=turnback(head);
	output(head);
}


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

struct student *input(void)
{
	char temp[100]={0};
	struct student *head=NULL;

	while(gets(temp))
	 {
		if(strcmp(temp,"end")==0)break;
	    p1=(struct student *)malloc(sizeof(struct student));
	    sscanf(temp,"%s%s %c %d %s%s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add);

	    if(head==NULL)
		{
			head=p1,p2=p1;
		}
	    else
		{
			p2->next=p1;
			p2=p1;
			p2->next=NULL;
		}
	 }
	 return(head);
}

struct student *sort(struct student *head)
{
 struct student *n,*newhead=NULL;
	 do
	 {
		  p2=NULL;
		  p1=head;
		  while(p1->next!=NULL) p2=p1,p1=p1->next;
		  if(newhead==NULL)
		   newhead=p1,n=newhead->next=p2;
		  n=n->next=p2;
		  p2->next=NULL;
	 }while(head->next!=NULL);

	 return(newhead);
}

void output(struct student *outhead)
{
	for(p1=outhead;p1!=NULL;p1=p1->next)
		printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
}

int main()
{
	 struct student *head;
	 head=input();
	 head=sort(head);
	 output(head);
	 printf("\n");
	 return 0;
}


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

struct student *creat(void)//????????CREAT?????
{

	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(LEN);//????????
	p2->next=NULL;
	scanf("%s",p1->num);//??num
    while(strcmp(p1->num,"end")!=0)//?NUM????????
	{
		scanf("%s %c%d%s%s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);//????????
		p1=(struct student *)malloc(LEN);//???????
		p1->next=p2;//????
		p2=p1;
        scanf("%s",p1->num);//????????
	}
	return(p2);
}

void print(struct student *head)//??????
{
	struct student *p;
	p=head->next;
	if(p!=NULL)
		do
		{printf("%s %s %c %d %s %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;
	struct student *creat(void);//????
	void print(struct student *);//????
    head=creat();//??????
    print(head);//??????
}


struct stu
{ char no[20],sx,nm[30],rm[20],mk[10];
  int age;
  struct stu* next;
};
main()
{  struct stu *p1,*p2,*head;
   int i;
   void output(struct stu *p,struct stu* p2);
   for(i=0;;i++)
   {  p1=(struct stu*)malloc(L);

      if(i==0)head=p1;
      scanf("%s",p1->no);
      if(strcmp(p1->no,"end")==0)break;
      else
      { if(i==0)head=p1;
	 scanf("%s %c%d%s%s",p1->nm,&p1->sx,&p1->age,p1->mk,p1->rm);
	if(i==0){head->next=NULL;p2=head;}
	else {
	p2->next=p1;
	p2=p1;
	p2->next=NULL;}
      }
   }
   output(head,head);
}
void output(struct stu* p,struct stu* p2)
{
  if(p->next!=NULL)output(p->next,p2);
  printf("%s %s %c %d %s %s",p->no,p->nm,p->sx,p->age,p->mk,p->rm);
  if(p!=p2)printf("\n");

}


struct stdnt
{
char num[20];
char name[20];
char gndr;
int age;
double score;
char adrs[30];
struct stdnt* next;
};

int n;

struct stdnt *creat()
{
struct stdnt *p1,*p2=0;
p1=(struct stdnt*)malloc(LEN);
for (n=0;;n++)
    {
    if (n==0) p1->next=0;
    scanf("%s",p1->num);
    if (strcmp(p1->num,"end")==0)
       break;
    else p2=p1;
    scanf("%s %c%d%lf %s",p1->name,&p1->gndr,&p1->age,&p1->score,p1->adrs);
    p1=(struct stdnt*)malloc(LEN);
    p1->next=p2;
    }
return p1->next;
}

void output(struct stdnt* p)
{
while (p!=0)
      {
      printf("%s %s %c %d %g %s\n",p->num,p->name,p->gndr,p->age,p->score,p->adrs);
      p=p->next;
      }
}

int main()
{
struct stdnt *p;
p=creat();
output(p);

}


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

struct student *create(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s %s %c %d %s %s",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->grade,&p1->address);
	for(n=0;p1->sex=='f' || p1->sex=='m' ;n++)
	{
		if(n==0) p1->next=NULL;
		else p1->next=p2;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s %s %c %d %s %s",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->grade,&p1->address);
	}
	head=p2;
	return(head);
}

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

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

}


/*?? ?? ?? ?? ?? ??*/
struct student
{
	struct student *pre;
	char num[100];
	char name[20];
	char sex[2];
	char age[10];
	char score[10];
	char ad[100];
	struct student *next;
};
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;
			p2=p1;
		}
		else
			p1->pre=p2;
			p2=p1;
			p1=(struct student *)malloc(LEN);
			scanf("%s",p1->num);
	}
	end=p2;
	p=end;
	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 student
{
	char num[10];
	char name[20];
	char sex[5];
	int age;
	char score[20];
	char addr[20];
	struct student *next;
};
struct student *head;
struct student *input()
{
	struct student *p1,*p2;
		p1=p2=(struct student *)malloc(sizeof(struct student));
		scanf("%s",p1->num);
		p2->next=NULL;
		while(strcmp(p1->num,"end")!=0)
		{
			scanf("%s",p1->name);
			scanf("%s",p1->sex);
			scanf("%d",&p1->age);
			scanf("%s",p1->score);
			scanf("%s",p1->addr);
			p1=(struct student *)malloc(sizeof(struct student));
			scanf("%s",p1->num);
			p1->next=p2;
			p2=p1;
		}
			head=p1;
			return(head);
}
void print(struct student *head)
{
	struct student *p;
	p=head->next;
	if(head!=NULL)
		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);
}
main()
{
	input();
	print(head);
	return 0;
}


struct stu
{
	char xuehao[20];
	char xingming[30];
	char xingbie;
	int nianling;
	char defen[10];
	char dizhi[20];
	struct stu *last;
};
main()
{
struct  stu  a[10000],*p;
int i=0;
a[0].last=NULL;
for(;;i++)
{
scanf("%s",a[i].xuehao);
if(a[i].xuehao[0]=='e')
break;
scanf("%s %c %d %s %s",a[i].xingming,&a[i].xingbie,&a[i].nianling,a[i].defen,a[i].dizhi);
if(i>0)
{
a[i].last=a+i-1;
}
p=(a+i);
}

while(p!=NULL)
{
printf("%s %s %c %d %s %s\n",p->xuehao,p->xingming,p->xingbie,p->nianling,p->defen,p->dizhi);
p=p->last;
}
}


struct student
{char num[10];
char name[20];
char sex;
int age;
char score[10];
char adr[30];
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);
scanf("%s",&p1->num);
if (strcmp(p1->num,"end")==0){/*delete p1;*/break;}
scanf(" %s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->adr);
if(head==NULL)head=p1;
else p1->previous=p2;
p2=p1;
}
/*p1->previous=p2;*/
end=p2;
p=end;
if(end!=NULL)
do
{printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->adr);
p=p->previous;
}while(p!=NULL);
}


struct s{
	char xuehao[20];
	char xingming[20];
	char xingbie;
	int age;
	char score[20];
	char add[20];
	struct s *next;
};
int main(){
	struct s *A(void);
	struct s *head,*p;
	head=A();
	p=head;
	if(head!=NULL){
		while(p->next!=NULL){
			printf("%s %s %c %d %s %s\n",p->xuehao,p->xingming,p->xingbie,p->age,p->score,p->add);
			p=p->next;
		}
		printf("%s %s %c %d %s %s\n",p->xuehao,p->xingming,p->xingbie,p->age,p->score,p->add);
	}
	return 0;
}

struct s *A(void){
	struct s *head,*p1,*p2;
	head=(struct s*)malloc(sizeof(struct s));
	scanf("%s %s %c %d %s %s",head->xuehao,head->xingming,&head->xingbie,&head->age,head->score,head->add);
	head->next=NULL;
	p1=head;
	for(;;){
		p2=(struct s*)malloc(sizeof(struct s));
		scanf("%s",p2->xuehao);
		if(strcmp(p2->xuehao,"end"))
			scanf(" %s %c %d %s %s",p2->xingming,&p2->xingbie,&p2->age,p2->score,p2->add);
		else
			break;
		p2->next=p1;
		p1=p2;
	}
	p2->next=p1;
	return (p1);
}


struct student
{char num[10];
char name[20];
char fm;
int age;
int score;
char add[50];
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->num);
head=NULL;
while(strcmp(p1->num,"end")!=0)
{n=n+1;
if(n==1) p1->next=NULL;
else p1->next=p2;p2=p1;head=p2;
p1=(struct student*)malloc(LEN);
gets(p1->num);
                 }

return head;
}

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

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


struct student
{
	char c[60];
	struct student *next;
};
struct student *creat(void)
{
	struct student *head,*p1;
	p1=(struct student *) malloc(LEN);
	head=p1;
	head->next=NULL;
	gets(p1->c);
	while(strcmp(p1->c,"end"))
	{
	p1=(struct student *) malloc(LEN);
		gets(p1->c);
	p1->next=head;
	head=p1;
	}
	return(head);
}
void print(struct student *head)
{
	struct student *p=head->next;
	do{puts(p->c);p=p->next;}while(p->next!=NULL);
	puts(p->c);
}
void main()
{
	struct student *p=creat();
	print(p);
}


struct stu
{
	char xh[20],mz[20],xb,dz[20],df[20];
	int nl;
};
int main()
{
	struct stu a[10000];
	int n=0,i;
	char str[4]="end",c;
	scanf("%s",a[0].xh);
	while(strcmp(a[n].xh,str)!=0)
	{
		scanf("%s",a[n].mz);
		c=getchar();
		scanf("%c",&a[n].xb);
		scanf("%d",&a[n].nl);
		scanf("%s",&a[n].df);
		c=getchar();
		scanf("%s",a[n].dz);
		c=getchar();
		n++;
		scanf("%s",a[n].xh);
		c=getchar();
	}
	for(i=n-1;i>=0;i--)
	printf("%s %s %c %d %s %s\n",a[i].xh,a[i].mz,a[i].xb,a[i].nl,a[i].df,a[i].dz);
	return 0;
}


struct student
{
	char num[20];
	char name[20];
	char sex[5];
	char age[5];
	char score[10];
	char address[20];
	struct student *next;
};
int main()
{
	struct student *head,*p1,*p2,*end;
	char c;
	int i1,n1;
	p1=p2=(struct student*)malloc(sizeof(struct student));
	scanf("%s%s%s%s%s",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->score);
	i1=0;
	while((c=getchar())!='\n')
	{
		p1->address[i1]=c;
		i1++;
	}
	for(;i1<=19;i1++)
		p1->address[i1]='\0';
	head=p1;
	n1=0;
	while(p1->num[0]!='e')
	{
		n1=n1+1;
		p2=p1;
		p1=(struct student*)malloc(sizeof(struct student));
		scanf("%s",&p1->num);
		if(p1->num[0]=='e') break;
		scanf("%s%s%s%s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->score);
		i1=0;
		while((c=getchar())!='\n')
		{
			p1->address[i1]=c;
			i1++;
		}
		for(;i1<=19;i1++)
			p1->address[i1]='\0';
		if(n1==1) p1->next=head;
		else p1->next=p2;
	}
	end=p2;//input

	p1=end;
	i1=0;
	while(p1!=head)
	{
		printf("%s %s %s %s %s%s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p1=p1->next;
	}
	printf("%s %s %s %s %s%s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);

}


struct student //?????
{
	char id[10];
	char name[20];
	char gender;
	int age;
	char score[10];
	char address[20];
	struct student *next, *up;//next?????????,up???????????????????
};
int main()
{
		struct student *head, *tail, *p, *r,*q;
	p=r=head=(struct student *)malloc(len);//head???????
	p->up=NULL;//??????up????null??????????up??????????????
	do
	{
		scanf("%s",p->id);
		if(strcmp(p->id,"end")!=0)//???????end??????????
		{
			scanf("%s %c %d %s %s",p->name,&p->gender,&p->age,p->score,p->address);
			p->next=r=(struct student *)malloc(len);//??????next???????up???????
			r->up=p;
			p=r;
		}
		else
		{
			p->next=NULL;//??????
			tail=p->up;//?tail????????????????up???????????
			break;
		}
	}while(1);
	q=tail;
	do
	{
		printf("%s %s %c %d %s %s\n",q->id,q->name,q->gender,q->age,q->score,q->address);//?up?????
		q=q->up;
	}while(q!=NULL);
		return 0;
}


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

int main()
{
	struct student *p1,*p2;
	p1=(struct student *)malloc(len);
	p1->next=NULL;
	scanf("%s",p1->num);
	while(strcmp(p1->num,"end")!=0){
		scanf("%s %c %d %f %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);
	}
	return 0;
}


struct node;
struct node
{
    char id[len];
    char name[len];
    char sexual[len];
    char age[len];
    char score[len];
    char addr[len];
    struct node* next;
    struct node* pre;
};
char end[len]="end";
int main(){

    struct node* p;
    p=(struct node*)malloc(sizeof(struct node));
    p->pre=NULL;
    while(1){
        scanf("%s",p->id);
        if(strcmp(p->id,end)==0)
            break;
        scanf("%s%s%s%s%s",p->name,p->sexual,p->age,p->score,p->addr);
        p->next = (struct node*) malloc(sizeof(struct node));
        p->next->pre = p;
        p=p->next;
    }
    p=p->pre;
    free(p->next);
    while(p!=NULL){
        printf("%s %s %s %s %s %s\n",p->id,p->name,p->sexual,p->age,p->score,p->addr);
        p=p->pre;
        if(p!=NULL)
            free(p->next);
    }
    return 0;
}


struct student
{
	char num[30];//???????end??strcpy??
	char name[30];
	char sex;
	int age;
	char score[30];//???????????
         char add[30];
	struct student *next;
}*p1,*p2;//???????????
int n;//????

struct student *creat(void)     //????
{
	struct student *head=NULL;
	char temp[30]={"end"};
	n=0;
         p1=p2=(struct student*)malloc(LEN);// ?????
	scanf("%s",p1->num);

	while(strcmp(p1->num,temp)!=0)//?????end???

	{
		scanf(" %s %c %d %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);//????????while??

	}
	p2->next=NULL;
    return(head);
}

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

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


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


struct stu
{
	char a[100];
	struct stu * next;
};
struct stu * create()
{
	struct stu *head,*p1,*p2;
	p2=p1=(struct stu *) malloc (sizeof(struct stu));
	gets(p1->a);
	p1->next=0;
	while(!(p1->a[0]==101&&p1->a[1]==110&&p1->a[2]==100))
	{
		p1=(struct stu *) malloc (sizeof(struct stu));
		gets(p1->a);
		p1->next=p2;
		p2=p1;
	}
	return p1->next;
}
void print (struct stu *p)
{
	while(p!=0)
	{
		printf("%s\n",p->a);
		p=p->next;
	}
}
int main()
{
	struct stu *p;
	p=create();
	print(p);
	return 0;
}


struct student
{char info[100];
struct student *next1;
struct student *next2;
};
int n,i;
struct student *creat(void)
{
struct student *p1,*p2,*p3;
n=0;
p3=p2=p1=(struct student*)malloc(LEN);
gets(p1->info);
while(p1->info[0]!='e')
{
n+=1;
if(n==1){p2->next1=p1;
p2->next2=NULL;}
else {p2->next1=p1;
p2->next2=p3;}
p3=p2;
p1=(struct student *)malloc(LEN);
gets(p1->info);
p2=p1;
}
p3->next1=NULL;
return p3;
}

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

int main()
{struct student *top;
top=creat();
print(top);
}


char str[]={"end"};
struct student
{
	char num[100];
	char name[100];
	char sex;
	int age;
	char score[100000];
	char add[100];
	struct student *next;
};
struct student *create()
{
	struct student *head,*p1,*p2;
	p1=(struct student*)malloc(Len);
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add);
	p1->next=NULL;
	p2=p1;
    p1=(struct student*)malloc(Len);
	for(;;)
    {scanf("%s",p1->num);
	if(!strcmp(p1->num,str)) break;
	else
	{
       scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
	p1->next=p2;
	p2=p1;
	p1=(struct student*)malloc(Len);
	}
	}
	head=p2;return(head);

}
void main()
{
	struct student *p;

	p=create();
	do
	{printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
	p=p->next;
	}while(p!=NULL);

}


struct student
{
      char a[100];
      char b[100];
      char c;
      int d;
      char e[100];
      char f[100];
      struct student *t;
      }k[1000];
int n;
int main()
{ int i;
    struct student *head,*p;
  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);
     if(i>0)
     k[i].t=&k[i-1];
     if(i==0)
     k[i].t=NULL;
  }
  head=&k[i-1];
  p=head;
  do{
  printf("%s %s %c %d %s %s\n",p->a,p->b,p->c,p->d,p->e,p->f);
  p=p->t;}
  while(p!=NULL);
  return 0;
}


struct Student
{
char number[100];
char name[100];
char sex;
int age;
char score[20];
char address[100];
struct Student *next;
struct Student *front;
};
int n;
void main()
{
	struct Student*p1,*p2;
	struct Student*head;
	n=0;
	p1=p2=(struct Student*)malloc(LEN);
	scanf("%s %s %c%d%s%s",p1->number,p1->name,&p1->sex,&p1->age,p1->score,p1->address);
	p1->front=NULL;
	while(p1->number[0]!='e'||p1->number[1]!='n'||p1->number[2]!='d')
	{
			n=n+1;
            if(n==1)head=p1;
            else
			{
			p2=p1;
			p1=(struct Student*)malloc(LEN);
			scanf("%s %s %c%d%s%s",&p1->number,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);
			p1->front=p2;
			}
	}
	while(p2!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p2->number,p2->name,p2->sex,p2->age,p2->score,p2->address);
		p2=p2->front;
	}
}


void main()
{
	struct student
{
	char stu[100];
	struct student *next;
	struct student *prev;
}*head,*p1,*p2,*p;

	int n;
	p1=p2=(struct student *)malloc(LEN);
	gets(p1->stu);
	p1->prev=NULL;
	while(strcmp(p1->stu,"end")!=0)
	{
		p1=(struct student*)malloc(LEN);
		p1->prev=p2;
		gets(p1->stu);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;

	p=p2;

		do
		{
			p=p->prev;
			printf("%s\n",p->stu);

		}while(p->prev!=NULL);
	}


struct Student
 {
	char num[50];
	char name[50];
	char x;
	int age;
	float score;
	char ad[50];
	struct Student *next;
 };

struct Student *create(void)
{
	struct Student *head,*p1,*p2;
	int n=0;
	char end[5]="end\0";
	p1=(struct Student*)malloc(LEN);
	p2=p1;
	scanf("%s",p1->num);
	scanf("%s %c%d%f%s",p1->name,&p1->x,&p1->age,&p1->score,p1->ad);
	head=NULL;
	for(;;)
	{
	 n=n+1;
	 if(n==1)head=p1;
	 else p1->next=head;
	 head=p1;
	 p1=(struct Student*)malloc(LEN);

	 scanf("%s",p1->num);
	 if(strcmp(p1->num,end)==0)break;
	 scanf("%s %c%d%f%s",p1->name,&p1->x,&p1->age,&p1->score,p1->ad);
    }
	p2->next=NULL;
	return(head);
}
void print(struct Student *head)
{   struct Student *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->x,p->age,p->score,p->ad);
		p=p->next;
    };

}
main()
{
	struct Student *pt;
	pt=create();
	print(pt);

}


void main()
{
 struct student
{
 char str[100];
 struct student *before;
 struct student *next;
 }*head,*p1,*p2;
 p1=(struct student *)malloc(sizeof(struct student));
 p1->before=NULL;
 head=p1;
 while(strcmp(p2->str,"end")!=0)
 {
  gets(p1->str);
  p2=p1;
  p1=(struct student*)malloc(sizeof(struct student));
  p1->before=p2;
  p2->next=p1;
 }
  p2->next=NULL;
  p2=p2->before;
  do
  {
   printf("%s\n",p2->str);
   p2=p2->before;
  }while(p2->before!=NULL);
  printf("%s\n",p2->str);
}


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

struct stu *creat()
{
	struct stu *head,*p1,*p2;
	p1=(struct stu *)malloc(LEN);
	scanf("%s %s %c %d %lf %s ",&p1->num,&p1->name,&p1->sex,&p1->age,&p1->x,&p1->add);
	p2=p1;head=p1;
	p1->next=NULL;
	while(1)
	{
	p1=(struct stu *)malloc(LEN);
	scanf("%s ",&p1->num);
	if(p1->num[0]!='e')
	{
	    scanf("%s %c %d %lf %s ",&p1->name,&p1->sex,&p1->age,&p1->x,&p1->add);
	    p1->next=p2;
	    p2=p1;
	}
	else
		break;
	}
	return p2;
}
void print(struct stu *head)
{
	struct stu *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->x,p->add);
		p=p->next;
	}
}
void destroy(struct stu *head)
{
	struct stu *p;
	while(head)
	{
		p=head;
		head=head->next;
		free(p);
	}
}

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


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 *p,*head,*q;
	p=(struct student*)calloc(1000,sizeof(struct student));
	int i,k;
	for(i=0;;i++)
	{
		scanf("%s",p[i].num);
        if(p[i].num[0]=='e')
			break;
		scanf("%s %c %d %s %s",p[i].name,&p[i].sex,&p[i].age,p[i].score,p[i].address);
	}
    k=i-1;
	head=&p[k];
	for(i=k;i>=1;i--)
		p[i].next=&p[i-1];
	p[0].next=NULL;
	q=head;
	do
	{
		printf("%s %s %c %d %s %s\n",q->num,q->name,q->sex,q->age,q->score,q->address);
		q=q->next;
	}
	while(q!=NULL);
}


struct stu
{char a[100];
struct stu *next;
};
int main()
{struct stu *head,*p1,*p2;
head=(struct stu *)malloc(sizeof(struct stu));
p1=head;
p2=head;
p1->next=0;
    while(1)
{
    gets(p1->a);
    if(strcmp(p1->a,"end")==0)
    break;
    else
    head=p1;
    p1=(struct stu *)malloc(sizeof(struct stu));

   p1->next=p2;
   p2=p1;
}

p1=head;
while(1)
{
puts(p1->a);
if(p1->next==0)
break;
p1=p1->next;
}

   return 0;
}


struct student{
	struct student *pre;
    char No[10];
	char name[20];
	char sex;
	int age;
	float grade;
	char address[20];
	struct student *next;
};
struct student *create(){
    struct student *head,*p1,*p2,*h,*p;
	p1=(struct student *)malloc(sizeof(struct student));
	scanf("%s",p1->No);
	if(p1->No[0]=='e'){
	    free(p1);
		head=NULL;
		return head;
	}
	else{
	    scanf("%s",p1->name);
		getchar();
		scanf("%c",&p1->sex);
		scanf("%d",&p1->age);
		scanf("%f",&p1->grade);
		scanf("%s",p1->address);
		p1->next=NULL;
	}
	head=p1;
	p2=p1;
	for(;;){
        p1=(struct student *)malloc(sizeof(struct student));
	    scanf("%s",p1->No);
	    if(p1->No[0]=='e'){
			head->pre=NULL;
		    for(h=head;h->next!=NULL;){
		    p=h->next;
			p->pre=h;
			h=h->next;
		}
	    free(p1);
		return head;
		}
	    else{
	    scanf("%s",p1->name);
		getchar();
		scanf("%c",&p1->sex);
		scanf("%d",&p1->age);
		scanf("%f",&p1->grade);
		scanf("%s",p1->address);
		p1->next=NULL;
		}
		p2->next=p1;
		p2=p1;
	}
}
void destroy(struct student *head){
    struct student *p;
	for(;head!=NULL;){
	    p=head;
        head=head->next;
		free(p);
	}
}
void main()
{
	struct student *h,*t,*h1;
	h=create();
    for(h1=h;h1->next!=NULL;){
	    h1=h1->next;
	}
	for(t=h1;t!=NULL;t=t->pre){
	printf("%s %s %c %d %g %s\n",t->No,t->name,t->sex,t->age,t->grade,t->address);
    }
	destroy(h);
}


main()
{
	struct a
	{
		char s[100];
		struct a *next;
	};
	int len=sizeof(struct a),n=0;
	struct a *p1,*p2,*head,*p;
	p1=p2=(struct a *)malloc(len);
	head=NULL;
	gets(p1->s);
	while(strcmp(p1->s,"end")!=0)
	{
		n++;
		if(n==1)
			head=p1;
		else
			p1->next=p2;
		p2=p1;
		p1=(struct a *)malloc(len);
		gets(p1->s);
	}
	head->next=NULL;
	p=p2;
	if(head!=NULL)
	{
		do
		{
			puts(p->s);
			p=p->next;
		}while(p!=NULL);
	}
}


struct Student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char add[20];
	struct Student *next;
};
int n;
struct Student *creat()
{
	struct Student *head,*p1,*p2;
	p1=p2=(struct Student *) malloc(LEN);
	scanf("%s",&p1->num);
	while(p1->num[0]!='e')
	{
		n++;
		scanf("%s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add);
		if(n==1) p1->next=NULL;
		else
		{
			p1->next=p2;
			p2=p1;
		}
		p1=(struct Student *) malloc(LEN);
		scanf("%s",&p1->num);
	}
	head=p2;
	return head;
}
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->add);
			p=p->next;
		}while(p!=NULL);
}
void main()
{
	struct Student *head;
	head=creat();
	print(head);
}


int main()
{
	struct student
	{
		char imfor[100];
		struct student *early;
	};

	int m;
	struct student *p1,*p2,*last,*p;
	p1=p2=(struct student *)malloc(sizeof(struct student));
	gets(p1->imfor);
	p1->early=0;
	for (m=1;m<1000;m++)
	{
		p1=(struct student * )malloc(sizeof(struct student));
		p1->early=p2;
		p2=p1;
		gets(p1->imfor);
		if (p1->imfor[0]=='e')
		{
			last=p1->early;
			break;
		}

	}
	p=last;
	for (m=1;m<1000;m++)
	{
		printf("%s\n",p->imfor);
		p=p->early;
		if (p==0)
		{
			break;
		}
	}
}


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

main()
{
      struct student *p,*p1,*p2,*header;
        header=(struct student *)malloc(sizeof(struct student));
        header->next=header->former=NULL;
        p2=header;
       for(;;)
        {
           p1=(struct student *)malloc(sizeof(struct student));
           p2->next=p1;
           p1->former=p2;
           scanf("%s",p1->num);
           if(p1->num[0]=='e'&&p1->num[1]=='n'&&p1->num[2]=='d') break;
           scanf("%s %c %d %lf %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
           p2=p1;
           }
        p2->next=NULL;
        free(p1);
               p=p2;
               for(;p->former!=NULL;)
               {
                 if(p->score==(int)(p->score))

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

                 else printf("%s %s %c %d %.1lf %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
                 p=p->former;
                 }
      p1=p2;
      for(;p1->former!=NULL;)
      {
       p2=p1;
       p1=p2->former;
       free(p2);
       }
       free(p1);

      }


struct stru
{
	struct stru *pre;
	char msg[200];
	struct stru *next;
}*head, *p,*q,*end;

void creat()
{
	char temp[200];
	p=q=(struct stru *)malloc(LEN);
	head=p;
	head->pre=NULL;
	gets(p->msg);
	while(1)
	{
		gets(temp);
		if(strcmp(temp,"end")!=0)
		{p=(struct stru *)malloc(LEN);
		strcpy(p->msg,temp);
		p->pre=q;
		q->next=p;
		q=p;}
		else
			break;
	}
	q->next=NULL;
	end=q;
}

void print(struct stru *end)
{
	for(p=end;p!=NULL;p=p->pre)
		printf("%s\n",p->msg);
}

void main()
{
	creat();
	print(end);
}


struct student
{
	char id[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char address[20];
	struct student *next;
	struct student *pre;
};
struct student *create(void)
{
	struct student *head,*p1,*p2,*end;
	p1=(struct student *)malloc(LEN);
	scanf("%s %s %c %d %s %s",p1->id,p1->name,&p1->sex,&p1->age,p1->score,p1->address);
	p1->next=NULL;
	p1->pre=NULL;
	head=p1;
	p2=p1;
	do
	{
		p1=(struct student*)malloc(LEN);
		scanf("%s",p1->id);
		if(strcmp("end",p1->id)==0)
		{
			break;
		}
		else
		{
			scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->address);
		    p1->next=NULL;
		    p1->pre=NULL;
			p2->next=p1;
			p1->pre=p2;
			p2=p1;
		}
	}while(1);
	end=p2;
	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->pre;
	}
}

int main()
{
	struct student *end;
	end=create();
	print(end);
}


int n;
struct student
{
	char str[100];
	struct student *pre;
} *p1, *p2;

struct student *create(void)
{
	struct student *last, *head;
	p1 = p2 = (struct student *)malloc(sizeof(struct student)); //????
	gets(p1->str);//?????
	head=NULL;
	n=0;
	while (strcmp(p1->str,"end")!=0)
	{
		    n=n+1;	//??????
		if (n==1)
		{
			head=p1;
			p1->pre = NULL;//??????pre??
		}
		else
		{
			p1->pre = p2;//????pre????????

		}
		    p2 = p1;//?????
		    p1 = (struct student *)malloc(sizeof(struct student));//????
			gets(p1->str);

	}
	last=p1->pre=p2;
	return (last);
}
void main ()
{
	 struct student *create();
	 struct student *last, *p;
	 last=create();
	 p=last;
    do
	 {
          printf("%s\n", p->str);
            p=p->pre;
	 }
	 while (p->pre!=NULL);
	 if(p->pre==NULL)
      printf("%s\n", p->str);

}


struct stu
{
	char num[10];
	char name[20];
	char sex;
	int age;
	float mark[6];
	char add[10];
	struct stu *next;
};
int n;
struct stu *creat(void)
{
	struct stu *head;
	struct stu *p1,*p2;
	n=0;
	p1=p2=(struct stu *)malloc(sizeof(struct stu));
	scanf("%s",p1->num);
	if(strcmp(p1->num,"end")==0)
	{
		free(p1);
		head=NULL;
		return head;
	}
	else
	{
		scanf(A,p1->name,&p1->sex,&p1->age,p1->mark,p1->add);
		head=p1;
		p2=p1;
		p1->next=NULL;
		do
		{
			p1=(struct stu *)malloc(sizeof(struct stu));
			scanf("%s",p1->num);
			if(strcmp(p1->num,"end")==0)
			{
		         free(p1);
		         break;
			}
			else
			{
				scanf(A,p1->name,&p1->sex,&p1->age,p1->mark,p1->add);
				head=p1;
				p1->next=p2;
				p2=p1;
			}
		}while(1);
		return head;
	}
}

int main(void)
{
	struct stu *p;
	struct stu *head;
	p=creat();
	while(p)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->mark,p->add);
		p=p->next;
	}
}


struct stu
{
	char num[111];
	char name[111];
	char gender;
    int age;
	char score[11111];
	char add[111];
	struct stu *next;
};
int n;
struct stu *creat()
{

	struct stu *head;
	struct stu *p1,*p2;
	n=0;
	p1=(struct stu *)malloc(L);
    scanf("%s",p1->num);
    if(strcmp(p1->num,"end"))
		scanf("%s %c %d %s %s",p1->name,&p1->gender,&p1->age,p1->score,p1->add);
	else return NULL;
    while(1)
	{
		n=n+1;
		if(n==1) p1->next=NULL;
		else p1->next=p2;
		p2=p1;
		p1=(struct stu *)malloc(L);
		scanf("%s",p1->num);
	    if(strcmp(p1->num,"end"))
		scanf("%s %c %d %s %s",p1->name,&p1->gender,&p1->age,p1->score,p1->add);
		else break;
	}
	head=p2;
	return(head);
}

void main()
{
	int i;
	struct stu *p;
	p=creat();
	while(p)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->gender,p->age,p->score,p->add);
		p=p->next;

	}
}


struct student
{
 char xuehao[20];
 char name[30];
 char sex;
 int age;
 char score[20];
 char adress[40];
 struct student *next;
};
void insert (struct student *pheader)
{
 struct student *p;
 p=(struct student *)malloc(sizeof(struct student));
 p->next=pheader->next;
 pheader->next=p;
}
main()
{
 struct student *pheader,*p;
 pheader=(struct student *)malloc(sizeof(struct student));
 pheader->next=NULL;
 while(9)
 {
  insert(pheader);
  scanf("%s",pheader->next->xuehao);
  if(pheader->next->xuehao[0]=='e')
    break;
  scanf("%s %c %d %s %s",pheader->next->name,&pheader->next->sex,&pheader->next->age,&pheader->next->score,pheader->next->adress);
 }
 p=pheader->next;
 while(9)
 {
   p=p->next;
   printf("%s %s %c %d %s %s\n",p->xuehao,p->name,p->sex,p->age,p->score,p->adress);
   if(p->next==NULL)
     break;
 }
 while(9){
 if(pheader->next->next==NULL)
   break;
 p=pheader->next;
 pheader->next=p->next;
 free(p);}
 free(pheader->next);
 free(pheader);
}


struct student
{
            char str[50];
            struct student *next;
            };
struct student *creat()
{
       struct student *head=NULL,*p1,*p2;
       p1=p2=(struct student*)malloc(Len);
       gets(p1->str);
       while(strcmp(p1->str,"end")!=0)
       {

                           if(head==NULL)head=p1;
                           else p2->next=p1;
                           p2=p1;
                           p1=(struct student*)malloc(Len);
                           gets(p1->str);
       }
       p2->next=NULL;
       return(head);
}

struct student *re(struct student *head)
{
       struct student *p1,*p2,*newhead=NULL,*n;
       do
       {p1=head;
       p2=NULL;
       while(p1->next!=NULL)p2=p1,p1=p1->next;
       if(newhead==NULL)newhead=p1,n=newhead->next=p2;
       n=n->next=p2;
       p2->next=NULL;
       }while(head->next!=NULL);
       return(newhead);
}

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();
     head=re(head);
     print(head);

}


char ex[4]={"end"};
struct student
{
	char n[100];
	struct student *next;
};
void main()
{
	int n=0;
	struct student *a=NULL,*b=NULL;
	struct student *head,*p1,*p2;
	head=NULL;
	p1=(struct student*)malloc(LEN);
	p2=NULL;
	gets(p1->n);
	while(strcmp(ex,p1->n)!=0)
	{
		p1->next=p2;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		gets(p1->n);
	}
	p1=NULL;
	head=p2;
	a=head;
	while(a!=NULL)
	{
		puts(a->n);
		b=a->next;
		a=b;
	}
}


typedef struct Student
{
	char ALL[100];
	struct Student *pNext;
	struct Student *pPrev;
}Stu;
int main(void)
{
	Stu *pRoot=(Stu *)malloc(sizeof(Stu));
	Stu *pNow=pRoot;
	pRoot->pPrev=NULL;
	for(;;)
	{
		gets(pNow->ALL);
		if(strcmp("end",pNow->ALL))
		{
			pNow->pNext=(Stu *)malloc(sizeof(Stu));
			pNow->pNext->pPrev=pNow;
			pNow=pNow->pNext;
		}
		else break;
	}
	pNow=pNow->pPrev;
	for(;;)
	{
		puts(pNow->ALL);
		if(pNow->pPrev==NULL) break;
		pNow=pNow->pPrev;
	}
	return 0;
}


struct Student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char add[20];
	struct Student *next;
};
int n=0;
struct Student*create()
{
	struct Student*head;
	struct Student*p1,*p2;
	n=0;
	p1=p2=(struct Student*)malloc(sizeof(struct Student));
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&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(sizeof(struct Student));
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")!=0)
			scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);

	}
p2->next=NULL;

return (head);
}

void print(struct Student *head)
{
	struct Student*p;
	p=head;
	if(p->next!=NULL)print(p->next);
	printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);

}
int main()
{
	struct Student *head;
	head=create();
	print(head);
	return 0;
}
//
//p=p->next;


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

main()
{
      struct student *p,*p1,*p2,*header;
        header=(struct student *)malloc(sizeof(struct student));
        header->next=header->former=NULL;
        p2=header;
       for(;;)
        {
           p1=(struct student *)malloc(sizeof(struct student));
           p2->next=p1;
           p1->former=p2;
           scanf("%s",p1->num);
           if(p1->num[0]=='e'&&p1->num[1]=='n'&&p1->num[2]=='d') break;
           scanf("%s %c %d %lf %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
           p2=p1;
           }
        p2->next=NULL;
        //free(p1);
               p=p2;
               for(;p2->former!=NULL;)
               {
                 if(p2->score==(int)(p2->score))

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

                 else printf("%s %s %c %d %.1lf %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->address);
                 p2=p2->former;
                 }
     // p1=p;
    //  for(;p1->former!=NULL;)
    // {
      // p2=p1;
      // p1=p2->former;
      // free(p2);
     //  }
      // free(p1);

      }


void main()
{
	struct student
	{
	char a[100];
	struct student * next;
	};
	struct student * head;
	struct student * p1,* p2;
	p1=p2=(struct student * )malloc(LEN);
	gets(p1->a);
	p1->next=0;
	while(strcmp(p1->a,"end"))
	{
		head=p1;
		p2=p1;
		p1=(struct student * )malloc(LEN);
		gets(p1->a);
		p1->next=p2;
	}
	for(p1=head;p1!=0;p1=p1->next)
		printf("%s\n",p1->a);
}


int main()
{
	struct student
	{
		char No[9];
		char name[20];
		char sex;
		int age;
		char score[8];
		char add[20];
		struct student *next,*last;
	};
	struct student *p,*head,*tail;
	p=(struct student*)malloc(sizeof(struct student));
	head=p;
	head->last=NULL;
	do
	{
		scanf("%s",p->No);
		if(p->No[0]=='e')
		{
			p->next=NULL;
			tail=p->last;
		}
		else
		{
			scanf("%s %c%d%s%s",p->name,&p->sex,&p->age,&p->score,p->add);
			p->next=(struct student*)malloc(sizeof(struct student));
			p->next->last=p;
		}
		p=p->next;
	}while(p!=NULL);
	p=tail;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->No,p->name,p->sex,p->age,p->score,p->add);
		p=p->last;
	}
	return 0;
}


struct node
{
 char no[20],name[20],sex,ad[20],score[20];
 int age;
 struct node *next;
}*start=NULL,*p;
int main()
{

	struct node * temp;

	while(1==1)
	{
		temp=(struct node *)malloc(sizeof(struct node));
		scanf("%s",temp->no);
		if(strcmp(temp->no,"end")==0) break;

		scanf(" %s %c %d %s %s",temp->name,&temp->sex,&temp->age,temp->score,temp->ad);
		temp->next=start;
		start=temp;

	}
	p=start;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->no,p->name,p->sex,p->age,p->score,p->ad);
		p=p->next;
	}
printf("\n");
return 0;

}


struct student
{
	char id[100];
	char name[100];
	char sex;
	int age;
	char score[100000];
	char address[100];
	struct student *next;
};

struct student *creat(void)
{
	struct student *head,*p,*q;
	q=NULL;
	head=(struct student *)malloc(len);
	p=head;
	while(1)
	{
		q=p;
		scanf("%s",&p->id);
		if(strcmp(p->id,"end")==0)
			break;
		scanf("%s %c %d %s %s",&p->name,&p->sex,&p->age,&p->score,&p->address);
		p=(struct student *)malloc(len);
		q->next=p;
	}
	q->next=NULL;
	return (head);
}

struct student *turn(struct student *head)
{
	struct student *p,*q,*t,*newhead=NULL;
	while(head->next !=NULL)
	{
		q=NULL;
		p=head;
		while(p->next!=NULL)
		{
			q=p;
			p=p->next;
		}
		if(newhead==NULL)
		{
			newhead=p;
			t=newhead->next=q;
		}
		t=t->next=q;
		q->next=NULL;
	}
	return newhead;
}

void put(struct student *head)
{
	struct student *p;
	for(p=head;p!=NULL;p=p->next)
	{
		if(strcmp(p->id,"end")==0)
			continue;
		printf("%s %s %c %d %s %s\n",p->id,p->name,p->sex,p->age,p->score,p->address);
	}
}

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


char a[3]={'e','n','d'};
struct student
{
	char xuehao[50];
	char name[50];
	char gender;
	int age;
    float score;
	char add[100];
	struct student *next;
};
int m;
struct student *head;
struct student *creat()
{
	struct student *p1,*p2;
	m=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s %s %c %d %f %s",p1->xuehao,p1->name,&p1->gender,&p1->age,&p1->score,p1->add);
	head=NULL;
	while(strcmp(p1->xuehao,a)!=0)
	{
		m=m+1;
		if(m==1)
		{p2->next=NULL;}
		else p1->next=p2;
		p2=p1;
		head=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s",p1->xuehao);
		if(strcmp(p1->xuehao,a)!=0)
		{scanf(" %s %c %d %f %s",p1->name,&p1->gender,&p1->age,&p1->score,p1->add);}
	}
		if(strcmp(p1->xuehao,a)==0)
			p1->next=head;
		return(head);
}
void main()
{
		creat();
		struct student *p1;
	     for(p1=head;p1!=NULL;p1=p1->next)
			printf("%s %s %c %d %g %s\n",p1->xuehao,p1->name,p1->gender,p1->age,p1->score,p1->add);

}


struct student
{
	char num[20];
	char name[20];
	char x[2];
	int age;
	char score[8];
    char add[30];
	struct student *next;
};
void main()
{
	int i,j;
	struct student *head,*p1,*p2;
    p1=(struct student *)malloc(len);
	head=p1;
	scanf("%s%s%s%d%s%s",p1->num,p1->name,p1->x,&p1->age,p1->score,p1->add);
	p1->next=null;
	for(i=1;;i++)
	{
		p1=(struct student *)malloc(len);
		scanf("%s",p1->num);
		if((p1->num[0])!='e')
		{
			scanf("%s%s%d%s%s",p1->name,p1->x,&p1->age,p1->score,p1->add);
			p1->next=head;
			head=p1;
		}
		else break;
	}
	do
	{
		printf("%s %s %s %d %s %s\n",head->num,head->name,head->x,head->age,head->score,head->add);
		head=head->next;
	}while(head!=null);
}


struct stu
{char id[16];
 char name[32];
 char gender;
 int age;
 char score[8];
 char add[16];
 struct stu*next;
};
int n;
struct stu*creat(void)
{struct stu *head,*p1,*p2;
 n=0;
 head=NULL;
 p1=p2=(struct stu*)malloc(sizeof(struct stu));
 scanf("%s",p1->id);
 while(strcmp(p1->id,"end")!=0)
 {scanf("%s %c %d %s %s",p1->name,&p1->gender,&p1->age,p1->score,p1->add);
  n=n+1;
  if(n==1) {head=p1;p1->next=NULL;}
  else
  {
   p1->next=p2;
   head=p1;
  }
  p2=p1;
  p1=(struct stu*)malloc(sizeof(struct stu));
  scanf("%s",p1->id);
 }
 return(head);
}
void main()
{struct stu*head,*p;
 head=creat();
 p=head;
 if(head!=NULL)
 do
 {printf("%s %s %c %d %s %s\n",p->id,p->name,p->gender,p->age,p->score,p->add);
  p=p->next;
 }while(p!=NULL);
}


struct Student
{
        char information[200];
        struct Student *next;
};
int n;
struct Student*creat()
{
        struct Student *p1,*p2,*head;
        n=0;
        p1=p2=(struct Student *)malloc(LEN);
        gets(p1->information);
        head=NULL;
        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 *head)
{
        struct Student *p;
        p=head;
        if(head!=NULL)
                do
                {
                        printf("%s\n",p->information);
                        p=p->next;
                }
                while(p!=NULL);
}
int main()
{
        struct Student * head;
        head=creat();
        print(head);
        return 0;
}


struct stu{
	char no[10];
	char name[20];
	char gene;
	unsigned int age;
	float score;
	char add[20];
	struct list *next;
};

struct stu *creat()
{
	struct stu *p1=NULL,*p2=NULL,*head;
	int n=0;
	do{
        p2=p1;
		p1=(struct stu*)malloc(sizeof(struct stu));
	    scanf("%s",p1->no);
		if(*p1->no=='e')
		{
			head=p2;
			free(p1);
			break;
		}
		scanf("%s %c %d %f %s\n",p1->name,&p1->gene,&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 stu *head)
{
	struct stu *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->no,p->name,p->gene,p->age,p->score,p->add);
		p=p->next;
	}
}

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


struct student
{
    char num[15];
    char name[30];
    char sex;
    char age[3];
    char grade[10];
    char ad[15];
}stu[1000]={0};

int main()
{
    int i=0;
    while(1)
    {
        scanf("%s",stu[i].num);
        if(stu[i].num[0]=='e')
            break;
        else
        {
            scanf("%s %c %s %s %s",stu[i].name,&stu[i].sex,stu[i].age,stu[i].grade,stu[i].ad);
            i++;
        }
    }
    i=i-1;
    for(;i>=0;i--)
    {
        printf("%s %s %c %s %s %s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].grade,stu[i].ad);
    }
    return 0;
}


struct student
{
	char info[50];
	struct student *p;
};
void main()
{
	int m,n,i,j;
	struct student *p,*head;
    for(i=0;;i++)
	{
		p=DT;
		if(i==0)
		  p->p=NULL;
		gets(p->info);
		if(strcmp(p->info,"end")==0)
			break;
		p->p=head;
		head=p;
	}
    for(p=head,j=0;j<i;j++,p=p->p)
	{
		puts(p->info);
	}
}


struct Student
{
char number[100];
char name[100];
char sex;
int age;
char score[20];
char address[100];
struct Student *next;
struct Student *front;
};
int n;
void main()
{
	struct Student*p1,*p2;
	n=0;
	p1=p2=(struct Student*)malloc(LEN);
	scanf("%s %s %c%d%s%s",&p1->number,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);
	p1->front=NULL;
	while(p1->number[0]!='e'||p1->number[1]!='n'||p1->number[2]!='d')
	{
			n=n+1;
		    p2->next=p1;
			p2=p1;
			p1=(struct Student*)malloc(LEN);
			scanf("%s %s %c%d%s%s",&p1->number,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);
			p1->front=p2;
	}
	p2->next=NULL;
	while(p2!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p2->number,p2->name,p2->sex,p2->age,p2->score,p2->address);
		p2=p2->front;
	}
}


struct a
{
	char num[10];
	char name[21];
	char sex;
	int age;
	float score;
	char address[12];
	struct a*next;
};
struct a*create()
{
	struct a*head,*p1;
	p1=len;p1->next=null;head=p1;strcpy(p1->num,"pp");
	while(strcmp(p1->num,"end"))
	{
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")!=0)
		{
		scanf("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
		p1=len;
		p1->next=head;
		head=p1;
		strcpy(p1->num,"pp");}
	}
	head=p1->next;
	return head;
}
void print(struct a*head)
{
	struct a*p1;
	p1=head;
	do
	{
		printf("%s %s %c %d %g %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		if(p1->next!=null)printf("\n");
		p1=p1->next;
	}while(p1);
}
int main()
{
	struct a*create();
	struct a*head;
	void print(struct a*head);
	head=create();
	print(head);
}


struct student
{char number[100];
char name[100];
char sex;
int age;
char score[20];
char address[100];
struct student *next;
struct student *front;
};
void main()
{
struct student *p1,*p2;
p1=p2=(struct student*)malloc(LEN);
p1->front=NULL;
scanf("%s",&p1->number);
while(p1->number[0]!='e'||p1->number[1]!='n'||p1->number[2]!='d')
{
        scanf("%s %c%d%s%s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);
p2->next=p1;
p2=p1;
p1=(struct student*)malloc(LEN);
p1->front=p2;
scanf("%s",&p1->number);
}
p2->next=NULL;
while(p2!=NULL)
{
printf("%s %s %c %d %s %s\n",p2->number,p2->name,p2->sex,p2->age,p2->score,p2->address);
p2=p2->front;
}
}


int main()
{
    char str[10000][100];
    gets(str[0]);
    int i=0,j;
    while(str[i][0]!='e')
    {
                         i++;
                         gets(str[i]);
    }
    for(j=i-1;j>=0;j--)
    printf("%s\n",str[j]);
    getchar();getchar();
}


struct node
{
	int num;
	char number[20];
	char name[20];
	char sex[10];
	char age[10];
	char score[10];
	char address[20];
	struct node *next;
};
struct node * creat(int n);
struct node * insert(struct node *head,struct node * q);
void list(struct node *head);
struct node * fv(struct node * head);
int main(void)
{
	struct node *p;
	p=creat(0);
	int i;
	for(i=1;i<1000;i++)
	{
		struct node *q;
		q=creat(i);
		if(strcmp("end",q->number)!=0)
			p=insert(p,q);
		else
			break;
	}
	p=fv(p);
	list(p);
	return 0;
}
struct node * creat(int n)
{
	struct node *ps;
	ps=(struct node *)malloc(sizeof(struct node));
	scanf("%s %s %s %s %s %s\n",&ps->number,&ps->name,&ps->age,&ps->sex,&ps->score,&ps->address);
	fflush(stdin);
	ps->num=n;
	return(ps);
}
struct node * insert(struct node *head,struct node * q)
{
	struct node *m,*n;
	m=head;
	if(head==0)
	{
		head=q;
		q->next=0;
	}
	else
	{
		if(q->num<=head->num)
		{
			q->next=head;
			head=q;
		}
		else
		{
			while((q->num>m->num)&&(m->next!=0))
			{
				n=m;
				m=m->next;
			}
			if(q->num<=m->num)
			{
				n->next=q;
				q->next=m;
			}
			else
			{
				m->next=q;
				q->next=0;
			}
		}
	}
	return(head);
}
struct node * fv(struct node * head)
{
	struct node *p,*q,*k,*l;
	l=head;
	p=(struct node *)malloc(sizeof(struct node));
	p->next=l;
	k=p->next;
	while(k!=0)
	{
		q=p;
		p=k;
		k=p->next;
		p->next=q;
	}
	p->next=q;
	q=p;
	while(q->num!=head->num)
		q=q->next;
	q->next=0;
	return(p);
}
void list(struct node *head)
{
	struct node *p;
	p=head;
	while(p!=0)
	{
		printf("%s %s %s %s %s %s\n",&p->number,&p->name,&p->age,&p->sex,&p->score,&p->address);
		p=p->next;
	}

}


int n=0;
struct student
{
	char id[20];
	char name[20];
	char sex;
	int age;
	char score[20];
	char address[20];
	struct student* next;
};
struct student *creat()
{
struct student* head,*pf,*ps;
pf= (struct student * ) malloc(sizeof(struct student));
ps=pf;
scanf("%s",&pf->id);
while(pf->id[0]!='e')
{
	n++;
	scanf("%s %c %d %s %s",&pf->name,&pf->sex,&pf->age,&pf->score,&pf->address);
	if(n!=1)
	{
		pf->next=ps;
		ps=pf;
	}
	else pf->next=NULL;
	pf=(struct student*)malloc(sizeof(struct student));
	scanf("%s",&pf->id);
}
head=ps;
return head;
}
void print(struct student *head)
{
	int i;
	struct student *p;
	p=head;
	if(head!=NULL)
	for(i=0;i<n;i++)
	{
		printf("%s %s %c %d %s %s\n",p->id,p->name,p->sex,p->age,p->score,p->address);
		p=p->next;
	}
}
void main()
{
struct student *head;
head=creat();
print(head);
}


struct Inform
{
    char number[30];
    char name[30];
	char gender[2];
	char age[4];
	char score[10];
	char address[20];
	struct Inform *next;
};
 int n;
 struct Inform *creat()
 {

	  struct Inform *head;
      struct Inform *p1,*p2;
      head=NULL;
      p1=p2=(struct Inform*)malloc(LEN);
      n=0;
	  scanf("%s%s%s%s%s%s",&p1->number,&p1->name,&p1->gender,&p1->age,&p1->score,&p1->address);
      while(strcmp(p1->number,"end")!=0)
	  {
	      n=n+1;
          if(n==1) head=p1;
          else p2->next=p1;
          p2=p1;
          p1=(struct Inform*)malloc(LEN);
          scanf("%s",&p1->number);
          if(strcmp(p1->number,"end")!=0) scanf("%s%s%s%s%s",&p1->name,&p1->gender,&p1->age,&p1->score,&p1->address);
      }
	  p2->next=NULL;
	  return head;
}

void print(struct Inform *h)
{
     struct Inform *p;
	 p=h;
	 while(p!=NULL)
	 {
	    printf("%s %s %s %s %s %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);
		p=p->next;
	 }

}

struct Inform *invert(struct Inform *h)
{
    struct Inform *p=h->next;
	 struct Inform *q=p->next;
	h->next=NULL;
	while(q!=NULL)
	{p->next=h;h=p;p=q;q=q->next;p->next=h;
    }
    p->next=h;
	return p;
}

int main()
{
	void print(struct Inform *h);
	struct Inform *invert(struct Inform *h);
	struct Inform *hea;
	hea=creat();
	hea=invert(hea);
	print(hea);
	return 0;
}


void main()
{
	int n,i,j,length1,length2,cha;
	scanf("%d",&n);
	char beijianshu[101],jianshu[101];
	for(i=0;i<n;i++)
	{
		scanf("%s",beijianshu);
		scanf("%s",jianshu);
		length1=strlen(beijianshu);
		length2=strlen(jianshu);
		for(j=1;j<=length2;j++)
		{
			cha=beijianshu[length1-j]-jianshu[length2-j];
			if(cha>=0)
				beijianshu[length1-j]=cha+'0';
			else
			{
				beijianshu[length1-j-1]--;
				beijianshu[length1-j]=10+cha+'0';
			}
		}
		while(beijianshu[length1-j]<'0')
		{
			beijianshu[length1-j]+=10;
			j++;
			beijianshu[length1-j]-=1;
		}

		printf("%s\n",beijianshu);
	}

}


void turn(char str[100])
{
	int n,i,t;
	n=strlen(str);
	for(i=0;i<=(n-1)/2;i++)
	{
		t=str[i];
		str[i]=str[n-i-1];
		str[n-i-1]=t;
	}
}

int min(int x,int y)
{
	int z;
	if(x>=y)
		z=y;
	else
		z=x;
	return(z);
}

void miner(char str1[100],char str2[100],char str3[100])
{
	int t,i,m,n;
	m=strlen(str1);
	n=strlen(str2);
	t=min(m,n);
	for(i=0;i<t;i++)
	{
		if(str1[i]>=str2[i])
			str3[i]=str1[i]-str2[i]+48;
		else
		{
			str3[i]=str1[i]+10-str2[i]+48;
			str1[i+1]--;
			str3[i+1]--;
		}
	}
}

void main()
{
	char a[100],b[100],t[2],c[100];
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		gets(t);
		gets(a);
		gets(b);
		turn(a);
		turn(b);
		strcpy(c,a);
		miner(a,b,c);
		turn(c);
		puts(c);
	}
}


void main()
{
	int n,la,lb,length,i,s,j;
	char a[100],b[100];
	int aArray[100],bArray[100];
	scanf("%d",&n);
    for(s=1;s<=n;s++)
	{
		scanf("%s",a);
		scanf("%s",b);

		la=strlen(a);
		lb=strlen(b);
		length=la-lb;

		for(i=0;i<la;i++)
			aArray[i]=a[i]-'0';
		for(i=0;i<length;i++)

			bArray[i]=0;

		for(i=length;i<la;i++)
			bArray[i]=b[i-length]-'0';

		for(i=la-1;i>=0;i--)
		{
			if(aArray[i]>=bArray[i])a[i]=aArray[i]-bArray[i];
			if(aArray[i]<bArray[i])
			{a[i]=aArray[i]+10-bArray[i];aArray[i-1]--;}

		}

		for(i=0;i<la;i++)
		     a[i]=a[i]+48;

		for(i=0;i<la;i++)
		{
			if(a[i]!=0)
	     	for(j=i;j<la;j++)
			printf("%c",a[j]);
			printf("\n");
			break;
		}
	}
}


int main()
{ 	int n;
cin>>n;
   for(int t=0;t<n;t++)
	{cin.get();
		const int MAX_LEN = 200;
	int an1[MAX_LEN]; int an2[MAX_LEN];
	char seLine1[MAX_LEN + 1]; char seLine2[MAX_LEN + 1];

	cin.getline(seLine1, MAX_LEN + 1);
	cin.getline(seLine2, MAX_LEN + 1);
	int nLen1 = strlen(seLine1);
	int nLen2 = strlen(seLine2);
	//cout<<seLine1<<endl<<seLine2<<endl;
	memset(an1, 0, sizeof(an1));
	memset(an2, 0,sizeof(an2));
   	int i, j=0;
	for (i = nLen1-1;  i>=0; i--)
		an1[j++] = seLine1[i] - '0';
	j=0;
	for (i = nLen2-1; i>=0;i--)
		an2[j++] = seLine2[i] - '0';
	for (i = 0; i < MAX_LEN ;i++)
	{
		//printf("%d %d %d ",i, an1[i], an2[i]);
		if(an1[i]>=an2[i])
			an1[i]-=an2[i];
		else{
		     an1[i]=10+an1[i]-an2[i];
			 an1[i+1]-=1;
		}
		//printf("aa%d %d\n", i, an1[i]);
	}
	i = MAX_LEN - 1;
	while(an1[i]==0) i--;
	//cout<<i<<endl;
	for(;i >= 0; i--)
		cout << an1[i];
	cout << endl;
   }
	return 0;
}


int an1[100];
int an2[100];
char szLine1[100];
char szLine2[100];
void main()
{
	int n,p,i,j,nLen1,nLen2,max=0;;
	scanf("%d",&n);
	for(p=0;p<n;p++)
	{
		scanf("%s",szLine1);
		scanf("%s",szLine2);

	memset(an1,0,sizeof(an1));
	memset(an2,0,sizeof(an2));

	nLen1=strlen(szLine1);
	j=0;

	for(i=nLen1-1;i>=0;i--)
	{
		an1[j++]=szLine1[i]-'0';
	}
	nLen2=strlen(szLine2);
	j=0;
	for(i=nLen2-1;i>=0;i--)
	{
		an2[j++]=szLine2[i]-'0';
	}
	if(nLen1>nLen2)
		max=nLen1-1;
	else
		max=nLen2;
	for(i=0;i<max;i++)
	{
		an1[i]-=an2[i];
		if(an1[i]<0)
		{
			an1[i]+=10;
			an1[i+1]--;
		}
	}
	for(i=max;i>=0;i--)
		printf("%d",an1[i]);
	printf("\n");
	}

}


int str2(char*str,int*a)
{
	int length=(int)strlen(str);
	int i;
	for(i=0;i<length;i++)
		a[length-i-1]=str[i]-'0';
	return length;
}
void print_b(int*a,int length)
{
	int t=length-1;
	int i;
	while(a[t]==0 && t>0)
		t--;
	for(i=t;i>=0;i--)
		printf("%d",a[i]);
}
int sub_b(int*a,int alength,int*b,int blength,int*c)
{
	int i;
	for(i=0;i<alength;i++)
	{
		c[i]=a[i];
		if(i<blength)
			c[i]-=b[i];
	}
	for(i=0;i<alength;i++)
		if(c[i]<0)
		{
			c[i+1]--;
			c[i]+=10;
		}
	return c[alength-1]?alength:(alength-1);
}
void main()
{
	char s1[M],s2[M];
	int a[M],b[M],c[M];
	int alength,blength,clength;
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %s",s1,s2);
	    alength=str2(s1,a);
	    blength=str2(s2,b);
	    clength=sub_b(a,alength,b,blength,c);
	    print_b(c,clength);
	    printf("\n");
	}
}


int main()
{
	int n, num1[101], num2[101], len1, len2, m, j;
	char str1[102], str2[102];

	cin >> n;
	cin.get();
	for (int k = 1; k <= n; k++)
	{
		cin.getline(str1,102);
		cin.getline(str2,102);
                cin.get();
		len1 = strlen (str1);
		len2 = strlen (str2);
		memset(num1, 0, sizeof(num1));
        memset(num2, 0, sizeof(num2));
		j = 0;
		for (int i = len1 - 1; i >= 0; i--)
		{
			num1[j] = str1[i] - '0';
			j++;
		}
		j = 0;
		for (int i = len2 - 1; i >= 0; i--)
		{
			num2[j] = str2[i] - '0';
			j++;
		}
		for (int i = 0; i < len1; i++)
		{
			num1[i] = num1[i] - num2[i];
			if (num1[i] < 0)
			{
				num1[i + 1]--;
				num1[i] += 10;
			}
		}
		m = len1;
		while (num1[m] == 0)
			m--;
		for (int i = m; i >= 0; i--)
			cout << num1[i];
		cout << endl;
	}

	return 0;

}


 void main()
{
 int n,lengtha,lengthb,i,j,k,l;
 char a[100],b[100],c[100];
 scanf("%d",&n);
 for(i=1;i<=n;i++)
  {
   scanf("%s\n",a);
   scanf("%s\n",b);
   lengtha=strlen(a);
   lengthb=strlen(b);
   for(j=1;j<=lengthb;j++)
     {
      if (a[lengtha-j]>=b[lengthb-j])
        c[lengtha-j]=a[lengtha-j]-b[lengthb-j];
      else
        { c[lengtha-j]=a[lengtha-j]-b[lengthb-j]+10;
         a[lengtha-j-1]=a[lengtha-j-1]-1;}
      }
     if(a[lengtha-j]<0)
       {
        a[lengtha-j]=a[lengtha-j]+10;
        a[lengtha-j-1]=a[lengtha-j-1]-1;
        }
      for(k=lengtha-j;k>=0;k--)
         c[k]=a[k]-48;
      for(l=0;l<lengtha;l++)
        printf("%d",c[l]);
        printf("\n");
   }
}


void dajianfa(char a[],char b[]);

void main ()
{
	int n;
	char a[100];
	char b[100];
	int i;
	char nouse;

	scanf("%d%c",&n,&nouse);

	for (i=0;i<n;i++)
	{
		gets(a);
		gets(b);

		dajianfa(a,b);
		if(i!=n-1) gets(b);
	}
}

void dajianfa(char a[],char b[])
{
	int len1,len2;
	int i;

	len1=strlen(a);
	len2=strlen(b);

	for(i=1;i<=len2;i=i+1)
	{
		if(a[len1-i]>=b[len2-i]) a[len1-i]=a[len1-i]-b[len2-i]+48;
		else {
			a[len1-i-1]-=1;a[len1-i]=a[len1-i]-b[len2-i]+58;
		}
	}

	a[len1]='\0';
	puts(a);
}


int main()
{
	int n ;
	cin >> n ;
	for (int k = 1 ; k <= n ; k ++)
	{
		char str1[200], str2[200] ;
	    int num1[200], num2[200] = {0} , num[200] = {0} ;
		cin >> str1 >> str2 ;
		int len1 = strlen(str1) , len2 = strlen(str2) ;
		for (int i = len1 - 1 ; i >= 0 ; i --)
			num1[i] = str1[i] - '0' ;
		for (int i = len1 - 1 , j = len2 - 1 ; j >= 0 ; i -- , j --)
			num2[i] = str2[j] - '0' ;
		for (int i = len1 - 1 ; i >= 0 ; i --)
			if (num1[i] >= num2[i])
				num[i] = num1[i] - num2[i] ;
			else
			{
				num[i] = 10 + num1[i] - num2[i] ;
				for (int a = 1 ; a <= i ; a ++)
				{
					if (num1[i - a] == 0)
					{
						num1[i - a] = 9 ;
						continue ;
					}
					num1[i - a] -- ;
					break ;
				}
			}
			int b = 0 ;
			while (num[b] == 0)
				b ++ ;
			for (  ; b <= len1 - 1 ; b ++)
				cout << num[b] ;
			cout << endl ;
	}

	return 0 ;
}


void main()
{
        int n, result[100];
        char a[100], b[100], c[2];
        scanf("%d", &n);
        int i,s,t,j,k;
        for(i=0;i<n;i++)
        {
                gets(c);
                gets(a);
                gets(b);
                s=strlen(a);
                t=strlen(b);
                for (j=s-1; ;j--)
                {
                        if (a[j]>=b[j-s+t])
                                result[j] = a[j]-b[j-s+t];
                        else
                        {
                                result[j] = a[j]-b[j-s+t]+10;
                                a[j-1]--;
                        }
                        if (j-s+t==0)
                                break;
                }
                for(k=0; k<j; k++)
                        result[k]=a[k]-'0';
                if(j>0)
                {
                        for(k=0;k<s;k++)
                                printf("%d",result[k]);
                        printf("\n");
                }
                else
                {
                        for(k=0;k<s;k++)
                                if (result[k]!=0)
                                        break;
                        for(j=k;j<s;j++)
                                printf("%d",result[k]);
                        printf("\n");
                }
        }
}


void minus(char a[],char b[]);
void ni(char a[]);
void tranvert(char m,char a[]);
void trans(char n,char m,char b[]);

void main()
{
    char k,i,m,n,a[30][100]={0},b[30][100]={0};
    scanf("%d",&k);
    for(i=0;i<k;i++)
    {
        scanf("%s",a[i]);
        scanf("%s",b[i]);
        m=strlen(a[i]);
        n=strlen(b[i]);//the result at most has m bits
        ni(a[i]);
        ni(b[i]);
        trans(n,m,b[i]);
        minus(a[i],b[i]);
        tranvert(m,a[i]);
        ni(a[i]);
        printf("\n");

    }
    for(i=0;i<k;i++)
    {
        puts(a[i]);
    }
}

void minus(char a[],char b[])
{
    char i,t,m=strlen(a),jin=0;//experimental
    for(i=0;i<=m-1;i++)
    {
        t=a[i]-b[i]-jin;
        if(t>=0) {a[i]=t; jin=0;}
        else {a[i]=t+10; jin=1;}
    }
}

void ni(char a[])
{
    char i,t,m=strlen(a);
    for(i=0;i<m/2;i++)
    {
        t=a[i];
        a[i]=a[m-1-i];
        a[m-1-i]=t;
    }
}

void tranvert(char m,char a[])
{
        char i,j;  //n=strlen(a)
        for(i=m-1;i>=1;i--)
            if(a[i]!=0) break;
        for(j=i;j>=0;j--)
            a[j]+='0';
}

void trans(char n,char m,char b[])// add 0 so that b is as long as a
{    char i;
    for(i=n;i<=m-1;i++)
    b[i]='0';
}


void main()
{
   char beijian[200],jian[200],jian2[200],result[200];
   int i=0,j=0,l1,l2,n;
     scanf("%d",&n);
   for(j=0;j<n;j++)
   {
      for(i=0;i<100;i++)
   {
	   jian2[i]=48;
	   result[i]=48;
   }
   jian2[99]=0;
   result[99]=0;

   scanf("%s",beijian);
	  scanf("%s",jian);
      l1=strlen(beijian);
      l2=strlen(jian);
	  if(l1==l2)
      {
	  for(i=l1-1;i>=0;i--)
	  {
	     if(beijian[i]<jian[i])
		 {
	        beijian[i]=beijian[i]+10;
	        beijian[i-1]=beijian[i-1]-1;
		 }
 	     result[i]=beijian[i]-jian[i]+48;
	  }
	  result[l1]='\0';
	  }
      else
      {
		  for(i=l1-1;i>=l1-l2;i--) jian2[i]=jian[i-l1+l2];
 	  for(i=l1-1;i>=0;i--)
	  {
		  if(beijian[i]<jian2[i])
		 {
	        beijian[i]=beijian[i]+10;
	        beijian[i-1]=beijian[i-1]-1;
		 }
	     result[i]=beijian[i]-jian2[i]+48;
	  }
	  result[l1]='\0';
      }
	  for(i=0;i<l1;i++)
	  {
		  if(result[i]!=0&&result[i]!=48) break;
	  }
      while(result[i]!='\0') printf("%c",result[i++]);
      printf("\n");
   }
}


void main()
{
  int n;
  scanf("%d",&n);
  char miner[20][101],minee[20][101];
  int i,sp,k,pr;
  int lr,le;
     for(i=1;i<=n;i++)
	 {
		 scanf("%s%s",&miner[i],&minee[i]);
         lr=strlen(miner[i]);
		 le=strlen(minee[i]);
		 while(le>=1)
		 {    if(miner[i][lr-1]>=minee[i][le-1])
		         miner[i][lr-1]=miner[i][lr-1]-minee[i][le-1]+'0';
		      else
			  {sp=lr-2;
			  while(miner[i][sp]=='0'){miner[i][sp]='9';sp--;}
			  miner[i][sp]=miner[i][sp]-1;
			  miner[i][lr-1]=miner[i][lr-1]-minee[i][le-1]+'0'+10;
			  }

		 le--;lr--;
		 }
		k=0;lr=strlen(miner[i]);
		while(1){if(miner[i][k]=='0')k++;else break;}
		for(pr=k;pr<=lr-1;pr++)printf("%c",miner[i][pr]);
		printf("\n");
	 }

}


/*
 * dazhengshujianfa.cpp
 *
 *  Created on: 2010-12-24
 *      Author: lz
 */

int main()
{
	int n;
	cin>>n;
	char a[200];//?????
	char b[200];//????
	char c[200];//???
	char s[200];//????????
	while(n>0)
	{
		n--;
		int i;
		int j;
		int carry=0;//??
		cin>>s;
		int slen=strlen(s);
		for(i=0;i<slen;i++)
			a[i]=s[slen-i-1];
		int alen=slen;
		cin>>s;
		slen=strlen(s);
		for(i=0;i<slen;i++)
			b[i]=s[slen-i-1];
		int blen=slen;
		for(i=0;i<blen;i++)//??
		{
			if(a[i]-'0'-carry>=b[i]-'0')
			{
				c[i]=(char)(a[i]-b[i]-carry+'0');
				carry=0;
			}
			else
			{
				c[i]=(char)(a[i]-b[i]-carry+10+'0');
				carry=1;
			}
		}
		for(i=blen;i<alen;i++)
		{
			if(a[i]-carry>='0')
			{
				c[i]=(char)(a[i]-carry);
				carry=0;
			}
			else
			{
				c[i]=(char)(a[i]-carry+10);
				carry=1;
			}
		}
		for(i=alen-1;i>=0;i--)
			if(c[i]!='0')
				break;
		for(j=i;j>=0;j--)
			cout<<c[j];
cout<<endl;
	}
	return 0;
}


int main()
{
	char a[105], b[105];
	int na[105], nb[105], n, i, j, k, lena, lenb;
	cin >>n;
	cin.get();
	for (i = 1; i <= n; i ++)
	{
		memset(na, 0, sizeof(na));
		memset(nb, 0, sizeof(nb));
		cin.getline (a, 104);
		cin.getline (b, 104);
		lena = strlen(a);
		lenb = strlen(b);
		for (j = 0; j <= lena - 1; j ++)
		{
			na [j] = a [lena -j - 1] - '0';
		}
		for (j = 0; j <= lenb - 1; j ++)
		{
			nb [j] = b [lenb - j - 1] - '0';
		}
		for (j = 0; j <= lena - 1; j ++)
		{
			na[j] = na [j] - nb [j];
			if (na [j] < 0)
			{
				na [j] = na [j] + 10;
				na [j + 1] = na [j + 1] - 1;
			}
		}
		j = 102;
		while (na[j] == 0)
			j --;
		for (; j >= 0; j--)
		{
			if (j != 0)
				cout << na[j];
			else
				cout << na[j] << endl;
		}
		cin.get();
	}
	return 0;
}


int main()
{
	char sn[10];
	int n;
	gets(sn);
	n = atoi(sn);
	int k;
	char a[250][250];
	char b[250][250];
	char cc[10];

	for(k=0;k<n;k++)
	{
		if( k==0)
		{
			gets(a[k]);
			gets(b[k]);
		}
		else
		{
			gets(cc);
			gets(a[k]);
			gets(b[k]);
		}
	}
    int lena[250];
	int lenb[250];
	int i;int j;
	for(k=0;k<n;k++)
	{

	lena[k]=strlen(a[k]);
	lenb[k]=strlen(b[k]);

    int shua[251][250];int shub[251][250];
	memset(shua[k],0,sizeof(shua[k]));
	memset(shub[k],0,sizeof(shub[k]));

	j=0;
	for(i=lena[k]-1;i>=0;i--)
	{
         shua[k][j++]=a[k][i]-'0';
	}
	j=0;
	for(i=lenb[k]-1;i>=0;i--)
	{
         shub[k][j++]=b[k][i]-'0';
	}

	for(i=0;i<250;i++)
	{
		shua[k][i]-=shub[k][i];
		if(shua[k][i]<0)
		{
			shua[k][i]+=10;
			shua[k][i+1]--;
		}
	}
	int bStartOutput = 0;
	for(i=249;i>=0;i--)
	{
		if(bStartOutput)
		{
			printf("%d",shua[k][i]);
		}
		else if(shua[k][i] > 0)
		{
			printf("%d",shua[k][i]);
			bStartOutput = 1;
		}
	}
	printf("\n");
	if (!bStartOutput)
		printf("0\n");

	}

	return 0;
}


char str1[N],str2[N],temp[N];

int max(int x,int y)
{
	return(x>y?x:y);
}

void major(char str1[],char str2[])
{
	int a[N],b[N];
	int len1,len2,len,t,jump,i;
	    len1=strlen(str1);
        len2=strlen(str2);
        if(len1<len2)
		{
            strcpy(temp,str1);t=len1;
            strcpy(str1,str2);len1=len2;
            strcpy(str2,temp);len2=t;
		}
	    len=max(len1,len2);
	    jump=len-len2+1;
	    for(i=len;i>=0;i--)
		    str1[i]=str1[i-1];
	    str1[0]='0';
	    for(i=len;i>=jump;i--)
		{
		    str2[i]=str2[i-jump];
		}
	    for(i=0;i<jump;i++)
		    str2[i]='0';
	    for(i=len;i>=0;i--)
		{
		    a[i]=str1[i]-'0';
		    b[i]=str2[i]-'0';
		}
	    for(i=len;i>=0;i--)
		{
		    if(a[i]>=b[i])
			    a[i]=a[i]-b[i];
		    else
			{
			    a[i]=a[i]+10-b[i];
			    a[i-1]-=1;
			}
		}
	    if(a[1]==0)
		{
		    for(i=0;i<=len-2;i++)
			    temp[i]=a[i+2]+'0';
		    temp[len-1]='\0';
		}
	    else if(a[1]!=0)
		{
		    for(i=0;i<=len-1;i++)
			    temp[i]=a[i+1]+'0';
		    temp[len]='\0';
		}
	    printf("%s\n",temp);
}
void main()
{
	char s1[100][N],s2[100][N];
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",s1[i]);
		scanf("%s",s2[i]);
		if(i<n-1)
			printf("\n");
	}
	for(i=0;i<n;i++)
		major(s1[i],s2[i]);
}


int main()
{
	int n,length_a,length_b,i,j,k;
	char a[128],b[128];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a);
		scanf("%s",b);
		length_a=strlen(a);
		length_b=strlen(b);
		for(j=length_a;(length_a-j)<length_b;j--)
		{
			if (a[j-1]>=b[length_b-1+j-length_a])
				a[j-1]=a[j-1]-b[length_b+j-length_a-1]+48;
			else
			{
					a[j-1]=a[j-1]+10-b[length_b+j-length_a-1]+48;
					k=j-2;
					while(a[k]=='0')
					{
						a[k]='9';
						k--;
					}
					a[k]--;
			}
		}
		k=0;
		while(a[k]=='0')
			k++;
		for(;k<length_a;k++)
			putchar(a[k]);
		putchar('\n');
	}
	return 0;
}


void main()
{
	char bjs[200],js[200];
	int i,j,k,l,count,n,c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(strcmp(bjs,js)!=0)
		{
		scanf("%s",bjs);
		scanf("%s",js);
		c=strlen(bjs)-strlen(js);
		for(j=strlen(js)-1;j>=0;j--)
		{
			if(bjs[c+j]<js[j])
			{
				for(k=1;;k++)if(bjs[c+j-k]>48)break;
				bjs[c+j-k]-=1;
				for(l=1;l<k;l++)bjs[c+j-l]=57;
				bjs[c+j]=58+bjs[c+j]-js[j];
			}
			else bjs[c+j]=bjs[c+j]-js[j]+48;
		}
		for(j=0;;j++)if(bjs[j]!=48)break;
		for(k=j;k<strlen(bjs);k++)printf("%c",bjs[k]);
		putchar(10);
		}
		else printf("0\n");
	}
}


void subtraction (char big[100], char small[100], int n)
{
	int i;
	for (i=n;i>=0;i--)
	{
		if (big[i]-small[i]>=0)
			big[i]=big[i]-small[i]+'0';
		else
		{
			big[i]=big[i]-small[i]+10+'0';
			small[i-1]=small[i-1]+1;
		}
	}
}

void main ()
{
	char numbig[100], numsmall[100];
	int i,j,lennumbig,lennumsmall,n,k;

	scanf("%d",&n);
	for (k=0;k<n;k++)
	{
		scanf ("%s",&numbig);
		scanf ("%s",&numsmall);
		getchar();

		lennumbig=strlen(numbig);
		lennumsmall=strlen(numsmall);

		for (i=lennumbig,j=lennumsmall;i>=lennumbig-lennumsmall;i--,j--)
			numsmall[i]=numsmall[j];
		for (i=0;i<lennumbig-lennumsmall;i++)
			numsmall[i]='0';

		subtraction(numbig,numsmall,lennumbig-1);

		puts(numbig);
	}
}


int trans(char str[], int a[])
{
	int l=(int)strlen(str);
	int i;
	for (i=0;i<l;i++)
	{   a[l-i-1]=str[i]-'0';
	}
	return l;
}

void print(int a[], int l)
{
	int k=l-1;
	int i;
	while (a[k]==0 && k>0)
	{ k--;
	}
	for (i=k;i>=0;i--)
	{ printf("%d",a[i]);
	}
}

int minus(int a[], int al, int b[], int bl,int c[])
{
	int i;
	for (i=0;i<al;i++)
	{   c[i]=a[i];
	    if (i<bl)  c[i]=c[i]-b[i];
	}
	for (i=0;i<al;i++)
	{   if (c[i]<0)
	{   c[i+1]--;
	    c[i]=c[i]+10;
	}
	}
	return al;
}

int main()
{
	char s1[101],s2[101];
	int a[101],b[101],c[101];
	int al,bl,cl,i,n;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{   scanf ("%s%s",s1,s2);
	    al=trans(s1,a);
		bl=trans(s2,b);
		cl=minus(a,al,b,bl,c);
		print(c,cl);
		printf("\n");
	}

	return 0;
}


int main()
{
	char a[150],b[150];
	int c[150],d[150],result[150];
	int n,la,lb,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a);
		scanf("%s",b);
		la=strlen(a);
		lb=strlen(b);
		for(j=0;j<la;j++)
			c[j]=a[j]-'0';
		for(j=0;j<la-lb;j++)
			d[j]=0;
		for(j=la-lb;j<la;j++)
			d[j]=b[j-la+lb]-'0';

		int carry = 0;
		for(j=la-1;j>=0;j--)
		{
			if(c[j]>=d[j]+carry)
			{
				result[j]=c[j]-d[j]-carry;
				carry = 0;
			}
			else
			{
				//c[j-1]=c[j-1]-1;

				result[j]=c[j]+10-d[j]-carry;
				carry = 1;
			}
		}
		for(j=0;j<la;j++)
		{
			if(result[j]!=0) break;
		}
		for(k=j;k<la-1;k++)
			printf("%d",result[k]);
		printf("%d\n",result[la-1]);
	}
	return 0;
}


int main()
{
	int n,i,j,len1,len2;
	char str1[101],str2[101];
	int a[100],b[100];
	cin>>n;
	while(n--)
	{
cin.get();
		len1=0;
		len2=0;
		cin.getline(str1,100);
		cin.getline(str2,100);
		while(str1[len1]!=0)
			len1++;
		while(str2[len2]!=0)
			len2++;
		memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
		for(i=len1-1;i>=0;i--)
			a[len1-1-i]=str1[i]-'0';
		for(i=len2-1;i>=0;i--)
			b[len2-1-i]=str2[i]-'0';
		for(i=0;i<len1||i<len2;i++)
		{
			if(a[i]>=b[i]) a[i]-=b[i];
			else
			{
				a[i]=a[i]+10-b[i];
				a[i+1]--;
			}
		}
		int count=99;
		while(a[count]==0)
			count--;
		for(i=count;i>=0;i--)
		cout<<a[i];
cout<<endl;
	}
return 0;
}


char a[100],b[100];
void reverse(char a[])
{int i,m;
 char t;
 m=strlen(a);
 for(i=0;i<m/2;i++)
   {t=a[i];
    a[i]=a[m-i-1];
    a[m-1-i]=t;
   }
}
void minus(char a[],char b[])
{int i;
for(i=0;i<strlen(b);i++)
 {a[i]=a[i]-b[i];
  if(a[i]<0)
    {a[i]=a[i]+10;
     a[i+1]=a[i+1]-1;
     }
  a[i]=a[i]+48;
  }
}
void main()
{int i,n;char c[2];
 scanf("%d\n",&n);
 for(i=0;i<n-1;i++)
   {
     gets(a);    gets(b);
     gets(c);
     reverse(a);   reverse(b);
     minus(a,b);
     reverse(a);
     puts(a);
    }
     gets(a);       gets(b);
     reverse(a);   reverse(b);
     minus(a,b);
     reverse(a);
     puts(a);
}


int lena,lenb,lenc;
void minus(char a[],char b[],char c[])
{	int carry=0,i;
	for(i=lena-1;i>=0;i--)
	{if(a[i]-b[i]-carry<0)
		{c[i]=a[i]+10-b[i]+'0'-carry;
		carry=1;
		}
	else if(a[i]-b[i]-carry>=0)
		{c[i]=a[i]-b[i]+'0'-carry;
		carry=0;
		}
	}
	c[lena]='\0';
}
void operate(char b[])
{	int jump=lena-lenb;
	int i;
	b[lena]='\0';
	for(i=lenb;i>=0;--i)
		b[i+jump]=b[i];
	for(i=0;i<jump;i++)
		b[i]='0';
}
void main()
{	char a[ARRAY][N],b[ARRAY][N],c[N];
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%s",a[i]);
	scanf("%s",b[i]);
	printf("\n");
	}
	for(i=0;i<n;i++)
	{lena=strlen(a[i]);lenb=strlen(b[i]);
	operate(b[i]);
	minus(a[i],b[i],c);
	for(j=0;j<lena;j++)
		if(c[j]!='0') break;
	for(;j<lena;j++)
		printf("%c",c[j]);
	printf("\n");
	}
}


void main()
{
	int i,n;
	scanf("%d",&n);

	for(i=1;i<=n;i++)
	{
		char a[101],b[101];
		scanf("%s",a);
		scanf("%s",b);
		int ita,itb;
		for(ita=0;a[ita]!='\0';ita++)
			;
		for(itb=0;b[itb]!='\0';itb++)
			;
		ita--;
		itb--;

		int temp=0;
		for(;itb>=0;itb--)
		{
			a[ita]=a[ita]-b[itb]-temp;
			if(a[ita]<0)
			{
				temp=1;
				a[ita]+=10;
			}
			else
				temp=0;
			a[ita]+='0';
			ita--;
		}
		for(;ita>=0;ita--)
		{
			a[ita]=a[ita]-temp;
			if(a[ita]<'0')
			{
				temp=1;
				a[ita]+=10;
			}
			else
				break;
		}

		printf("%s\n",a);
	}
}


void main()
{
	int n,i,j;
	char a[100],b[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s%s",a,b);
		for(j=strlen(a)-1;j>=strlen(a)-strlen(b);j--)
			if(a[j]>=b[j-strlen(a)+strlen(b)])
				a[j]=a[j]-b[j-strlen(a)+strlen(b)]+48;
			else
			{
				a[j]=a[j]-b[j-strlen(a)+strlen(b)]+58;
				a[j-1]--;
			}
			j=0;
			while(a[j]=='0')
				j++;
			for(;j<=strlen(a)-1;j++)
				printf("%c",a[j]);
			printf("\n");
	}
}


void main()
{
    int n,i,lengtha,lengthb,j;
	char a[100],b[100],c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	    {
		     scanf("%s",a);
			 scanf("%s",b);
			 c=getchar();
			 lengtha=strlen(a);
			 lengthb=strlen(b);
			 for(j=lengthb-1;j>=0;j--)
			    {
				      if(a[lengtha-lengthb+j]<b[j])
				  {
				      a[lengtha-lengthb+j]='0'+10+a[lengtha-lengthb+j]-b[j];
				      a[lengtha-lengthb+j-1]=a[lengtha-lengthb+j-1]-1;
				  }
				      else
					  a[lengtha-lengthb+j]='0'+a[lengtha-lengthb+j]-b[j];
				}
			 puts(a);
			}
}


void gui0(char[],int n);
int main()
{
	int num;
	scanf("%d",&num);
	char a[101],b[101];
	char**pp=(char**)malloc(num*sizeof(char*));
	for(int k=0;k<num;k++)
	{
		gui0(a,101);
		gui0(b,101);
		scanf("%s",a);
		scanf("%s",b);
		int m=strlen(a);
		int n=strlen(b);
		int j=n-1;
		for(int i=m-1;i>=m-n;i--)
		{
			if(b[j]<=a[i])
				a[i]=a[i]-b[j]+'0';
			else
			{
				a[i-1]--;
				int t=a[i]-b[j]+10;
				a[i]='0'+t;
			}
			j--;
			if(j<0)
				break;
		}
		pp[k]=(char*)malloc(101*sizeof(char));
		strcpy(pp[k],a);
	}
	for(int r=0;r<num;r++)
	{
		int i;
		for(i=0;i<strlen(pp[r]);i++)
			if(pp[r][i]=='0')
				continue;
			else
				break;
		for(;i<strlen(pp[r]);i++)
			printf("%c",pp[r][i]);
		printf("\n");
	}
	return 0;
}
void gui0(char a[],int n)
{
	for(int i=0;i<n;i++)
		a[i]='\0';
}


int main()
{
	int n;
	cin>>n;
	for(int k=1;k<=n;k++)
	{
		char a[101],b[101],c[101];
		//cin.getline(a,101);
		//cin.getline(b,101);
		cin>>a>>b;
		int lena,lenb;
		lena=strlen(a);
		lenb=strlen(b);
		for(int i=1;i<=lenb;i++)
		{
			if(a[lena-i]>=b[lenb-i])
			{
				c[lena-i]=a[lena-i]-b[lenb-i]+'0';
			}
			else
			{
				c[lena-i]=a[lena-i]+10-b[lenb-i]+'0';
				int t;
				t=lena-i;
				while(a[t-1]=='0')
				{
					a[t-1]='9';
					t--;
				}
				a[t-1]-=1;
			}
		}
		for(int i=0;i<lena-lenb;i++)
		{
			c[i]=a[i];
		}
		for(int i=0;i<lena;i++)
		{
			cout<<c[i];
		}
		cout<<endl;
	}
	return 0;
}


void main()
{
	int n;
	char cint1[101],cint2[101],result[101];
	int length1,length2;
	scanf("%d",&n);
	while(n-->0){
		getchar();
		scanf("%s",cint1);
		scanf("%s",cint2);
		length1=strlen(cint1);
		length2=strlen(cint2);
		int k0=length1-1,i=length1-1,k=k0,j;
		for(j=length2-1;j>=0;j--)
			result[k--]=cint1[i--]-cint2[j]+'0';
		while(i>=0)
			result[k--]=cint1[i--];
		for(k=k0;k>0;k--)
			if(result[k]<'0'){
				result[k]+=10;
				result[k-1]--;
			}
		for (k=0;k<k0;k++)
			if(result[k]!='0')
				break;
		while(k<=k0)
			printf("%c",result[k++]);
		printf("\n");
	}
}


int main()
{
	int n;
	char a[120],b[120];
	cin>>n;

	for(int q=1;q<=n;q++)
	{getchar();
		cin.getline(a,120);
		cin.getline(b,120);
		for(int i=0;i<strlen(b);i++)
			b[i]=96-b[i];
		for(int i=1;i<=strlen(b);i++)
		{
			a[strlen(a)-i]+=(b[strlen(b)-i]-48);
		}
		for(int i=strlen(a)-1;i>=0;i--)
		{
			if(a[i]<48)
			{
				a[i]+=10;
				a[i-1]--;
			}
		}
		for(int i=0;i<strlen(a);i++)
			cout<<(int)(a[i]-48);
		cout<<endl;
	}

	return 0;
}


int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		char integer1[101],integer2[101],answer[101];
		cin>>integer1>>integer2;
		memset(answer,'\0',sizeof(answer));
		int len1=strlen(integer1),len2=strlen(integer2);
		for(int j=len1-1,k=len2-1,count=99;j>=0;j--,k--,count--){
			if(k<0)answer[count]=integer1[j];
			else{
			if(integer1[j]-'0'>=integer2[k]-'0')answer[count]=(integer1[j]-'0'-(integer2[k]-'0'))+'0';
			else{
				integer1[j-1]=integer1[j-1]-1;
				answer[count]=integer1[j]-'0'+10-(integer2[k]-'0')+'0';
			}
		}
		}
		for(int j=0;j<100;j++){
			if(answer[j]!='\0')cout<<answer[j];
		}
		cout<<endl;
	}
	return 0;
}


int flag=0;
char minus(char a,char b)
{   int z;
	if ((int)a>=(int)b) z=(int)a-(int)b+48;
	else
	{
		z=(int)a-(int)b+10+48;
		flag=1;
	}
    return((char)z);

}
void main()
{
	char a[100],b[100];
	int n,i,j,k,la,lb,m;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s%s",a,b);
		printf("\n");
		la=strlen(a);
		lb=strlen(b);
		for(j=0;j<lb;j++)
		{   flag=0;
			a[la-j-1]=minus(a[la-j-1],b[lb-j-1]);
			if(flag)
			{
				for(k=1;;k++)
				{
					if(a[la-j-1-k]!='0')
					{
						a[la-j-1-k]=a[la-j-1-k]-1;
						if(k>1)
							for(m=1;m<=k-1;m++)
								a[la-j-1-m]='9';

							break;
					}
				}
			}
		}
		printf("%s\n",a);
	}

}


void swi(int l,char s[200]){
	int i,t;
	for(i=0;i<l/2;i++){
		t=s[i];
		s[i]=s[l-i-1];
		s[l-i-1]=t;
	}
	return;
}
int main(){
	char m[200],n[200],t[200];
	int n1,i,j,k,lm,ln,q,flag,num;
	scanf("%d",&num);
	for(n1=0;n1<num;n1++){
		scanf("%s %s",m,n);
		flag=0;
		lm=strlen(m);
		ln=strlen(n);
		if(lm<ln)
			flag=1;
		else if(lm==ln&&strcmp(m,n)<0)
			flag=1;
		if(flag){
			strcpy(t,m);
			strcpy(m,n);
			strcpy(n,t);
			q=lm;
			lm=ln;
			ln=q;
			putchar('-');
		}
		swi(lm,m);
		swi(ln,n);
		for(i=0;i<ln;i++){
			if(m[i]>=n[i])
				m[i]-=n[i];
			else{
				m[i]=10+m[i]-n[i];
				for(k=1;!m[i+k];k++);
				for(q=1;q<k;q++)
					m[i+q]=9;
				m[i+q]--;
			}
		}
		for(i=ln;i<lm;i++)
			m[i]-='0';
		for(lm--;!m[lm];lm--);
		swi(lm+1,m);
		for(i=0;i<=lm;i++)
			printf("%d",m[i]);
		if(n1<num-1)
			putchar('\n');
	}
	return 0;
}


void subtract(char a[],char b[],char c[])
{int i,carry=0;
 for(i=100;i>=0;i--)
 {if(b[i]+carry>a[i])
	{c[i]=10+a[i]-b[i]-carry+'0';
     carry=1;}
  else
	{c[i]=a[i]-b[i]-carry+'0';
	 carry=0;}
}
}

void align(char a[])
{int len,jump,m;
 len=strlen(a);
 jump=101-len;
for(m=len;m>=0;m--)
 {a[m+jump]=a[m];
  a[m]='0';}
}

void main()
{int i,x,y,z,m;
scanf("%d",&m);
while(m>0)
{char e[101],f[101],g[101];
 for(i=0;i<101;i++)
 e[i]=f[i]=g[i]='0';
 scanf("%s",e);
 scanf("%s",f);
 x=strlen(e);
 y=strlen(f);
 align(e);
 align(f);
 subtract(e,f,g);
 z=100-x;
 while(z<=99&&g[z]=='0')
 z++;
 for(i=z;i<=100;i++)
 printf("%c",g[i]);
 printf("\n");
 m=m-1;
 getchar();
}
}


//*****************************
//*?????? 1300012809   **
//*???2013.11.16          **
//*????????          **
//*****************************
int main()
{
	int n, i, j, k, changdu1, changdu2, jieguo[1005];
	char jianshu[1005], beijianshu[1005];
	char zhongjian[1005];
	cin >> n;
	cin.get();
	for (k=0; k<n; k++)
	{
		if (k!=0) cin.get();
		cin.getline(beijianshu,1001);
		cin.getline(jianshu,1001);
	    changdu1 = strlen(beijianshu);
	    changdu2 = strlen(jianshu);
	    for (i=0; i<changdu1; i++)	zhongjian[i] = beijianshu[i];
	    for (i=0; i<changdu1; i++)
		{
		    beijianshu[i] = zhongjian[changdu1-1-i];
	     	if (beijianshu[i]==' ')  beijianshu[i]='0' ;
		}
	    for (i=0; i<changdu2; i++)		zhongjian[i] = jianshu[i];
	    for (i=0; i<changdu2; i++)
		{
	     	jianshu[i] = zhongjian[changdu2-1-i];
	    	if (jianshu[i]==' ')  jianshu[i]='0' ;
		}
	    //?????
     	for (i=0; i<changdu2; i++)
		{
		   if (beijianshu[i]<jianshu[i])
		   {
		    	jieguo[i] = 10 - jianshu[i] + beijianshu[i];
		    	if (beijianshu[i+1] != '0') beijianshu[i+1] -= 1 ;
		    	else
				{
			    	j=i;
			     	while(beijianshu[j+1]=='0')
					{
			     		beijianshu[j+1] = '9' ;
			    		j = j + 1 ;
					}
			    	beijianshu[j+1] -= 1 ;
				}
		   }
	    	else
			{
		    	jieguo[i] = beijianshu[i] - jianshu[i] ;

			}
		}
	    for (i=changdu2; i<changdu1; i++)
	    	jieguo[i]=beijianshu[i] - '0' ;
	    if (beijianshu[changdu1-1]=='0') changdu1 -= 1;
	    for (i=changdu1-1; i>=0; i--) cout << jieguo[i] ;
	    cout << endl;
	}
	return 0;
}


int main()
{
    void align(char a[]);
    void substract(char a[],char b[],char c[]);
    char a[101],b[101],c[101];
    int i,j,t,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    getchar();
                    gets(a);
                    gets(b);
                    align(a);
                    align(b);
                    substract(a,b,c);
                    for(j=0;j<100;j++)if(c[j]!='0'){t=j;break;}
                    for(j=0;j<100-t;j++)c[j]=c[j+t];
                    c[100-t]='\0';
                    puts(c);
}

}
void align(char a[])
{
     int jump,m;
a[100]='\0';
jump=100-strlen(a);
for(m=100-jump;m>0;m--)
a[m+jump-1]=a[m-1];
for(m=0;m<jump;m++)
a[m]='0';
}
void substract(char a[],char b[],char c[])
{
               int i,carry=0;
               for(i=99;i>=0;i--)
               {
                                 if(carry+b[i]>a[i]){c[i]=a[i]+10-(b[i]+carry)+'0';carry=1;}
                                 else{c[i]=a[i]-(b[i]+carry)+'0';carry=0;}
               }
}


void main()
{char str1[200],str2[200];
int zhe1[200],zhe2[200];
memset(zhe1,0,sizeof(zhe1));
memset(zhe2,0,sizeof(zhe2));
int cases;
scanf("%d",&cases);
while(cases>0)
{   int n1,n2,i,j,k;
	scanf("%s%s",str1,str2);
	n1=strlen(str1);n2=strlen(str2);
	for(i=0;i<n1;i++)
		zhe1[i]=str1[i]-'0';
	for(i=0;i<n1;i++)
		zhe2[i]=str2[i]-'0';
for(j=n1-1,k=n2-1;j>=0,k>=0;j--,k--)
{if(zhe1[j]>=zhe2[k]) zhe1[j]-=zhe2[k];
else { zhe1[j]=10+zhe1[j]-zhe2[k];
zhe1[j-1]--;}
}
for(i=0;i<n1;i++)
{if(zhe1[i]!=0) break;}
for(j=i;j<n1;j++) printf("%d",zhe1[j]);
printf("\n");
cases--;
}
}


void subtract(char a[100], char b[100])
{
	int re[100];
	int lena,lenb,i,j,m=0;
	lena=strlen(a);
	lenb=strlen(b);

	for(i=0;i<lena;i++)
		re[i]=a[i]-48;
	for(i=lena-1,j=lenb-1;j>=0;i--,j--)
	{
		re[i]=re[i]+48-b[j];
		if(re[i]<0)
		{
			re[i-1]--;
			re[i]+=10;
		}
	}

	for(i=0;i<lena;i++)
	{
		if(m==0&&re[i]==0)continue;
		else {printf("%d",re[i]);m=1;}
	}

	printf("\n");
}

main()
{

	int n,i,k;
	char inp[100][100];

	scanf("%d",&n);
	k=3*n;
//	printf("k=%d\n",k);
	for(i=0;i<k;i++)
	{
//		printf("i=%d\n",i);
		gets(inp[i]);
//		printf("i=%d\n",i);
	}
//	printf("len=%d\n",strlen(inp[0]));
//	printf("str=%s\n",inp[3]);

	for(i=0;i<n;i++)
		subtract(inp[3*i+1],inp[3*i+2]);

}


void main()
{
	long n;
	char str1[LENGTH+1], str2[LENGTH+1], ln[LENGTH+1];
	int a[LENGTH+1], b[LENGTH+1], len1, len2;
	long h, i, t;

	scanf("%d\n", &n);
	for (h=1;h<=n;h++)
	{
		gets(str1);
		gets(str2);
		if (h<n) gets(ln);
		len1=strlen(str1);
		len2=strlen(str2);
		for (i=0;i<=LENGTH;i++)
		{
			a[i]=0;
			b[i]=0;
		}
		for (i=0;i<len1;i++)
			a[LENGTH-i]=str1[len1-i-1]-'0';
		for (i=0;i<len2;i++)
			b[LENGTH-i]=str2[len2-i-1]-'0';
		for (i=0;i<=LENGTH;i++)
			a[i]-=b[i];
		for (i=LENGTH;i>0;i--)
		{
			if (a[i]<0)
			{
				a[i]+=10;
				a[i-1]--;
			}
		}
		t=0;
		while (a[t]==0)
			t++;
		for (i=t;i<=LENGTH;i++)
			printf("%d", a[i]);
		if (h<n) printf("\n");
	}
}