int qi(int num)
{
	int a,b;
	a=num/10;
	b=num-10*a;
	if(num%7==0)
		return 1;
		else if(a==7||b==7)
			return 1;
		else
			return 0;
}
int main()
{
	int n;
	int sum=0;
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		if(qi(i)==0)
			sum=sum+i*i;
		printf("%d\n",sum);
return 0;
}


int main()
{
	int n,i,a,sam;
	sam=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%7==0)
			sam=sam;
		else
		{
			if(i<10)
			{
				if(i!=7)
					sam=sam+i*i;
				else
					sam=sam;
			}
			else
			{   if(i/10==7)
			     sam=sam;
			    else
				{
					a=i%10;
				    if(a==7)
					sam=sam;
				    else
					sam=sam+i*i;
				}
			}
		}

	}
	printf("%d",sam);
	return 0;
}


int main()
{
  int n,s=0,i=1;
  scanf("%d",&n);
  for  (i=1;i<=n;i++)
   { if (i%7==0)
      continue;
    else if ((i-7)%10==0)
      continue;
    else if (i==71)
      continue;
    else if (i==72)
      continue;
    else if (i==73)
      continue;
    else if (i==74)
      continue;
    else if (i==75)
      continue;
    else if (i==76)
      continue;
    else if (i==77)
      continue;
    else if (i==78)
      continue;
    else if (i==79)
      continue;
    else s=s+i*i;
   }
   printf("%d\n",s);
   return 0;
}


int main()
{
	int n,i,sum=0;
	scanf("%d",&n);
         for(i=0;i<=n;i++){
              sum=sum+i*i;
         }
	for(i=0;i<=n;i++){
		if(i%7==0)
			sum=sum-i*i;

		else if(i%10==7)
			sum=sum-i*i;

        else if((i-(i%10))==70)
		    sum=sum-i*i;
	}
	printf("%d",sum);
	return 0;
}


int yu7WuGuan(int number){
		if(number%7 == 0){
			return 0;
		}
		for(int num = number; num > 0; num /= 10){
			if (num%10 == 7){
				return 0;
			}
		}
		return 1;
	}

int main(){
		int num, result = 0;
		scanf("%d", &num);

		for(int i = 1; i <= num; i++){
			if(yu7WuGuan(i)){
				result += i*i;
			}
		}

		printf("%d", result);
		return 0;
}


/*
int cmp(const void *a,const void *b)
{
    return ((int*)a)->w-((int*)b)->w;
}

int main()
{

	string str[2];
	string temp;

	cin>>str[1]>>str[0];
	for(int k=str[0].length();k>=0;k--)
		for(int m=0;m<=str[0].length()-k;m++){

		temp=str[0].substr(m,k);
		int loc=0;

		if(str[1].find(temp)!=-1){
			cout<<temp.length()<<endl;
			return 0;
		}
	}
	return 0;
}

string s1,s2;
int m[100001];
void work()
{
  int l1,l2;
  int i,j;
  int max=0;
  cin>>s1>>s2;
  l1=s1.length();
  l2=s2.length();
  for(j=0;j<l2;j++)
    m[j]=(s1[0]==s2[j]);

  for(i=1;i<l1;i++){
    for(j=l2-1;j>0;j--)
      if(s1[i]==s2[j])
        m[j]=m[j-1]+1;
       else m[j]=0;

    for(j=0;j<l2;j++)
      if(max<m[j])
        max=m[j];
  }

  printf("%d\n",max);
 // for(i=mi-max+1;i<=mi;i++)
 //   printf("%c",s1[i]);
 // printf("\n");

}
int main()
{
  work();
  return 0;
}

*/
int max_yueshu(int a,int b)
{
     if(b==0) return a;
	 else return max_yueshu(b,a%b);
}
int main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;++i)
        if(i%7!=0 && i%10!=7 && i/10!=7)
			sum+=i*i;
	cout<<sum<<endl;
	return 0;

}


int main()
{
 int i,n,sum=0;
 scanf("%d",&n);
 for (i=1;i<=n;i++){
  if (i%7==0) continue;
  if (i%10==7) continue;
  if (i-i%10==70) continue;
 sum+=i*i;
 }
 printf("%d\n",sum);
 return 0;
}


int main()
{
	int k, sev, sum = 0, sum1 = 0, sum2 = 0, sum3 = 0;
	cin >> k;
	for (int i = 1; i <= k; i++)
		sum = sum + i * i;
	for (int i = 7; i <= k; i = i + 10)
		sum1 = sum1 + i * i;
	for (int i = 7; i <= k; i = i + 7)
		sum2 = sum2 + i * i;
	for (int i = 71; (i <= k) && (i <= 79); i++)
		sum3 = sum3 + i * i;
	sum = sum - sum1 - sum2 - sum3;
	if (k < 7)
		sum = sum;
	else if ((k >= 7) && (k < 77))
		sum = sum + 7 * 7;
	else
		sum = sum + 7 * 7 + 2 * 77 * 77;
	cout << sum << endl;
	return 0;
}


int main()
{
	int n,i,sum;
	sum=0;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
        int r,shiwei;
		r=i%10;
		shiwei=(i-r)/10;
		if(i%7==0)
		  sum=sum+0;
		else if((i-7)%10==0)
			   sum=sum+0;
		     else if (shiwei==7)
					 sum=sum+0;
			      else sum=sum+i*i;
	}
	printf("%d\n",sum);
	return 0;
}


int main()
{
	int n = 0;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <=n; i++)
	{
		int k = i; //For Processing
		int sign = (k % 7 == 0)?1:0; //For recording K's Relativeness to 7 & Initialization
		while(k>0) //Counting each Digit
		{
			sign += (k % 10 == 7);
			k = k / 10;
		}
		if(sign == 0)
		{
			sum += i * i;
			//cout << i << ' ' << sum << endl; For Debuging
		}
	}
	cout << sum;
}


int main()
{
  int n,s=0,i=1;
  scanf("%d",&n);
  for  (i=1;i<=n;i++)
   { if (i%7==0)
      continue;
    else if ((i-7)%10==0)
      continue;
    else if (i==71)
      continue;
    else if (i==72)
      continue;
    else if (i==73)
      continue;
    else if (i==74)
      continue;
    else if (i==75)
      continue;
    else if (i==76)
      continue;
    else if (i==78)
      continue;
    else if (i==79)
      continue;
    else s=s+i*i;
   }
   printf("%d\n",s);
   return 0;
}


int main()
{
   int i,sum=0,n;
   cin>>n;
    for(i=1;i<=n;i++)
	{
		if ((i-7)%10==0) sum=sum;
		else
		    if (i%7==0)  sum=sum;
		    else
				if (i>70)
					if (i<80) sum=sum;
					else sum+=i*i;
                else sum+=i*i;
	}
    cout<<sum<<endl;
    return 0;
}


int main()
{
    int zuidashu;
    float shang;
    int pingfanghe = 0;

    cin >> zuidashu;

    for (int i = 1; i <= zuidashu; i++) {
        if (i % 7 == 0) {
            pingfanghe = pingfanghe + i*i;
            continue;
        }
        for (int j = 10; j < i*10; j = j*10) {
            if (i % j - i % (j / 10) == 7*j/10) {
                pingfanghe = pingfanghe + i*i;

                break;
            }
        }
    }

    pingfanghe = (-1)*pingfanghe;
    for (int i = 1; i <= zuidashu; i++) {
        pingfanghe = pingfanghe + i*i;
    }

    cout << pingfanghe;
    return 0;
}


int main()
{
	int n,sum=0,i;
	scanf("%d", &n);
	for(i=0;i<=n;i++)
	{
		if(i%7==0)
			continue;
		else if((i-7)%10==0)
			continue;
		else if(i-70>0&&i-70<10)
			continue;
		else sum = sum + i*i;
	}
	printf("%d", sum);
	return 0;
}


int main()
{
    int n, i = 1, sum = 0, a, b;
    cin >> n;

    for (i; i <= n; i++)
    {
        b = i % 10;
        a = (i - b) / 10;
        if (i % 7 == 0 || a == 7 || b == 7)
            sum = sum;
        else
            sum = sum + i * i;
    }
    cout << sum << endl;
}


int yu7WuGuan(int);
int main(int argc, char* argv[])
{
	int num, result=0;
	scanf("%d",&num);
	for(int i=1; i<=num; i++)
	{
		if(yu7WuGuan(i))
		{
			result += i*i;
		}
	}
	printf("%d",result);
	return 0;
}
    int yu7WuGuan(int number)
	{
		if(number%7==0)
		{
			return 0;
		}
	    for(int num=number; num>0; num/=10)
		{
		    if(num%10==7)
			{
			    return 0;
			}
		}
	    return 1;
	}


int main(int argc, char* argv[])
{
	int n,i,sum,c;
	sum = 0;

   	scanf("%d",&n);
	i=0;
	while(i<n)
	{
	i++;

	c=i/10;
	if (i%7==0 || i/10==7 || i-c*10==7)
		{
			continue;
		}
	sum = sum+i*i;
	}
	printf("%d\n",sum);
	return 0;
}


int main()

{
	int n, num, figure, delta, sum;
	cin >> n;
	sum = 0;
	for(int i = 1; i <= n; i++)
	{
		num = i;
		if(num % 7 == 0)
		{
			delta = 0;
		}
		else
		{
			while(num > 0)
			{
				figure = num % 10;
				if(figure == 7)
				{
					delta = 0;
					num = 0;
				}
				else
				{
					num = num / 10;
					delta = 1;
				}
			}
		}

		if(delta == 1)
			sum = sum + i * i;
	}
	cout << sum << endl;
	return 0;
}


 int wuguan(int e)
  {
	 if(e%7==0)
	 {return 0;}
	  for(int t=e;t>0;t=t/10)
	  {int q;
		  q=t%10;
		  if(q==7)
		  {return 0;}
 }return 1;}

int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for( int i=1;i<=n;i++)
	{
		if(wuguan(i))
		{
			sum+=i*i;
		}
	}printf("%d",sum);
}


int main()
{
	int wei(int x);
	int i,t,n;
	cin>>n;
		t=0;
	for(i=1;i<=n;i++)
	{
		if(i%7!=0&&wei(i)==0)
		{
			t=t+i*i;
		}
	}
	cout<<t<<endl;
	return 0;
}
int wei(int x)
{
	int flag=0,a;
	while(x!=0)
	{
		a=x-x/10*10;
		x=x/10;
		if(a==7)
		{
			flag=1;
			break;
		}
	}
	return(flag);
}


int main()
{
	int n;
	int sum=0;
	int i=0;
    scanf("%d",&n);
	while(i<=n)
	{
		if(i%7!=0){
			if(i%10!=7){
				if(i/10!=7)
				  sum=sum+i*i;

			}

		}
		i++;
	}
	printf("%d\n",sum);
	return 0;
}


int main()
{
	int m=0, n, h=0;
	cin >> n;
    for(int j=1; j<=n; j++)
		m=m+j*j;
	for(int i=1; i<=n; i++)
	{
		if(i%7==0)
			h=h+i*i;
		else if(i%10==7)
			h=h+i*i;
		else if(i/10==7)
			h=h+i*i;
	}

	cout << m-h << endl;
	return 0;
}


int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    {
		if(i%7==0)
		   continue;
		else
		   if(i%10==7||i/10==7)
		   continue;
		   else
		   sum+=i*i;
		}
		printf("%d",sum);
}


int main()
{
	int n,m=0,sum=0;
	cin>>n;
	if (n<100)
	{for (m=1;m<n+1;m++)
			{
				if (m%7==0||m%10==7||floor(m/10)==7)
				sum = sum;
			    else sum=sum+m*m;
			}
			cout<<sum<<endl;
	}
	else
		cout<<"no count"<<endl;
}


int main()
{
	int n,i;
	int sum=0;
	scanf("%d", &n);
	for(i=1;i<=n;i++)
	{
		if(i%7==0)
			sum=sum+i*i-i*i;
		else if(i%2==1 && i%5==2)
			sum=sum+i*i-i*i;
		else if(i>=70 && i<=76)
			sum=sum+i*i-i*i;
		else if(i==78 || i==79)
			sum=sum+i*i-i*i;
		else
		sum=sum+i*i;
	}
	printf("%d", sum);

	return 0;
}


int judge(int x);
int main()
{
	int n,i,sum=0,squ=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(judge(i)==0)
		{
			squ=i*i;
			sum=sum+squ;
		}
	}
	cout<<sum<<endl;
	return 0;
}
int judge(int x)
{
	int seven=0;
	if(x%7==0)
		seven=1;
	if((x-7)%10==0)
		seven=1;
	if(x>=70 && x<80)
		seven=1;
	return seven;
}


int main()
{
	int i,n;
	int sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%7==0)
		{
			continue;
		}
		else
		{
			if((int)i/10==7)
			{
				continue;
			}
			else
			{
				if(i%10==7)
				{
					continue;
				}
				else
				{
					sum=sum+i*i;
				}
			}
		}
	}
	printf("%d",sum);
	return 0;
}


//1000062701
int main()
{
	int i, n, sum=0;
	cin >> n;
	for (i=1;i<=n;i++)
	{
		if (i%7==0||i%10==7
			||i/10==7)
			continue;
		sum = sum + i*i;
	}
	cout << sum <<endl;
	getchar ();
	getchar ();
	return 0;
}


int main()
{
	int n;
	int num = 0;
	int m;
	scanf( "%d",&n );
	for( int i =1;i <= n ;i ++)
	{
		if( (i % 7) == 0 || (i % 10) == 7)
			continue;
		if( i / 10 != 0 )
		{
			m = i / 10;
			if( m == 7)
				continue;
		}
		num = num + i * i;
	}
	printf( "%d\n",num );
	return 0;
}


int main()
{
	int n;
	int i, sum=0, t;
	cin >> n;
	for (i=1;i<=n;i++)
	{
		if (i%7!=0)
		{
			t = (i+3) % 10;
			if(t!=0)
			{
				if(i>79)
					sum=sum+i*i;
				if(i<70)
					sum=sum+i*i;
			}
		}
	}
	cout << sum << endl;
	return 0;
}


int main()
{
	int n,i,x,y,z,m,sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		y=i%7;
		x=i%10;
		z=i-x;
		m=z/10;
		if(x==7||y==0||m==7)
			continue;
		sum=sum+i*i;
	}
	printf("%d",sum);
	return 0;
}


int main()
{
    int n,i;
    int sum=0;
    scanf("%d",&n);
    for(i=0;i<=n;i++)
    {
                    if((i%7)==0)
                    {
                             continue;
                    }
                    if((i%10)==7)
                    {
                              continue;
                    }
                    if((i/10)==7)
                    {
                                   continue;
                    }
                    sum+=i*i;
    }
    printf("%d",sum);
    return 0;
}


int main()
{
	int n;
	cin >> n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%7==0);
		else if(i%10 == 7);
		else if(i>=70 && i<=79);
		else
			sum+= i*i;
	}
	cout << sum << endl;
	return 0;
}


int main()
{
    int i,n,s;
    double i0;
    i=1,s=0;
    cin>>n;
    while(i<=n)
    {
        if(i%7==0||floor(i/10)==7||i-floor(i/10)*10==7)i=i+1;
        else s=s+i*i,i=i+1;
    }
    cout<<s;
    return 0;
}


int seven(int x);

int main()
{
    float a[11][100],p=0,gpa;
    int q,n,i,j=0;
    long m=0  ;
    scanf("%d",&n)  ;
    for(q=1;q<=n;q++)
    {
        if((q%7!=0)&&(seven(q)==0))
        {
            m+=q*q;

        }

    }
    printf("%ld",m);

    return 0;
}

int seven(int x)
{
    int i;
    for(i=1;i>=0;i--)
    {
        if(x/(int)(pow(10,i))==7)
        {
            return 1;
        }
        else
        {
        x-=  x/(int)(pow(10,i))*pow(10,i)          ;
        }

    }
    return 0;
}


int main()
{
	int i,n,jieguo=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if((i-7)%10==0)
			jieguo=jieguo;
		else if((i/10)==7)
			jieguo=jieguo;
		else if(i%7==0)
			jieguo=jieguo;
		else
			jieguo+=i*i;
	}
	printf("\n%d",jieguo);
	return 0;
}


int main(int argc, char* argv[])
{
	int i,sum,n;
	scanf("%d",&n);
        sum=0;
	for(i=1;i<n+1;i++)
		if( i%7==0)
			continue;
		else if(i%10==7)
			continue;
		else if(i/10==7)
			continue;
		else{
			sum=sum+i*i;
		}

	printf("%d",sum);
	return 0;
}


int main()
{int n;
cin>>n;
int i;
int sum=0;
for (i=1;i<=n;i++)
{if (69<i&&i<80)
sum=sum;
else if(i%10==7)
	sum=sum;
else if(i%7==0)
	sum=sum;
else sum=sum+i*i;
}
cout<<sum<<endl;
return 0;
}


int  main()
{
	int n,i,k,s,j,a,f,g;
	int sum=0;
	cin>>n;
	for (i=1;i<=n;i++)
		{
			a=0;
			f=i;
			g=i;
	  for(j=0;f!=0;f/=10,j++);
		for (k=0;k<j;k++)
			{
				s=g%10;
		    if (s==7)
				a=1;
			else a=a;
			g=g/10;
		}
		if (i%7==0)
			a=1;
		else
			a=a;
		if (a==0)
			sum=sum+i*i;
		else sum=sum;
	}
		cout<<sum<<endl;
return 0;
}


int mm(int i)
{
	int j;
	if(i%7==0)
{ return 0;
}for(j=i;j>0;j/=10)
{if(j%10==7){
return 0;}
}return 1;
}
int main(int argc, char* argv[])
{
     int i,n,sum;
	scanf("%d",&n);
for(i=1,sum=0;i<=n;i++)
{if (mm(i)==1)
{ sum+=i*i;
}
}
	printf("%d",sum);
	return 0;
}


struct Stu
{
    char stu[100];
    struct Stu *link;
};
int main()
{
    struct Stu *p1,*p2;
    p2=p1=(struct Stu *)malloc(LEN);
    gets(p1->stu);
    p1->link=NULL;
    for(;;)
    {
        p2=p1;
        p1=(struct Stu *)malloc(LEN);
        gets(p1->stu);
        p1->link=p2;
        if(strcmp(p1->stu,"end")==0) break;
    }
    for(;;)
    {
        puts(p2->stu);
        p2=p2->link;
        if(p2==NULL) break;
    }
    return 0;
}


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


typedef struct node{
	char id[100],name[100],sex[2],address[100],age[10],grade[10];
	struct node *next;
}node;

node *head=NULL;

int create(){
	node *p = (node*)malloc(sizeof(node));
	scanf("%s",p->id);
	if(p->id[0]=='e'){free(p);return 1;}
	scanf("%s%s%s%s%s",p->name,p->sex,p->age,p->grade,p->address);

	p->next = head;
	head = p;
	return 0;
}
void print(){
	node *p = head,*temp;
	for(;p!=NULL;){
		printf("%s %s %s %s %s %s\n",p->id,p->name,p->sex,p->age,p->grade,p->address);
		temp = p;
		p = p->next;
		free(temp);
	}
}

int main()
{
	int i,j,n,m,k;
	for(;;){
		if(create()==1)break;
	}
	print();
}


struct student
{char num[20];
char name[20];
char sex;
int age;
char score[20];
char add[20];
struct student *next;
};
int main()
{
struct student *p;
struct student *p1,*p2;
p1=(struct student*)malloc(len);
(*p1).next=0;
scanf("%s",(*p1).num);
while((*p1).num[0]!='e'){
scanf("%s %c %d %s %s",(*p1).name,&(*p1).sex,&(*p1).age,(*p1).score,(*p1).add);
p2=p1;
p1=(struct student*)malloc(len);
(*p1).next=p2;
scanf("%s",(*p1).num);
}
p=p2;
while(p){
printf("%s %s %c %d %s %s\n",(*p).num,(*p).name,(*p).sex,(*p).age,(*p).score,(*p).add);
p=(*p).next;
}
return 0;
}


int main()
{
	int n=0;
	struct student
	{
		char num[20];
		char name[20];
		char sex[5];
		int age;
		char score[10];
		char add[100];
		struct student *next;
	}*p1,*head,*p2,*end,*p3,*heade;
	head=NULL;
	p2=p1=(struct student *)malloc(LEN);
	scanf("%s",p1->num);
	if(p1->num[0]!='e')
	{
		head=p1;
		scanf("%s %s %d %s %s",p1->name,p1->sex,&p1->age,p1->score,p1->add);
		n=1;
	}
	p1=(struct student *)malloc(LEN);
	scanf("%s",p1->num);
	while(p1->num[0]!='e')
	{
		scanf("%s %s %d %s %s",p1->name,p1->sex,&p1->age,p1->score,p1->add);
		n++;
		p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
	}
	p2->next=NULL;
	end=p2;
	if(n==1)
		printf("%s %s %s %d %s %s\n",head->num,head->name,head->sex,head->age,head->score,head->add);
	else if(n==2)
	{
		printf("%s %s %s %d %s %s\n",end->num,end->name,end->sex,end->age,end->score,end->add);
		printf("%s %s %s %d %s %s\n",head->num,head->name,head->sex,head->age,head->score,head->add);
	}
	else
	{
		p1=head;
		p2=head->next;
		p3=p2->next;
		p1->next=NULL;
		p2->next=p1;
		while(p3->next!=NULL)
		{
			p1=p2;
			p2=p3;
			p3=p2->next;
			p2->next=p1;
		}
		p3->next=p2;
		heade=p3;
		p1=heade;
		while(p1!=NULL)
		{
			printf("%s %s %s %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add);
			p1=p1->next;
		}
	}
	return 0;
}


struct stu
{char num[50];
struct stu * next;
};
void main()
{
	struct stu * head,*p1,*p2;
	int i=1;
	p1=p2=(struct stu *)malloc(L);
    gets(p1->num);
	head=p1;
	while((strcmp(p1->num,"end")!=0))
	{
		p1=(struct stu*) malloc(L);
		gets(p1->num);
		p2->next=p1;
		p2=p1;i++;
	}
	p2->next=0;
	int k;
	for(;i>1;i--)
	{
		k=i;
		for(p1=head;k>2;k--)
		{p1=p1->next;}
		printf("%s\n",p1->num);
	}
}


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


struct student
{
 char num[10];
 char name[20];
 char sex[2];
 int  age;
 float score;
 char address[40];
 struct student *next;
};
void main()
{
   struct student *p,*p1,*p2;
   p1=(struct student *)malloc(len);
   p1->next=NULL;
   scanf("%s",p1->num);
	   while(p1->num[0]!='e')
	   {
		   scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->address);
		p2=p1;
	    p1=(struct student*)malloc(len);
		p1->next=p2;
		scanf("%s",p1->num);
	   }
	   if(p2->next!=NULL){
   for(p=p2;p->next!=NULL;p=p->next)
	   {
	   printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
	   }
       printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);
	   }
	   if(p2->next=NULL)

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


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

int main()
{
	struct student *p1,*p2,*head;
	p1=(struct student*)malloc(sizeof(struct student));
	p1->next=NULL;
	scanf("%s",p1->num);
	if (p1->num[0]!='e')
	{
	while (p1->num[0]!='e')
	{
		scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->add);
        p2=p1;
	    p1=(struct student*)malloc(sizeof(struct student));
		p1->next=p2;
		scanf("%s",p1->num);
	}
	head=p2;
	while (head!=NULL)
	{
		printf("%s %s %s %d %g %s\n",head->num,head->name,head->sex,head->age,head->score,head->add);
		head=head->next;
	}
	}
	return 0;
}


struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	float score;
	char address[1000];
	struct student *next;
}stu[10000];
int main()
{
	struct student *head,*p;
	int i,j;
	char str[4]="end";
	for(i=0;;i++)
		{
			scanf("%s",stu[i].num);
	        if(strcmp(stu[i].num,str)==0)
			break;
			scanf("%s",&stu[i].name);
		    scanf(" %c",&stu[i].sex);
		    scanf("%d",&stu[i].age);
		    scanf("%f",&stu[i].score);
		    scanf("%s",&stu[i].address);
	}
	stu[0].next=NULL;
	for(j=1;j<i;j++)
		stu[j].next=&stu[j-1];
	head=&stu[i-1];
	if (i>0)
			for(p=head;p!=NULL;p=p->next)
		    printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address);

	return 0;
}


struct student
{
	char num[100];
	struct student *prev;
};

main()
{
	struct student *p1,*p2;
	int flag=0;
	while (1)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		gets(p1->num);
		if (*(p1->num)=='e') break;
		else
		{
			if (flag==0)
			{
				p2=p1;
				p1->prev=NULL;
				flag=1;
			}
			else
			{
				p1->prev=p2;
				p2=p1;
			}
		}
	}
	while (p2!=NULL)
	{
		printf("%s\n",p2->num);
		p2=p2->prev;
	}
	return 0;
}


struct student
{
    char id[50];
    char s[50];
    char sex;
    int age;
    char score[10];
    char add[20];
    struct student *po;
};
int main()
{
    struct student *p,*q;
    q=(struct student*)malloc(LEN);
    scanf("%s %s %c %d %s %s",q->id,q->s,&q->sex,&q->age,q->score,q->add);
    q->po=NULL;
    p=q;
    q=(struct student*)malloc(LEN);
    scanf("%s",q->id);
    while(strcmp(q->id,"end")!=0)
    {
     scanf("%s %c %d %s %s",q->s,&q->sex,&q->age,q->score,q->add);
     q->po=p;
     p=q;
     q=(struct student*)malloc(LEN);
     scanf("%s",q->id);
    }
    printf("%s %s %c %d %s %s\n",p->id,p->s,p->sex,p->age,p->score,p->add);
    while(p->po!=NULL)
    {
      p=p->po;
      printf("%s %s %c %d %s %s\n",p->id,p->s,p->sex,p->age,p->score,p->add);
    }
    return 0;
}


int n;
struct student
{
char s[100];
struct student *next;
};

void main()
{
struct student *head, *p1, *p2; n=0;
p1=p2=( struct student*) malloc(LEN);
gets(p1->s);
head=NULL;

while(p1->s[0]!='e')
{
n=n+1;
if(n==1) p1->next=NULL;
else p1->next=p2;
p2=p1;
p1=(struct student*)malloc(LEN);
gets(p1->s);
}
head=p2;

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

}


struct Student
{
	char r[200];
	struct Student *next,*up;
};
int main()
{
	struct Student *p,*h,*pre;
	h=NULL;
	while (1)
	{
		p=malloc(L);
		if (h==NULL)
		{
			h=p;
			p->up=h;
		}
		else
		{
			pre->next=p;
			p->up=pre;
		}
		gets(p->r);
		if (strcmp(p->r,"end")==0) break;
		//scanf("\n");
		pre=p;
	}
	p=pre;
	while (1)
	{
		printf("%s",p->r);
		if (p==h) break;
		else printf("\n");
		p=p->up;
	}
	return 0;
}


struct student{
	char num[50];
	char name[50];
	char sex[50];
	char age[50];
	char score[50];
	char adr[50];
	struct student *next;
};//?????????????
int main(){
	struct student *p1,*p2,*head;
	p1=(struct student *)malloc(LEN);
	int i=0;
	p2=NULL;
	for(;;i++)
	{
		p1=(struct student *)malloc(LEN);
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0)
		{//??p1->num?????
			break;
		}
		scanf("%s %s %s %s %s",p1->name,p1->sex,p1->age,p1->score,p1->adr);
		p1->next=p2;
		p2=p1;

	}

	head=p2;
	if(head!=NULL)
	{
		p1=head;
		do{
			printf("%s %s %s %s %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->adr);
			p1=p1->next;
		}while(p1!=NULL);
	}
	return 0;
}


struct stu
{
	char xinxi[100];
	struct stu *next;
};
void main()
{
	int len=1,i;
	struct stu *p1,*p2,*head,*new1,*newhead;
	p1=p2=head=(struct stu *)malloc(sizeof(struct stu));
	gets(p1->xinxi);
	while(strcmp(p1->xinxi,"end")!=0)
	{
		p1=(struct stu *)malloc(sizeof(struct stu));
		gets(p1->xinxi);
		if(strcmp(p1->xinxi,"end")==0)
			p2->next=NULL;
		else
		{
			p2->next=p1;
			p2=p1;
			len++;
		}
	}
	p1=head;
	for(i=0;i<len;i++)
	{
		p2=p1=head;
		while(p1->next!='\0')
		{
			p2=p1;
			p1=p1->next;
		}
		if(i==0)
		{
			newhead=new1=p1;
		}
		else
		{
			new1=new1->next=p1;
		}
		p2->next=NULL;
	}
	p1=newhead;
	for(i=0;i<len;i++)
	{
		printf("%s\n",p1->xinxi);
		p1=p1->next;
	}
}


int main()
{
    struct student
    {
    char a[20];
    char b[20];
    char c[20];
    char d[20];
    char e[20];
    char f[20];
    struct student *pNext;
    };
    struct student *pHeader = (struct student *)malloc(sizeof(struct student));
    pHeader->pNext=NULL;
    struct student *p;
    while(1)
    {
    p=(struct student *)malloc(sizeof(struct student));
    p->pNext=pHeader->pNext;
    pHeader->pNext=p;
    scanf("%s",p->a);
    if(p->a[0]=='e') break;
    scanf("%s %s %s %s %s",p->b,p->c,p->d,p->e,p->f);
    }
    p=pHeader->pNext->pNext;
    while(1)
    {
    if(p==NULL) break;
    printf("%s %s %s %s %s %s\n",p->a,p->b,p->c,p->d,p->e,p->f);
    p=p->pNext;
    }
}


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


main()
{
      int i,j,k,n,m;
      struct student
      {
            char num[200];
            char name[200];
            char sex;
            int age;
            char score[20];
            char add[500];
             }stu[1000];
             i=0;
            while(1)
            {
                    scanf("%s",stu[i].num);
                    if(strcmp(stu[i].num,"end")==0)
                                 break;
      scanf("%s %c %d %s %s",stu[i].name,&stu[i].sex,&stu[i].age,stu[i].score,stu[i].add);
                                 i++;
                                 }
      for(j=i-1;j>=0;j--)
      {
      printf("%s %s %c %d %s %s\n",stu[j].num,stu[j].name,stu[j].sex,stu[j].age,stu[j].score,stu[j].add);
                         }

           }


struct L
{
 char a[6][20];
 struct L *pq;
 struct L *ph;
};
struct L *creat(void)
{
 struct L *p1,*p2,*p3,*head,*end;
 int i,j,k,l;
 l=sizeof(struct L);
 p1=head=(struct L *)malloc(l);
 p1->pq=NULL;
 do
 {
  for(i=0;i<6;i++)
   scanf("%s",p1->a[i]);
  p2=(struct L *)malloc(l);
  p3=p2->pq=p1;
  p1->ph=p2;
  p1=p2;
 }while(p3->a[0][0]!='e');
 return p3->pq;
}
int main()
{struct L *creat(void);
 int i,j;
 struct L *head,*p1,*p2;
 p1=head=creat();
 do
 {for(i=0;i<6;i++)
  {if(i==0) printf("%s",p1->a[0]);
   else printf(" %s",p1->a[i]);}
  printf("\n");
  p1=p1->pq;
 }while(p1!=NULL);
}


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

         if(i==n)
         p=news=p1;
         else
         {
           p=p->next=p1;
           p2->next=NULL;
          }

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


struct student
{
	char num[30];
	char name[30];
	char s;
    float grad1;
	float grad2;
	char add[30];
	struct student *next,*prev;
};

void main()
{
	struct student *head,*temp,*end;
	head=(struct student *)malloc(sizeof(struct student));
	temp=head;
	head->prev=0;

	while(1)
	{
scanf("%s",temp->num);
if(strcmp(temp->num,"end")==0)
break;

scanf("%s %c %f %f %s",temp->name,&temp->s,&temp->grad1 ,&temp->grad2,temp->add );

temp->next=(struct student *)malloc(sizeof(struct student));
temp->next->prev =temp;
temp=temp->next;

}
end=temp->prev;
end->next=0;

temp=end;
while(temp!=0)
{
	printf("%s %s %c %g %g %s\n",temp->num ,temp->name,temp->s,temp->grad1 ,temp->grad2,temp->add );
	temp=temp->prev;
}
}


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

}


struct stu
{
	char inf[50];
	struct stu *next;
};

struct stu *head,*p1,*p2;
int output(struct stu *point);
int main()
{

	p1=(struct stu *)malloc(sizeof(struct stu));
	head=p1;
	while(gets((*p1).inf)!=NULL)
	{
		p2=(struct stu *)malloc(sizeof(struct stu));
		(*p1).next=p2;
		p1=p2;
	}
	(*p1).next=NULL;
	output(head);
	return 0;
}

int output(struct stu *point)
{
	if(strcmp(point->next->inf,"end")!=0)
		output(point->next);
	puts((*point).inf);
	return 0;
}


struct student
{
	char num[50];
	char name[50];
	char sex[1];
	int age;
	float score;
	char address[50];
	struct student *next;
};
void main()
{
	struct student *head,*p1,*p2;
	p1=p2=(struct student*)malloc(sizeof(struct student));
	head=p1;
	scanf("%s%s%s%d%f%s",p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
	p2->next=NULL;
	while(strcmp(p1->num,"end")!=0)
	{
		p1=(struct student*)malloc(sizeof(struct student));
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0) break;
		scanf("%s%s%d%f%s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address);
		p2=p1;
		p2->next=head;
		head=p1;
	}
	p2=head;
	while(p2!=NULL)
	{
		printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->address);
		p2=p2->next;
	}
}


struct student
{
  char str[1000];
  struct student *next;
};
void main()
{
  struct student a[1000],*p,*head;
  int i,j,t;
  for(i=0;;i++)
  {
	gets(a[i].str);

	if(a[i].str[0]=='e')
	break;
  }
  for(j=i-1;j>=0;j--)
  {
	 head=&a[i-1];   /*???a[i-1]???a[i]????????*/
	 a[j].next=&a[j-1];  /*????????end*/
	 a[0].next=NULL;
  }

  p=head;
  do
  {
	  printf("%s\n",p->str);
	  p=p->next ;
  } while(p!=NULL);
}


main()
{
    struct inf
	{
	struct inf *pLate;
	char num[20];
	char nam[20];
	char gen;
	int old[20];
	int sco[20];
	char loc[20];
	struct inf *pNext;
	};
	int i,j,k;
	struct inf *pHeader;
	pHeader=(struct inf *)malloc(sizeof(struct inf));
	struct inf *p;
	struct inf *p1=NULL;
	p=pHeader;
	pHeader->pLate=NULL;
	for(i=0;;i++)
	{
		p->pNext=(struct inf *)malloc(sizeof(struct inf));
		p=p->pNext;
		p->pLate=p1;
		scanf("%s",p->num);
		if(p->num[0]=='e')
		{
		    p->pNext=NULL;
			break;
		}
		else
		{
		scanf("%s %c %s %s %s",p->nam,&p->gen,p->old,p->sco,p->loc);
		p1=p;
		}
	}
	for(j=i;j>=1;j--)
	{
		p=p->pLate;
		printf("%s %s %c %s %s %s\n",p->num,p->nam,p->gen,p->old,p->sco,p->loc);
	}
	p=pHeader;
	struct inf *pd;
	for(k=0;k<=i;k++)
	{
		pd=p;
		p=p->pNext;
		free(pd);
	}
	free(p);
}


struct stud
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char grade[10];
	char add[30];
	struct stud *next;
};
struct stud *creat(void)
{
	struct stud *head,*p1,*p2;
	p1=p2=(struct stud *)malloc(sizeof(struct stud));
	p2->next=0;
	head=p1;
	for(;;)
	{
		scanf("%s",p1->num);
		if(*(p1->num+2)=='d')
			return head;
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->grade,p1->add);
		p1=(struct stud *)malloc(sizeof(struct stud));
		head=p2;
		p1->next=p2;
		p2=p1;
	}
}
void print(struct stud *head)
{
	struct stud *p;
	for(p=head;p!=0;p=p->next)
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->grade,p->add);
}
void main()
{
	struct stud *head;
	head=creat();
	print(head);
}


struct student
{
	char id[100];
	char name[100];
	char sex;
	int age;
	char score[100];
	char addr[100];
    struct student *pre,*next;
};
void main()
{
	struct student *p1,*p2,*head1,*head2;

	int n=0;
	char temp[100];
	head1=NULL;
	p1=p2=NULL;
	while(scanf("%s",temp),strcmp(temp,"end")!=0)
	{
		n=n+1;
		p1=(struct student *)malloc(sizeof(struct student));
		p1->pre=NULL;
		p1->next=NULL;

		strcpy(p1->id,temp);
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->addr);
		if(n==1)head1=p1;else {p2->next=p1;p1->pre=p2;}
		p2=p1;
	}

	head2=p2;
	while(p2!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p2->id,p2->name,p2->sex,p2->age,p2->score,p2->addr);
		p2=p2->pre;
	}
}


	struct stu
	{
	char num[30];
	char name[30];
	char sex;
	int age;
	float score;
	char add[30];
	struct stu *next;
	};
	struct stu *p1,*p2,*head;
int main()
{
	void result(struct stu*);

	p1=p2=(struct stu*) malloc(sizeof(struct stu));
	scanf("%s ",p1->num);
	scanf("%s ",p1->name);
	scanf("%c",&(p1->sex));
	scanf("%d",&(p1->age));
	scanf("%g",&(p1->score));
	scanf("%s",p1->add);
	head=p1;head->next=0;
	for(;;)
	{

	 p1=(struct stu*) malloc(sizeof(struct stu));
     p2->next=p1;
	scanf("%s",p1->num);
	if(p1->num[0]=='e'&&p1->num[1]=='n'&&p1->num[2]=='d')
	{p2->next=0;goto print;}
	scanf("%s ",p1->name);
	scanf("%c",&(p1->sex));
	scanf("%d",&(p1->age));
	scanf("%g",&(p1->score));
	scanf("%s",p1->add);
    p2=p1;
	}
    print:result(head);
	return 0;
}
void result(struct stu *x)
{
	if(x->next==0)
	{printf("%s ",x->num);
	printf("%s ",x->name);
	printf("%c",x->sex);
	printf(" %d",x->age);
	printf(" %g",x->score);
	printf(" %s",x->add);
	printf("\n");
	}
	else
	{
	result(x->next);
    printf("%s ",x->num);
	printf("%s ",x->name);
	printf("%c",x->sex);
	printf(" %d",x->age);
	printf(" %g",x->score);
	printf(" %s",x->add);}
	printf("\n");
}


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

	int n=1,m;
	struct student *p1,*p3[600];
	p1=p3[0]=(struct student *)malloc(sizeof(struct student));
	gets(p1->imfor);
	while (p1->imfor[0]!='e')
	{
		p1=(struct student * )malloc(sizeof(struct student));
		p3[n]=p1;
		n++;
		gets(p1->imfor);
	}
	for (m=n-2;m>=0;m--)
	{
		printf("%s\n",p3[m]->imfor);
	}
}


struct student{
		struct student *pre;
		char s[100];
		struct student *next;
	};

struct student *creat()
{
	struct student *p1,*p2;
    p1=(struct student*)malloc(len);
	gets(p1->s);
	p1->pre=NULL;
	p1->next=NULL;

	p2=p1;
	while(strcmp(p1->s,"end"))
	{
	p1=(struct student*)malloc(len);
	gets(p1->s);
	p1->pre=p2;
	p2->next=p1;
	p1->next=NULL;
	p2=p1;
	}
	return(p1->pre);
}

void print(struct student *end)
{
	while(end)
	{
	puts(end->s);
	end=end->pre;
	}
}

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


struct student
{
	char stu[100];
	struct student *next;
};
int n;

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

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

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


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

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


struct student
{

/*char id[20];

char name[10];

char sex;

int age;

int score;

char addr[20];*/
	char s[100];

struct student *next;
};
int n;
struct student *creat(void)
{

struct student *head;

struct student *p1,*p2;

n=0;

p1=p2=(struct student *)malloc(LEN);

//scanf("%s",p1->id);
gets(p1->s);

/*while(p1->s!="end")*/
while(strcmp(p1->s,"end")!=0)

{
//printf(p1->s);
//scanf("%s %c %d %d %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->addr);

n++;

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

else p1->next=p2;

p2=p1;

p1=(struct student *)malloc(LEN);

//scanf("%s",p1->id);
gets(p1->s);

}
//printf(p1->s);
head=p2;
	//printf(p2->s);

return(head);
}
void print(struct student *head)
{

struct student *p;

p=head;
//printf(p->s);

if(head!=NULL)

do

{

//printf("%s %s %c %d %d %s",p->id,p->name,p->sex,p->age,p->score,p->addr);
	if (p->next != NULL)
	{
		printf(p->s);
		printf("\n");
	}
	else
		printf(p->s);

p=p->next;

}while(p!=NULL);
}
void main()
{

struct student*head;

head=creat();

print(head);
}


struct Student
{
    struct Student *previous;
	char no[20];
    char name[30];
	char sex;
	int age;
	float score;
	char address[30];
};

struct Student *creat()
{
	struct Student *end,*p1,*p2;
	p1=NULL;
    for(;;)
	{
		p2=p1;
		p1=(struct Student*)malloc(LEN);
	    p1->previous=p2;
		scanf("%s",p1->no);
		if(strcmp(p1->no,"end")==0)break;
		else
		{
			scanf("%s",p1->name);
		    getchar();
    	    p1->sex=getchar();
    	    scanf("%d%f",&p1->age,&p1->score);
    	    scanf("%s",p1->address);
		}
	}
	end=p2;
	return(end);
}

void print(struct Student *end)
{
	struct Student *p;
	p=end;
	do
	{
		printf("%s %s %c %d %g %s\n",p->no,p->name,p->sex,p->age,p->score,p->address);
		p=p->previous;
	}while(p!=NULL);
}

void main()
{
	struct Student *end;
	end=creat();
	print(end);
}


struct student
{
	char a[100];
	struct student *pre;
};
struct student *creat()
{
	struct student *p1;struct student *p2;
	struct student *head;
	head=(struct student *) malloc(sizeof(struct student));
	p1=p2=head;
	head->pre=0;
	while(1)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		p1->pre=p2;
		gets(p1->a);
		if(p1->a[0]=='e')
		{
			return (p2);
		}
		p2=p1;
	}
}
int main()
{
	struct student *p1;
	p1=creat();
	while(p1->pre!=0)
	{
		printf("%s\n",p1->a);
		p1=p1->pre;
	}
	return 0;
}
//?????????????????


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

struct seqs *build()//????
{
    struct seqs *head,*newnode,*p;

	newnode=(struct seqs *)malloc(len);  newnode->next=NULL;//????????
    scanf("%s %s %c %d %f %s",newnode->num,newnode->name,&newnode->sex,&newnode->age,&newnode->score,newnode->addr);//????????????
	p=newnode;//???p?????????

    while(1)//???????????????????
	{
        newnode=(struct seqs *)malloc(len);//?????
		scanf("%s",newnode->num);
		if(newnode->num[0]=='e')
			break;//???????????
        scanf("%s %c %d %f %s",newnode->name,&newnode->sex,&newnode->age,&newnode->score,newnode->addr);//????
		newnode->next=p;//??????????
		p=newnode;//???p??????
	}
	head=p;//??head
	return head;
}

void main()
{
	int i;
	struct seqs *p;
	p=build();
	while(p!=NULL)
	{
        printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->addr);
		p=p->next;
	}
}


int main(){
	struct {
		char No[100];
		char name[20];
		char sex;
		int age;
		float grade;
		char address[20];
	} stu[10000];
	int i;
	cin>>stu[0].No>>stu[0].name>>stu[0].sex>>stu[0].age>>stu[0].grade>>stu[0].address;  //???????
	for(i=1;stu[i-1].No[0]!='e';i++){
		cin>>stu[i].No;
		if(stu[i].No[0]!='e')  //????end?????
            cin>>stu[i].name>>stu[i].sex>>stu[i].age>>stu[i].grade>>stu[i].address;
	}
	for(i=i-2;i>=0;i--)  //????
		cout<<stu[i].No<<" "<<stu[i].name<<" "<<stu[i].sex<<" "<<stu[i].age<<" "<<stu[i].grade<<" "<<stu[i].address<<endl;
	return 0;
}


struct student
{
	char num[200];
	char name[100];
	char xingbie;
	int age;
	char score[200];
	char add[200];
	struct student *next;
};
struct student*creat()
{
	struct student *p1,*head;
	p1=(struct student*)malloc(LEN);
	head=NULL;
	scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0) return head;
	scanf("%s %c %d %s %s",p1->name,&p1->xingbie,&p1->age,p1->score,p1->add);
	while(1)
	{
		p1->next=head;
		head=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0)
			break;
		else
			scanf("%s %c %d %s %s",p1->name,&p1->xingbie,&p1->age,p1->score,p1->add);
	}
	return (head);
}
void main()
{
	struct student *p;
	p=creat();
	while(p!=NULL)
	{
		if((strcmp(p->num,"end")==0)){p=p->next;continue;}
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->xingbie,p->age,p->score,p->add);
		p=p->next;
	};
}


struct stu
{
	char num[1000];
	struct stu *pre;
}*phead,*p1,*p2,*pend;
void print(void)
{
	struct stu *p;
	for(p=pend;p!=phead;)
	{
		puts(p->num);
		p=p->pre;
	}
	puts(p->num);
}

main()
{
	for(p1=p2=phead=(struct stu*)malloc(sizeof(struct stu));;)
	{
		gets(p1->num);
		if(p1->num[0]=='e')
		{
			pend=p1->pre;
			break;
		}
		p1=(struct stu*)malloc(sizeof(struct stu));
		p1->pre=p2;
		p2=p1;
	}
	print();
}


struct student
{
	char number[20];
	char name[20];
	char sex[2];
	int year;
	float score;
	char address[100];
	struct student *next;
};
int main()
{
	struct student *p1,*p2;
	p1=(struct student *)malloc(sizeof(struct student));
	p1->next=NULL;
	scanf("%s",p1->number);
	while(p1->number[0]!='e')
	{
		scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->year,&p1->score,p1->address);
		p2=p1;
		p1=(struct student *)malloc(sizeof(struct student));
		p1->next=p2;
		scanf("%s",p1->number);
	}
	while(p2!=NULL)
	{
		printf("%s %s %s %d %g %s\n",p2->number,p2->name,p2->sex,p2->year,p2->score,p2->address);
		p2=p2->next;
	}
	return 0;
}


struct Student
	{
		char num[10];
		char nam[20];
		char sex[2];
		char age[3];
		char sco[6];
		char add[12];
		struct Student*next;
	};
int n;
struct Student*creat(void)
{
	struct Student*head;
	struct Student*p;
	p=(struct Student*)malloc(LEN);
	head=NULL;n=0;
	scanf("%s",p->num);
	while(strcmp(p->num,"end")!=0)
	{
		n=n+1;
		scanf("%s%s%s%s%s",p->nam,p->sex,p->age,p->sco,p->add);
		if(n==1)head=p;
		else
		{
			p->next=head;
			head=p;
		}
		p=(struct Student*)malloc(LEN);
		scanf("%s",p->num);
	}

	return(head);
}
int main()
{
	struct Student*pt;
	pt=creat();
	while(pt!=NULL)
	{
		printf("%s %s %s %s %s %s\n",pt->num,pt->nam,pt->sex,pt->age,pt->sco,pt->add);
		pt=pt->next;
	}
	return 0;
}


struct student
{char number[100];
char name[100];
char sex;
int age;
char score[20];
char address[100];
struct student *nest;
struct student *front;
};
void main()
{
	struct student *p1,*p2;
	int n=0;
	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);
		n=n+1;
		p2->nest=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		p1->front=p2;
		scanf("%s",&p1->number);
	}
	p2->nest=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 student{
	char num[20],name[20],add[100],sex[2];
	int age;
	float score;
	struct student *next;
};
void main()
{
	struct student *p1,*p,*p2;
	p=(struct student*)malloc(sizeof(struct student));
	p->next=NULL;
	scanf("%s",p->num);
	while(p->num[0]!='e')
	{
		scanf("%s%s%d%f%s",p->name,p->sex,&p->age,&p->score,p->add);
		p1=p;
		p=(struct student*)malloc(sizeof(struct student));
		p->next=p1;
	    scanf("%s",p->num);
	}
	p2=p1;
	while(p2!=NULL)
	{
		printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->add);
		p2=p2->next;
	}

}


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


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

struct student *creat(void)
{
struct student *head;
struct student *p,*q;
int t=0;

head=(struct student*) malloc (sizeof (struct student));
gets(head->all);
q=head;
head->next=NULL;

do
{
	if(t>0)
		{
		p->next=q;
		q=p;
		}

p=(struct student*) malloc (sizeof (struct student));
gets(p->all);
t++;
}while(strcmp(p->all,"end")!=0);

return(q);

}

void print(struct student *head)
{
struct student *p;
p=head;

do
{
printf("%s\n",p->all);
p=p->next;
}while (p!=NULL);

}

void main()
{
struct student *headnew;

headnew=creat();

print(headnew);

}


struct student
{
    char a[10];
	char b[20];
	char c;
	int d;
    float e;
	char f[19];
	struct student * next;
};
int main()
{
	struct student *p1,*p2;
    p1=(struct student *)malloc(len);
	scanf("%s %s %c %d %f %s",p1->a,p1->b,&p1->c,&p1->d,&p1->e,p1->f);
	p1->next=NULL;
	p2=p1;
	while(1)
	{
		p1=(struct student *)malloc(len);
		scanf("%s",p1->a);
		if(strcmp(p1->a,"end")==0)
			break;
        scanf("%s %c %d %f %s",p1->b,&p1->c,&p1->d,&p1->e,p1->f);
		p1->next=p2;
		p2=p1;
	}
	p1=p2;
	while(p1!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p1->a,p1->b,p1->c,p1->d,p1->e,p1->f);
		p1=p1->next;
	}
	return 0;
}


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

    return 0;
}


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


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


struct node
{
	struct node *last;
	char id[15];
	char name[25];
	char sex;
	int age;
	char score[10];
	char addr[15];
	struct node *next;
};
int n=1;

struct node *newnode()
{
	struct node *head=NULL,*New,*This;
	do
	{
		New=(struct node *)malloc(sizeof(struct node));
		scanf("%s",New->id);
		if(n==1)
		{
			head=New;
			New->last=NULL;
			This=head;
		}
		else
		{
			This->next=New;
			New->last=This;
		}
		if(strcmp(New->id,"end")!=0)
		{
			scanf("%s %c %d %s %s",New->name,&New->sex,&New->age,New->score,New->addr);
			This=New;
			n++;
		}
	}while(strcmp(New->id,"end")!=0);
	This->next=NULL;
	return(This);
}
void main()
{
	struct node *p;
	p=newnode();
	do
	{
		printf("%s %s %c %d %s %s\n",p->id,p->name,p->sex,p->age,p->score,p->addr);
		p=p->last;
	}while(p->last!=NULL);
	printf("%s %s %c %d %s %s\n",p->id,p->name,p->sex,p->age,p->score,p->addr);
}


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

int main()
{
	struct Student *head,*p;
	head=creat();
	p=head;
	while(p!=NULL)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}
	return 0;
}


//#define LEN sizeof(struct student)
struct student
	{
		char num[50];
		struct student * next;
	};
int n;
char end[4]="end";

struct student * creat(void)
{
	struct student * p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(sizeof(struct student));//
	gets(p1->num);
	while(strcmp(end,p1->num)!=0)//
	{
		n=n+1;
		if(n==1)
			p2->next=NULL;
		else p1->next=p2;
		p2=p1;
		p1=(struct student *)malloc(sizeof(struct student));
		gets(p1->num);

	}

	return(p2);

}

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

int main()
{
	print(creat());
	return 0;
}


	struct student
	{
		char num[100];
		struct student *next;
	};
	int n;

	struct student *creat(void)
	{
		struct student *head;
		struct student *p1,*p2;
		n=0;
		p1=p2=(struct student*)malloc(LEN);
		gets(p1->num);
		head=NULL;
		while(strcmp(p1->num,"end"))
		{
			n++;
			p1->next=head;
			head=p1;
			p1=(struct student*)malloc(LEN);
gets(p1->num);
		}
		p1->next=NULL;
		return(head);
	}

	void print(struct student *head)
	{
		struct student *p;
		p=head;
		if(head)
			do
			{
				puts(p->num);
				p=p->next;
			}
			while(p);
	}

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


struct student{
	char num[10];
	char name[20];
	char gd;
	int age;
	float sc;
	char adr[10];
	struct student *next;
};

struct student *append()
{
	struct student *head,*p1,*p2=NULL;
	while(1)
	{
	 p1=(struct student*)malloc(sizeof(struct student));
     scanf("%s",p1->num);
     if (p1->num[0]=='e')
	 {
		head=p2;
		break;
      }
	 else
	 {
	   scanf("%s %c %d%f %s",p1->name,&p1->gd,&p1->age,&p1->sc,p1->adr);
       p1->next=p2;
	   p2=p1;
	 }
	}
    return head;
}

void main()
{
	struct student *p;
	p=append();
	for(;p!=NULL;p=p->next)
	{
		printf("%s %s %c %d %g %s\n",p->num,p->name,p->gd,p->age,p->sc,p->adr);
	}
}


struct student
{
	char num[10];
	char name[20];
	char c;
	int age;
	char score[10];
	char addr[20];
	struct student*next;
};

void main()
{
	struct student *p1,*p2,*p,*head;

	p1=(struct student*)malloc(LEN);
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->c,&p1->age,p1->score,p1->addr);
	p1->next=NULL;
	do
	{
		p2=(struct student*)malloc(LEN);
		scanf("%s",p2->num);
		if(strcmp(p2->num,"end")==0)
		{
			head=p1;
			break;
		}
		else
		{
		scanf("%s %c %d%s%s",p2->name,&p2->c,&p2->age,p2->score,p2->addr);
		p2->next=p1;
		p1=p2;
		}
	}while(strcmp(p2->num,"end")!=0);

	p=head;
	do
	{
		if(p->next==NULL)
			break;
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->c,p->age,p->score,p->addr);
		if(p->next!=NULL)
			p=p->next;
	}while(p->next!=NULL);
	printf("%s %s %c %d %s %s\n",p->num,p->name,p->c,p->age,p->score,p->addr);

}


struct student
{
	char number[20];
	char name[20];
	char c;
	int age;
	float score;
	char address[30];
	struct student *next;
};
int n;
  struct student *creat(void)
  {
	  struct student *head;
	  struct student *p1,*p2;
	  int m;
	  n=0;
	  p1=p2=(struct student*)malloc(LEN);
	  head=NULL;
	  scanf("%s",p1->number);
	  for(m=0;;m++)
	  {
	  if(strcmp(p1->number,"end")!=0)
	  {
	    scanf("%s %c %d %f %s",p1->name,&p1->c,&p1->age,&p1->score,p1->address);
		  n=n+1;
		  if(n==1)head=p1;
		  else p2->next=p1;
		  p2=p1;
		  p1=(struct student *)malloc(LEN);
	  }
	  else break;
	  scanf("%s",p1->number);
	  }
	  p2->next=NULL;
	  return(head);
  }
  struct student *del(struct student *head,char *str)
  {
	  struct student *p1,*p2;
	  p1=head;
	  while(strcmp(str,p1->number)!=0&&p1->next!=NULL)
	  {
		  p2=p1;
		  p1=p1->next;
	  }
	  if(strcmp(str,p1->number)==0)
	  {
		  if(p1==head)head=p1->next;
		  else p2->next=p1->next;
		  n=n-1;
	  }
	  return(head);

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

		   while(head!=NULL)
		   {
			   p1=head;
			   while(p1->next!=NULL)
				   p1=p1->next;
			   printf("%s %s %c %d %g %s\n",p1->number,p1->name,p1->c,p1->age,p1->score,p1->address);
			   head=del(head,p1->number);
		   }
  }


struct student
{
    char name[32],sex,address[32],id[10],score[10];
    int age;
    struct student *next;
};
struct student *create()
{
    struct student *head=NULL,*p1,*p2;
    char ch[10];
    p1=p2=(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;
    head=p1;
    p2=p1;
    do
    {
        scanf("%s",ch);
        if(strcmp(ch,"end")==0) break;
     else
      {     p1=(struct student*)malloc(Len);
            strcpy(p1->id,ch);
            scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->address);
            p1->next=NULL;
            p2->next=p1;
            p2=p1;
      }
    }while(1);
         return head;
}
   void print(struct student *head)
   {
       struct student *p1,*p2;
    while(p1)
    {
       p1=head;
       if(p1->next==NULL)
       {
            printf("%s %s %c %d %s %s",p1->id,p1->name,p1->sex,p1->age,p1->score,p1->address);
            break;
       }
        else
        {
            while(p1->next!=NULL)
          {
             p2=p1;
             p1=p1->next;
          }
           printf("%s %s %c %d %s %s\n",p1->id,p1->name,p1->sex,p1->age,p1->score,p1->address);
           p2->next=NULL;
           free(p1);
        }
    }
  }
  int main()
  {
      struct student *head;
      head=create();
      print(head);
  }


main()
{
	struct student
	{
		char num[100];
		char name[100];
		char sex[10];
		char age[10];
		char score[10];
		char address[100];
		struct student *next;
	};
	struct student *head,*p1;
	p1=(struct student*)malloc(sizeof(struct student));
	head=NULL;
	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->address);
     	p1->next=head;
		head=p1;
		p1=(struct student*)malloc(sizeof(struct student));
		scanf("%s",p1->num);
	}
	p1=head;
	while(p1!=NULL)
	{
		printf("%s %s %s %s %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p1=p1->next;
	}
}


main()
{
	int n=0;
	struct b
	{
		char a[60];
	}d,*q[10000];
	while(1)
	{
		gets(d.a);
		if(d.a[0]=='e')
			break;
		q[n]=(struct b *)malloc(sizeof(struct b));
		*q[n]=d;
		n++;
	}
	while(n--)
	{
		puts(q[n]->a);
	}
}


struct num
{int nianling;
float defen;
char q[200],w[100],xingbie,xuehao[200];
struct num *next;
};
struct num *crea()
{long i;
  struct num *head;
  struct num *p1,*p2;
   p1=p2=(struct num *)malloc(LEN);
   head=p1;
   scanf("%s %s %c %d %f %s",&p1->xuehao,&p1->q,&p1->xingbie,&p1->nianling,&p1->defen,&p1->w);

head->next=NULL;
  for(;;)
    {
p1=(struct num *)malloc(LEN);
scanf("%s",&p1->xuehao);if(p1->xuehao[0]!='e')
{scanf("%s %c %d %f %s",&p1->q,&p1->xingbie,&p1->nianling,&p1->defen,&p1->w);

       p1->next=p2;
       p2=p1;}
else  {p1->next=p2,p2=p1;break;}
       }
   return(p1);
}
void main()
{

long nx,m,m0,tx,qx,q,mxh;
struct num *hi,*p,*t;
hi=crea();
t=hi->next;
for(p=t;p!=NULL;p=p->next)
{printf("%s %s %c %d %g %s\n",p->xuehao,p->q,p->xingbie,p->nianling,p->defen,p->w);
}
}


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


struct Student
{
	char no[10];
	char name[20];
	char sex;
	int age;
	char score[7];
	char add[15];
	struct Student *next;
};
int main()
{
	struct Student *p[1000],*head;
	int i;
	for(i=0; ;i++)
	{
		p[i]=(struct Student *)malloc(LEN);
		scanf("%s",p[i]->no);

			if(strcmp(p[i]->no,"end")==0)
			{
				head=p[i-1];//head????
				break;//???end???
			}
			else
			{
			getchar();
				scanf("%s %c %d %s %s",p[i]->name,&p[i]->sex,&p[i]->age,p[i]->score,p[i]->add);
			getchar();
				if(i==0)
				{
					p[i]->next=NULL;//????????????????????
				}
				else
				{
					p[i]->next=p[i-1];//????????????????
				}
			}

	}
	for(head=head;head!=NULL;head=head->next)
	{
		printf("%s %s %c %d %s %s\n",head->no,head->name,head->sex,head->age,head->score,head->add);
	}
	return 0;
}


struct student
{
	char num[10];
    char s1[20];
	char sex;
	int age;
	char mark[20];
	char s2[20];
    struct student*next;

} *p1,*p2;//????????????????????????//

int n;

//????//

struct student * creat(void)
{
	struct student * head;
    n=0;
    p1 = p2 = (struct student * )malloc(LEN);
    scanf("%s", p1->num);

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

		scanf ("%s %c %d %s %s", p1->s1,&p1->sex, &p1->age, p1->mark, p1->s2);//?????????????//
		n=n+1;
		if (n==1)
        {
			head=p1;//?????????//
		}
        else
        {
			p2->next=p1;
		}

        p2=p1;
        p1=(struct student *)malloc(LEN);
        scanf("%s",p1->num);//??p1->num???while?????//

	}
	p2->next=NULL;

	return(head);
}//?????????????//

struct student * turnback(struct student * head)//??????//
{
	struct student * newhead = NULL;

	struct student * anew;//?????????????????//

    do{
		p2 = NULL;
		p1 = head;
    	while(p1->next !=NULL)
		{
			p2=p1;
			p1=p1->next;
		}
		if(newhead==NULL)
		{
			newhead = p1;
		    anew = newhead->next = p2;//??anew????????//
		}

		anew = anew->next =p2;
		p2->next=NULL;

	}while(head->next !=NULL);

	return newhead;//??????????//
}
//??????//
void print(struct student *head)
{
	struct student *p;
	p = head;
	if(p !=NULL)
    	do{
			printf("%s %s %c %d %s %s\n", p->num, p->s1, p->sex, p->age, p->mark, p->s2);
			p = p->next;

		}while(p !=NULL);
}
//???//
main()
{
	struct student *head;
	head = creat();

	head = turnback(head);//?????????????//

	print (head);//??????????/
   return 0;

}


struct stu
{
	char num[15];
	char name[20];
	char sex;
	int  year;
	char score[20];
	char adr[15];
	struct stu *next;
}*p,*q,*head,*newhead,*ne;

struct stu *creat(void)
{
	char a[15];
	head=null;
	scanf("%s",&a);
	while(strlen(a)!=3)
	{
		p=(struct stu *)malloc(l);
		strcpy(p->num,a);
		scanf("%s %c %d %s %s",p->name,&p->sex,&p->year,p->score,p->adr);
		if(head==null)
			q=head=p;
		else
			q=q->next=p;
		scanf("%s",a);
	}
	q->next=null;
	return (head);
}

struct stu * change(struct stu *head)
{
	newhead=null;
	do
	{
		q=null;
		p=head;
		while(p->next!=null)
		{
			q=p;
			p=p->next;
		}
		if(newhead==null)newhead=p,ne=newhead->next=q;
		ne=ne->next=q;
		q->next=null;
	}while(head->next!=null);
	return (newhead);
}

void output(struct stu *newhead)
{
	p=newhead;
	while(p!=null)
	{
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->year,p->score,p->adr);
		p=p->next;
	}
}
int main()
{
	head=creat();
	newhead=change(head);
	output(newhead);
}


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

int i;

struct stu *creat(void)
{
	struct stu *p1,*p2,*head;
	p1=p2=(struct stu *) malloc(sizeof (struct stu));
	scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->adr);
	head=0;
	i=0;
	while(1)
	{
		if(i==0)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct stu *) malloc(LEN);
		scanf("%s",p1->num);
		if(p1->num[0]=='e')
			break;
		scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->adr);
		i++;
	}
	return(head);
}
void main()
{
struct stu *p,*head;
	int j;
	head=creat();
	for(;i>0;i--)
	{
		p=head;
		for(j=0;j<i;j++)
		{
			p=p->next;
		}
		printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->adr);
	}
	printf("%s %s %c %d %s %s\n",head->num,head->name,head->sex,head->age,head->score,head->adr);
}


struct people
{
	char num[20];
	char name[20];
	char sex;
	char age[5];
	char score[10];
	char address[30];
};
struct people child[1000];
void main()
{
	int i;
	for(i=0;;i++)
	{
		scanf("%s",child[i].num);
		if (strcmp(child[i].num,"end")==0)
			break;
		scanf("%s %c%s%s%s",child[i].name,&child[i].sex,child[i].age,child[i].score,child[i].address);
	}
	for(i--;i>=0;i--)
	{
		printf("%s %s %c %s %s %s\n",child[i].num,child[i].name,child[i].sex,child[i].age,child[i].score,child[i].address);
	}
}


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

struct student *Create();
void Insert(struct student *head,struct student *newnode);
void Print(struct student *head);

int main(){
	struct student tmp;
	struct student *head;

	head=Create();
	gets(tmp.stu);
	while(strcmp(tmp.stu,"end")!=0){
		Insert(head,&tmp);
		gets(tmp.stu);
	}
	Print(head);

	return 0;
}

struct student *Create()
{
	struct student *p;

	p=(struct student *)malloc(sizeof(struct student));
	strcpy(p->stu,"0");
	p->next=NULL;

	return p;
}

void Insert(struct student *head,struct student *tmp)
{
	struct student *p;
	struct student *newnode;

	p=head;
	while(p->next!=NULL)
		p=p->next;
	newnode=(struct student *)malloc(sizeof(struct student));
	p->next=newnode;
	strcpy(newnode->stu,tmp->stu);
	newnode->next=NULL;
}

void Print(struct student *head)
{
	if(head->next!=NULL)
		Print(head->next);
	if(strcmp(head->stu,"0")!=0)
		printf("%s\n",head->stu);
}


main()
{
      struct student
      {
             char num[20];
             char name[20];
             char sex;
             int age;
             float score;
             char ad[20];
             struct student *next;
      };

      struct student *head,*p1,*p2;
      int n=0;

      p1=p2=( struct student*) malloc(LEN);
      scanf("%s%s %c%d%f%s",p1->num,p1->name,&p1->sex,&p1->age,&p1->score,&p1->ad);//???????????
      p1->next=NULL;
      head=NULL;
      while  (n!=1)
      {
             p1=(struct student*)malloc(LEN);
             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->ad);
             p1->next=p2;
             p2=p1;
             }
             else
             n=1;
      }

      head=p2;
      p1=head;

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

}


struct sd
{char xh[100];char xm[100];char xb;int nl;double df;char dz[10];struct sd*before;};

struct sd* cre()
{struct sd *p1,*p2=NULL;

while(1){p1=(struct sd*)(malloc(sizeof(struct sd)));

scanf("%s",p1->xh);
if(strcmp(p1->xh,"end")==0)break;
else{  p1->before=p2;p2=p1;
	scanf("%s %c %d %lf %s",p1->xm,&p1->xb,&p1->nl,&p1->df,p1->dz);  }}
return p2;
}
void main()
{struct sd*cre();
	struct sd*p=cre();
	while(1){printf("%s %s %c %d %g %s\n",p->xh,p->xm,p->xb,p->nl,p->df,p->dz);
if(p->before==NULL)break;
else p=p->before; }}


struct student
{
	char stuID[20];
	char name[20];
	char sex;
	int age;
	char score[10];
	char add[20];
};
int main()
{
	int i,j;
	struct student stu[5000];
	scanf("%s %s %c %d %s %s",stu[0].stuID,stu[0].name,&stu[0].sex,&stu[0].age,stu[0].score,stu[0].add);
	i=0;
	if(strlen(stu[i].stuID)>=3)
	{
	while(1)
	{
		i++;
		scanf("%s",stu[i].stuID);
		if(strlen(stu[i].stuID)==3)
			break;
		scanf("%s %c %d %s %s",stu[i].name,&stu[i].sex,&stu[i].age,stu[i].score,stu[i].add);
	}
	//printf("#####3");
	for(j=i-1;j>=0;j--)
	{
		printf("%s %s %c %d %s %s\n",stu[j].stuID,stu[j].name,stu[j].sex,stu[j].age,stu[j].score,stu[j].add);
	}
	}
	return 0;
}


struct student
{
    char data[500];
    struct student *former;
};
int n;
struct student *create()
{
    struct student *tail;
    struct student *p1,*p2;
    n=0;
    p1=p2=(struct student *)malloc(sizeof(struct student));
    gets(p1->data);
    tail=NULL;
    while(strcmp(p1->data,"end")!=0)
    {
        n=n+1;
        if (n==1)
        {
            tail=p1;
            p1->former=NULL;
        }
        else
        {
            tail=p1;
            p1->former=p2;
            p2=p1;
        }
        p1=(struct student *)malloc(sizeof (struct student));
        gets(p1->data);
    }

    return(tail);
}
int main()
{

    struct student *p,*start;
    p=create();
    start=p;
    if (p!=NULL)
    {
        do
        {
            puts(start->data);
            start=start->former;
        }
        while (start!=NULL);
    }
}


int main()
{
	struct student {
		char ID[30];
		char name[30];
		char sex;
		int age;
		float  score;
		char address[20];
	}message[1000];
	int num=0;

	for(;;num++)
	{
		cin>>message[num].ID;
		if (message[num].ID[0]!='e')//??????
		{cin>>message[num].name>>message[num].sex>>message[num].age>>message[num].score>>message[num].address;
		}
		else break;
	}
	for(int i=num-1;i>=0;i--)
		cout<<message[i].ID<<' '<<message[i].name<<' '<<message[i].sex<<' '<<message[i].age<<' '<<message[i].score<<' '<<message[i].address<<endl;
return 0;
}


struct student{
	char xh[20];
	char name[20];
	char sex;
	int age;
	float score;
	char dizhi[30];
	struct student *next;
};
struct student *append(void)
{int n;
 struct student *head,*newnode,*thisnode=NULL;
 for (n=1;;n++)
 {newnode=(struct student*)malloc(sizeof(struct student));
  scanf("%s",&newnode->xh);
  if (newnode->xh[0]=='e')
     {head=thisnode;break;}
  else
     {scanf(" %s %c %d %f %s\n",&newnode->name,&newnode->sex,&newnode->age,&newnode->score,&newnode->dizhi);
      newnode->next=thisnode;
      thisnode=newnode;
     }
 }
 return head;
}
void main()
{struct student *p;
 for ( p=append();p!=NULL;p=p->next)
 {printf("%s %s %c %d %g %s\n",p->xh,p->name,p->sex,p->age,p->score,p->dizhi);

 }
}


struct student
{
	char num[50],ming[100];
	struct student *pro;
};
int n;
struct student *tail;

struct student *creat()
{
	struct student *head;
	struct student *p1,*p2;
    int i;
	i=0;
	p1=p2=(struct student *)malloc(len);
	scanf("%s",p1->num);
	head=0;
	while (strcmp(p1->num,"end"))
	{
		gets(p1->ming);
		i++;
		if (i==1)
		{
			head=p1;
			head->pro=0;
		}
		   else
		   {
			   p1->pro=p2;
		   }
		p2=p1;
		p1=(struct student *)malloc(len);
		scanf("%s",p1->num);
	}
	tail=p2;
	return(tail);
}

main()
{
	struct student *p;
	creat();
	p=tail;
	for (;p!=0;)
	{
		printf("%s%s\n",p->num,p->ming);
		p=p->pro;
	}
}


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

struct stu * turnback(struct stu *head)
{
	struct stu *New,*Newhead=NULL;
	do{
		p2=NULL;
		p1=head;
		while(p1->next!=NULL)
		{p2=p1;
		p1=p1->next;
		}
		if(Newhead==NULL)
		{
			Newhead=p1;
			New=Newhead->next=p2;
		}
		New=New->next=p2;
		p2->next=NULL;
	}while(head->next!=NULL);
	return(Newhead);
}
void output(struct stu *head)
{for(p1=head;p1!=NULL;puts(p1->info),p1=p1->next);
}
void main()
{
	struct stu *head;
	head=creat();
	head=turnback(head);
	output(head);
}


struct link
{
	char s[100];
	struct link *next;
	struct link *last;
} ;
struct link *create()
{
	struct link *last,*head,*p;
	char s[100];
	head=(struct link*)malloc(LEN);
	last=head;
	do
	{
		gets(s);
		if (strlen(s)==3) break;
		p=(struct link*)malloc(LEN);
		strcpy(p->s,s);
		last->next=p;
		p->last=last;
		last=p;
	}
	while (0==0);
	last->next=NULL;
	head=head->next;
	head->last=NULL;
	return head;
}
void nprint(struct link *p)
{
	struct link *last;
	while (p!=NULL)
	{
		last=p;
		p=p->next;
	}
	p=last;
	while (p!=NULL)
	{
		puts(p->s);
		p=p->last;
	}
}
int main()
{
	struct link *p;
	p=create();
	nprint(p);
}


struct student
{
	char inf[50];
	struct student *next;
};
int main()
{
	struct student *head,*p;
	p=(struct student*)malloc(LEN);
	gets(p->inf);
	head=NULL;
	while (p->inf[0]!='e')
	{
		p->next=head;
		head=p;
		p=(struct student*)malloc(LEN);
		gets(p->inf);
	}
	p=head;
	while(true)
	{
	printf("%s",p->inf);
	p=p->next;
	if (p==NULL)  break;
	else printf("\n");
	}
	return 0;
}


struct student
{
    char id[50];
    char name[50];
    char sex;
    int age;
    double grade;
    char a[20];
    struct student *next;
};

void main()
{
    struct student *h,*p,*q;
    int n=0;
    p=(struct student*)malloc(LEN);
    scanf("%s",p->id);
    while(p->id[0]!='e')
    {
         scanf("%s %c%d%lf%s",p->name,&p->sex,&p->age,&p->grade,p->a);
         n=n+1;
         if(n==1) p->next=NULL;
         else p->next=h;
         h=p;
         p=(struct student *)malloc(LEN);
         scanf("%s",p->id);
    }
    p=h;
    do
    {
        printf("%s %s %c %d %g %s\n",p->id,p->name,p->sex,p->age,p->grade,p->a);
        p=p->next;
    }
    while(p!=NULL);
}


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

int isequal(char *a);

int main()
{
	struct student *head,*p1,*p2;
	p1=(struct student*)malloc(sizeof(struct student));
	gets(p1->str);
	p1->next=NULL;
	if(isequal(p1->str))
	{
		free(p1);
		head=NULL;
	}
	else
	{
		head=p1;
		p2=p1;
		do
		{
			p1=(struct student*)malloc(sizeof (struct student));
			gets(p1->str);
			p1->next=NULL;
			if (isequal(p1->str))
			{
				free(p1);
				break;
			}
			else
			{
				head=p1;
				p1->next=p2;
				p2=p1;

			}
		}
		while(1);
	}
	struct student *p;
	p=head;
	while(p)
	{
		printf("%s",p->str);
		p=p->next;
		if (p != NULL)
			printf("\n");
	}
	return 0;
}

int isequal(char *a)
{
	if (a[0] == 'e' && a[1] == 'n' && a[2] == 'd' && a[3] == 0)
		return 1;
	else
		return 0;
}


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

	}
	while(p1->next!=NULL);
}


void main()
{
	struct stu
	{
		char num[21];
		char name[31];
		char sex[2];
		int age;
		float score;
		char address[31];
		struct stu *next;
		struct stu *pre;
	};
	struct stu *head,*p1,*p2,*tail;
	head=(struct stu *)malloc(sizeof(struct stu));
	p1=head;
	p2=p1;
	p1->pre=NULL;
	scanf("%s",&p1->num);
	if (strcmp(p1->num,"end"))
	{
	while(strcmp(p1->num,"end"))
	{
		scanf("%s",&p1->name);
		scanf("%s",&p1->sex);
		scanf("%d",&p1->age);
		scanf("%f",&p1->score);
		scanf("%s",&p1->address);
		p2=(struct stu*)malloc(sizeof(struct stu));
		p1->next=p2;
		p2->pre=p1;
		p1=p2;
		scanf("%s",&p1->num);
	}
	tail=p1->pre;
	free(p1);
	tail->next=NULL;
	p1=tail;
	p2=p1;
	while(p1!=NULL)
	{
		printf("%s %s %s %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p2=p1->pre;
		p1=p2;
	}
	p1=head;
	p2=p1;
	while(p1!=NULL)
	{
		p2=p1->next;
		free(p1);
		p1=p2;
	}
    }
	else
		free(head);
}


struct link
{
	char a[10][100];
	struct link *next;
};
struct link *now,*past;
int i,n=1;
void build()
{
	while (1)
	{
	now=(struct link*)malloc(sizeof(struct link));
	scanf("%s",now->a[0]);
	if (strcmp(now->a[0],"end")==0) return;
	for (i=1;i<6;i++)
		scanf("%s",now->a[i]);
	if (n==1)
	{
		now->next=NULL;
	} else now->next=past;
	past=now;
	n++;
	}
}
void main()
{
	build();
	now=past;
	while (now!=NULL)
	{
		printf("%s",now->a[0]);
		for (i=1;i<6;i++)
			printf(" %s",now->a[i]);
		printf("\n");
		now=now->next;
	}
}


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


struct stu{char id[20];char name[20];char sex;int age;char score[20];char address[20];struct stu *next;struct stu *former;};
struct stu *cr(void)
{struct stu *head,*end;
 struct stu *p1,*p2;
 int i=0;
 p1=p2=(struct stu*)malloc(LEN);
 scanf("%s",&p1->id);
 if(strcmp(p1->id,"end")!=0)
{	 scanf("%s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);//printf("%s",p1->name);
	 head=NULL;
    	 while(1)
	{
		 i++;
		 if(i==1)  {head=p1;p1->former=NULL;}
		 else {p2->next=p1;p1->former=p2;}
		  p2=p1; p1=(struct stu*)malloc(LEN);
		 scanf("%s",&p1->id);
		  if(strcmp(p1->id,"end")==0)break;
			// printf("%s",p1->id);
		  scanf("%s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address);
	}

		  p2->next=NULL;
		  end=p2;
		  return (end);

 }
 else return(NULL);
}

void print(struct stu *end)
{

	struct stu *q=end;  // printf("%s",end->id);

	while(q!=NULL&&end!=NULL)
	{
		printf("%s %s %c %d %s %s\n",q->id,q->name,q->sex,q->age,q->score,q->address);
		q=q->former;//printf("%s",q->id);
	}
//printf("%s",q->id);
}

int main()
{struct stu *p;
  p=cr();

print(p);
return 0;
}


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

struct student *creat(void)
{
 struct student *head;
 struct student *p1,*p2=NULL;
 p1=(struct student*)malloc(LEN);
 scanf("%s",p1->num);
 if (strcmp(p1->num,"end")!=0)
 {
 scanf("%s%s%d%s%s",p1->name,p1->sex,&p1->age,p1->score,p1->addr);
 p1->next=NULL;
 p2=p1;

 while (1)
 {
  p1=(struct student*)malloc(LEN);
  scanf("%s",p1->num);
  if (strcmp(p1->num,"end")==0)
   break;
  else
  {
   scanf("%s%s%d%s%s",p1->name,p1->sex,&p1->age,p1->score,p1->addr);
   p1->next=p2;
   p2=p1;
  }
 }
 }
 head=p2;
 return(head);
}

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

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


struct Student
{
	char id[10];
	char name[100];
	char sex;
	char year[10];
	char mark[10];
	char ad[20];
}stu[1000];
int main()
{
	int i,k=0;
	for(i=0;;i++)
	{
		scanf("%s ",stu[i].id);
		if(stu[i].id[0]=='e')
			{break;}
		else
		{scanf("%s %c %s %s %s\n",stu[i].name,&stu[i].sex,stu[i].year,stu[i].mark,stu[i].ad);
		k++;}
	}
	for(i=k-1;i>=0;i--)
		printf("%s %s %c %s %s %s\n",stu[i].id,stu[i].name,stu[i].sex,stu[i].year,stu[i].mark,stu[i].ad);
}


struct Student
{
char id[9];
char name[20];
char gen;
int age;
char grade[10];
char add[20];
struct Student *next;
};
void main()
{
struct Student *head,*p2,*p1,*newstu,*newhead;
int i,n=1;
char e[]={"end"};
p1=p2=head=(struct Student*)malloc(sizeof(struct Student));
scanf("%s %s %c %d %s %s",
	  &p1->id,&p1->name,&p1->gen,&p1->age,&p1->grade,&p1->add);
while(1)
{
p1=(struct Student*)malloc(sizeof(struct Student));
scanf("%s",&p1->id);
if(strcmp(p1->id,e)==0) {p2->next=NULL;break;}
else
{
scanf(" %s %c %d %s %s",
	  &p1->name,&p1->gen,&p1->age,&p1->grade,&p1->add);
p2->next=p1;
p2=p1;
n++;
}
}
for(i=0;i<n;i++)
{
 p2=p1=head;
 while(p1->next!=NULL)
 {
 p2=p1;
 p1=p1->next;
 }
 if(i==0)
	 newhead=newstu=p1;
 else
	 newstu=newstu->next=p1;
 p2->next=NULL;
}
p1=newhead;
for(i=0;i<n;i++)
{
printf("%s %s %c %d %s %s\n",p1->id,p1->name,p1->gen,p1->age,p1->grade,p1->add);
    p1=p1->next;
}
}


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


int i=0;

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

struct shuju *create()
{

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

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

void print(struct shuju* head)
{
    int j;
    struct shuju* p,*pre;

    for (j=0;j<i;j++)
    {
    	p=head;
    pre=p;
    	while (p->next!=NULL)
    {
        pre=p;
        p=p->next;
    }
    printf("%s %s %c %d %s %s\n",p->xh,p->xm,p->sex,p->age,p->fen,p->dorm);

    pre->next=NULL;}
}

void main()
{

    struct shuju *p;
    p=create();

    print(p);
}


	struct Student
	{
		char ID[10];
		char name[20];
		char sex;
		int age;
		float score[20];
		char add[20];
		struct Student*next;
	};
	int main()
	{
		struct Student a[1000],*head,*p;
	int i,j;
	for(i=0;;i++)
	{
		scanf("%s %s %c %d %s %s",a[i].ID,a[i].name,&a[i].sex,&a[i].age,a[i].score,a[i].add);
         if(a[i].ID[2]=='d')
		 {
			 printf("\n");
			 break;
		 }
	}
	for(j=i-1;j>=0;j--)
	{
		head=&a[i-1];
		a[j].next=&a[j-1];
		a[0].next=NULL;
		p=head;
	}
	do
	{
		printf("%s %s %c %d %s %s\n",p->ID,p->name,p->sex,p->age,p->score,p->add);
		p=p->next;
	}while(p!=NULL);
	return 0;
	}


int main()
{
	int i,n;
	char a[MAX][MAX];
	for(i=0; ;i++)
	{
		gets(a[i]);
		if(strcmp(a[i],"end")==0) break;
	}
    for(n=i-1;n>=0;n--)
	{
		puts(a[n]);
	}
	return 0;
}


struct Student
{
	struct Student *prev;
	char number[30];
	char name[30];
	char gender;
	int age;
	double score;
	char address[30];
};

int main()
{
	struct Student a,*p;
	scanf("%s%s %c%d%lf%s",a.number,a.name,&a.gender,&a.age,&a.score,a.address);
	p=(struct Student *)malloc(LEN);
	*p=a;
	(*p).prev=NULL;
	for(;1;)
	{
		scanf("%s",a.number);
		if(a.number[0]=='e')
			break;
		scanf("%s %c%d%lf%s",a.name,&a.gender,&a.age,&a.score,a.address);
		a.prev=p;
		p=(struct Student *)malloc(LEN);
		*p=a;
	}
	printf("%s %s %c %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);
	for(;(*p).prev!=NULL;)
	{
		p=p->prev;
		printf("%s %s %c %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);
	}
	return 0;
}


struct student
{
	char num[10];
	char name[20];
	char gender[2];
	int year;
	char score[10];
	char ad[20];
	struct student *next;
};

int main()
{
	int i,count=0;
	struct student *head,*p1,*p2,*p,*q,*temp;
	for(i=1;i<=10000;i++){
		p1=(struct student *)malloc(sizeof(struct student));
		scanf("%s",p1->num);
		if(strcmp(p1->num,"end")==0){
			head=temp;
			break;
		}
		else if(i==1){
			p1->next=NULL;
			p2=p1;
			temp=p1;
		}
		else{
			p1->next=p2;
			p2=p1;
			temp=p1;
		}
		scanf("%s",p1->name);
		scanf("%s",p1->gender);
		scanf("%d",&p1->year);
		scanf("%s",p1->score);
		scanf("%s",p1->ad);
		count=count+1;
	}
	for(i=1;i<=count;i++){
		if(i==1){
			p=head;
		}
		printf("%s %s %s %d %s %s\n",p->num,p->name,p->gender,p->year,p->score,p->ad);
		p=p->next;
		if(p==NULL){
			break;
		}
	}

	return 0;
}


struct stu
{
	char num[15];
	char name[20];
	char gender;
	int age;
	char score[10];
	char add[20];
	struct stu *next;
};
int n;
struct stu *creat(void)
{
	struct stu *head,*p,*q;
	p=q=(struct stu*)malloc(LEN);
	scanf ("%s%s %c %d %s%s",(*p).num,(*p).name,&(*p).gender,&(*p).age,(*p).score,(*p).add);
	for (n=0;(*p).gender=='f'||(*p).gender=='m';n++)
	{
         if (n==0) (*p).next=NULL;
		 else (*p).next=q;
		 q=p;
		 p=(struct stu*)malloc(LEN);
		 scanf("%s%s %c %d %s%s",(*p).num,(*p).name,&(*p).gender,&(*p).age,(*p).score,(*p).add);
	}
	head=q;
	return(head);
}
void print(struct stu *head)
{
	struct stu *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).gender,(*p).age,(*p).score,(*p).add);
}
void main()
{
	struct stu *head;
	head=creat();
	print(head);
}


/*
 * justexp.cpp
 *
 *  Created on: 2011-11-18
 *      Author: dell
 */
int main()
{
	struct data
	{
		char num[200];
		char name[200];
		char gender;
		int age;
		float score;
		char add[200];
	}student[2000];
	int count=0;
	while(true)
	{
		memset(student[count].num,'\0',sizeof(student[count].num));
		cin>>student[count].num;
		if(strcmp(student[count].num,"end")==0)
			break;
		cin>>student[count].name>>student[count].gender>>student[count].age>>student[count].score>>student[count].add;
		count++;
	}
	while(count--)
	{
		cout<<student[count].num<<" "<<student[count].name<<" "<<student[count].gender<<" "<<student[count].age<<" "<<student[count].score<<" "<<student[count].add<<endl;
	}
	return 0;
}


struct Student
{
	char inf[81];
	struct Student *front,*next;
};

int n;
struct Student *creat()
{
	struct Student *head,*p1,*p2,*temp;
	n=0;
	p1=p2=(struct Student *)malloc(LEN);
	gets(p1->inf);
	head=NULL;
	while(strcmp(p1->inf,"end")!=0)
	{
		n++;
		if(n==1)
		{
			head=p1;p1->front=NULL;
		}
		else
		{
			p2->next=p1;
			p1->front=temp;
		}
		p2=p1;
		temp=p1;
		p1=(struct Student *)malloc(LEN);
		gets(p1->inf);
	}
	p2->next=NULL;
	return(p2);
}

int main()
{
	struct Student *pt;
	pt=creat();
	if(pt!=NULL)
	{
		do
		{
			puts(pt->inf);
			pt=pt->front;
		}
		while(pt!=NULL);
	}
	return 0;
}


	struct student
	{
		char number[10];
		char name[100];
		char sex;
		int age;
		char score[20];
		char add[20];
		struct student *pre;
	};
int n;

	struct student *creat(void)
	{
		struct student *tail;
		struct student *p1,*p2;
		n=0;
		p1=p2=(struct student *)malloc(sizeof(struct student));
		scanf("%s %s %c %d %s %s",p1->number,p1->name,&p1->sex,&p1->age,p1->score,p1->add);
		p1->pre=NULL;
		while(1)
		{
			n++;
			tail=p1;
			p1=(struct student *)malloc(sizeof(struct student));
			scanf("%s",p1->number);
			if(strcmp(p1->number,"end")==0)
				break;
			scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add);
			p1->pre=p2;
			p2=p1;
		}
		return(tail);
	}

    void print(struct student *tail)
	{
		struct student *p;
		p=tail;
			do
			{
			  printf("%s %s %c %d %s %s\n",p->number,p->name,p->sex,p->age,p->score,p->add);
			  p=p->pre;
			}while(p!=NULL);
	}

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


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

int main ()
{
  // freopen ( "1.in" , "r" , stdin );
  // freopen ( "1.out" , "w" , stdout );

   char a[100];
   struct student *p , *p1;
   p = p1 = ( struct student * ) malloc ( sizeof ( struct student ) );
   p1->last = NULL;
   gets ( p1->a );
   for ( ; ; )
    {
     gets ( a );
     if ( strcmp ( a , "end" ) == 0 ) break;
     p = ( struct student * ) malloc ( sizeof ( struct student ) );
     strcpy ( p->a , a );
     p->last = p1;
     p1 = p;
    }
   for ( ; ; )
    {
     printf ( "%s" , p->a );
     p = p->last;
     if ( p == NULL ) break;
      else printf ( "\n" );
    }
   return 0;
}


struct stu
{
	char info[1000];
	struct stu * next;
};
struct stu * head;
struct stu * create()
{

	char str1[]="end";
	struct stu *p1,*p2,*p;
	p1=(struct stu*)malloc(Len);
	gets(p1->info);
	p1->next=NULL;
	if(strcmp(p1->info,str1)==0)
	{
		free(p1);
		head=NULL;
		return head;
	}
	else
	{
		head=p1;
		p2=p1;
		do{
			p1=(struct stu*)malloc(Len);
	        gets(p1->info);
	        p=head;

			if(strcmp(p1->info,str1)==0)
			{
				free(p1);
				break;
			}
			else
			{

				p1->next=p2;
				head=p1;
				p2=p1;

			}
		}while(1);
			return head;
	}
}

void print(struct stu * head)
{
	struct stu * p;
	p=head;
	if(head!=NULL)
		do
		{
			puts(p->info);

			p=p->next;
		}while(p!=NULL);
}
void main()
{

	create();

	print(head);
}


struct stu
{
	char xuehao[20];
	char name[20];
	char sex[10];
	int old;
	float score;
	char where[20];
	struct stu *next;
};
void main()
{
	struct stu *head,*p0,*p;
	int i;
	char a[4]="end\0";
	head=NULL;
	for(i=0;;i++)
	{
		p0=(struct stu*)malloc(LEN);
		scanf("%s",p0->xuehao);
		if(strcmp(p0->xuehao,a)==0)
			break;
		scanf("%s%s%d%f%s",p0->name,p0->sex,&p0->old,&p0->score,p0->where);
		if(head==NULL)
		{
			head=p0;
			p0->next=NULL;
			p=p0;
		}
		else
		{
			head=p0;
			p0->next=p;
			p=p0;
		}
	}
	for(p=head;p!=NULL;p=p->next)
	{
		printf("%s %s %s %d %g %s\n",p->xuehao,p->name,p->sex,p->old,p->score,p->where);
	}
}


//#include <memory.h>
struct information
{char info[50];
 struct information*next;
};

struct information* creat()
{struct information *head,*p1,*p2;
 p1=p2=(struct information*)malloc(len);
 p1->next=NULL;
 gets(p1->info);
 while(strcmp(p1->info,"end")!=0)
	{p2=p1;
	 p1=(struct information*)malloc(len);
     gets(p1->info);
	 p1->next=p2;
	 }
 return p2;
}

void print(struct information*head)
{
 while(head!=NULL)
	{printf("%s\n",head->info);
     head=head->next;
	}
}

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


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


void main()
{
	struct student
	{
		char info[1000];
		struct student *pre,*next;
	} *head,*tail,*p;
	int l;
	l=sizeof(struct student);
	head=(struct student*)malloc(l);
	p=head;
	p->pre=NULL;
	p->next=NULL;
	for (;;)
	{
		gets(p->info);
		if (strcmp(p->info,"end")==0) {tail=p;break;}
		p->next=(struct student*)malloc(l);
		(p->next)->pre=p;
		(p->next)->next=NULL;
		p=p->next;
	}
	p=tail;
	for (;;)
	{
		if (!(p->pre)) {free(p);break;}
		puts((p->pre)->info);
		p=p->pre;
		free(p->next);
	}
}


struct student
{
	char number[40];
	char name[50];
	char sex;
	int age;
	float score;
	char address[50];
	struct student *next;
};
int n;
struct student *creat(void)
{
	struct student *head,*p1,*p2;
	p1=p2=(struct student*)malloc(Len);
	head=NULL;
	scanf("%s%s %c%d%f%s",p1->number,p1->name,&(p1->sex),&(p1->age),&(p1->score),p1->address);
	n=0;
	while(1){
		n++;
		if(n==1){
			head=p1;
		}else{
			p2->next=p1;
		}
		p2=p1;
		p1=(struct student*)malloc(Len);
		scanf("%s",p1->number);
		if(*p1->number=='e'){
			break;
		}
		scanf("%s %c%d%f%s",p1->name,&(p1->sex),&(p1->age),&(p1->score),p1->address);
	}
	p2->next=NULL;
	return(head);
}
struct student *reverse(struct student *head)
{
	struct student *p1,*p2,*p3;
	p1=head;
	p2=p1;
	p3=p1;
	do
	{
		if(p3==head){
			p3=p2->next;
			p2=p3;
			p1->next=NULL;
		}else{
			p3=p2->next;
			p2->next=p1;
			p1=p2;
			p2=p3;
		}
	}while(p3!=NULL);
	head=p1;
	return (head);
}
int main()
{
	struct student *head;
	head=creat();
	head=reverse(head);
	struct student *p1;
	p1=head;
	while(p1!=NULL){
		printf("%s %s %c %d %g %s\n",p1->number,p1->name,p1->sex,p1->age,p1->score,p1->address);
		p1=p1->next;
	}
	return 0;
}


//#include<stdlib.h>//
struct student
{
        struct student *bef;
        char n[10];
        char s[20];
        char sex;
        int age;
        char score[10];
        char address[20];
        struct student *next;
};
int n;
struct student *creat(void)
{

        struct student *p1,*p2;
        n=0;
        p1=p2=(struct student*)malloc(LEN);

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

                while(p1->n[0]!='e')
                {
                        n=n+1;
                        if(n==1)
                        {

                             p1->bef=NULL;
                        }
                        else
                        {
                                p2->next=p1;
                                p1->bef=p2;
                        }
                        p2=p1;
                        p1=(struct student*)malloc(LEN);

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

                }
                p2->next=NULL;

		return(p2);
}

        int main()
        {
                struct student *p;
                p=creat();
                do
                {
                        printf("%s %s %c %d %s %s\n",p->n,p->s,p->sex,p->age,p->score,p->address);
                        p=p->bef;
                }while(p!=NULL);
        return 0;
        }


 typedef struct linknode
 {
       char inf[500];
	   struct linknode *next,*prev;
 } snode,*ptr;

 main ()
 {
     int i,a1,a2,j,min,k;
	 ptr head,p1,p2,p3;

	 k=0;
     for (i=1;i<=5;i)
	 {
         p1=(ptr)malloc(sizeof(snode));
		 if (k==0) {head=p1; p2=p1;}
		 else {(*p2).next =p1; (*p1).prev=p2;}

	     gets((*p1).inf);
		 if ((*p1).inf[0]!='e')
		 {
			 p2=p1; k++;
		 }
		 else
		 {
		     p1=p2; i=6;
		 }
	 }

	 for (i=1;i<=k;i++)
	 {
	     printf ("%s\n",(*p1).inf  );
		 if (i!=k) p1=(*p1).prev ;

	 }

 }


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

struct list *creat()
{
	struct list *p1=NULL,*p2=NULL,*head;
	int n=0;
	do{
        p2=p1;
		p1=(struct list*)malloc(sizeof(struct list));
	    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;
}

int main()
{
	struct list *p;
	p=creat();
	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;
	}
	return 0;
}


void main()
{
    struct fy
	{
		char xh[100];
		char xm[100];
		char xb;
		int nl;
		float df;
		char dz[100];
		struct fy *pre;
	};
	struct fy *p,*node;
	int n=1;
	for(;;)
	{
	node= (struct fy *)malloc(sizeof(struct fy));
	if(n==1) node->pre=NULL;
	else node->pre=p;
	scanf("%s",node->xh);
	if(strcmp(node->xh,"end")==0) break;
	scanf("%s %c %d %f %s",node->xm,&node->xb,&node->nl,&node->df,node->dz);
	p=node;
	n++;
	}
	for(;node->pre!=NULL;)
	{
		node=node->pre;
		printf("%s %s %c %d %g %s\n",node->xh,node->xm,node->xb,node->nl,node->df,node->dz);
	}

}


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


struct student
{
	char num[15];
	char name[30];
	char sex[2];
	short age;
	float score;
	char address[30];
	struct student *former;
};
void main()
{
    struct student *p1,*p2;
    p1=p2=(struct student *)malloc(LEN);
    scanf("%s%s%s%d%f%s",p1->num,p1->name,p1->sex,&p1->age,&p1->score,p1->address);
    p1->former=NULL;
    while(1)
    {
    	p1=(struct student *)malloc(LEN);
    	scanf("%s",p1->num);
    	if (strcmp(p1->num,"end")==0) break;
    	scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->address);
    	p1->former=p2;
    	p2=p1;
    }
    while (p2!=NULL)
    {
    	printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->address);
    	p2=p2->former;
    }
}


typedef struct Node{
	char content[150];//??????????????????????????????)
	struct Node *next;//??????
	struct Node *front;
}node,*ptr;
main()
{
	char temp[150],std[4] = "end";//std???????
	ptr head = NULL,p,q;//head???
	while(1){
		gets(temp);
		if(strcmp(temp,std) != 0){
			p = (ptr)malloc(sizeof(node));
			strcpy(p->content,temp);
			p->next = NULL;
			p->front = NULL;
			if(head == NULL)
				head = p;
			else{
				q->next = p;
				p->front = q;
			}
			q = p;
		}
		else
			break;
	}
	while(p != NULL){
		printf("%s\n",p->content);
		p = p->front;
	}
}


int main()
{
	int m,n,i,s;
	char a[1000][100];
	for(i=1;;i++)
	{
		gets(a[i]);
		if(strcmp(a[i],"end")==0)
			break;
	}
	for(s=i-1;s>0;s--)
		printf("%s\n",a[s]);
	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;
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);
}


struct student
{
	char xuehao[10];
	char xingming[20];
	char xingbie;
	int nianling;
	float chengji;
	char dizhi[20];
	struct student *next;
};
struct student *creat()
{
	int n=0;
	struct student *head,*p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	while(1)
	{
		scanf("%s",p1->xuehao);
		if(p1->xuehao[0]=='e')
		{head=p2;
		break;}
		scanf("%s %c %d %f %s",p1->xingming,&p1->xingbie,&p1->nianling,&p1->chengji,p1->dizhi);
		if(n==0) p1->next=NULL;
		else p1->next=p2;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		n++;
	}
	return head;
}
int main()
{
	struct student *p;
	p=creat();
	while(p!=NULL)
	{
		printf("%s %s %c %d %g %s\n",p->xuehao,p->xingming,p->xingbie,p->nianling,p->chengji,p->dizhi);
		p=p->next;
	}
	return 0;
}


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;
	 if(p==last)
		 printf("%s\n", p->str);
	for( p=last;p=p->pre;printf("%s\n", p->str));

}


//#define NULL 0
struct student
{
	char num[20];
	char name[20];
	char sex;
	int age;
	char score[10];
	char adress[20];
//	struct student *next;
	struct student *before;
};

struct student *creat(void)
{
	struct student *head,*p1,*p2;
	int n;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
//	scanf("%s %s %c %d %d %s",p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->adress);
    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->adress);
		n++;
		if(n==1)
		{
//			head=p1;
			p1->before=NULL;
		}
		else
		{
			p1->before=p2;
			head=p1;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
        scanf("%s",p1->num);
/*		if(strcmp(p1->num,"end")==0)
			break;
		else
			scanf(" %s %c %d %d %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->adress);*/
	}
//	head=p2;
	return(head);
}

void main()
{
	struct student *head,*q1;
	head=creat();
	q1=head;
	if(head!=NULL)
	{
		while(q1!=NULL)
		{
	    printf("%s %s %c %d %s %s\n",q1->num,q1->name,q1->sex,q1->age,q1->score,q1->adress);
	    q1=q1->before;
		}
   //     printf("%s %s %c %d %d %s\n",q1->num,q1->name,q1->sex,q1->age,q1->score,q1->adress);
	}

}