int main(){
	int n,i,j;
	cin>>n;
	struct student{
		int number;
		int maths;
		int chinese;
		int sum;
	};
	struct student stu[n],t;
	for(i=0;i<n;i++)                             //???????
		{cin>>stu[i].number>>stu[i].chinese>>stu[i].maths;
		stu[i].sum=stu[i].chinese+stu[i].maths;
		}
	for(i=0;i<3;i++)                           //?????
		for(j=n-2;j>=i;j--)
			if(stu[j].sum<stu[j+1].sum)
				{t=stu[j];
	            stu[j]=stu[j+1];
	            stu[j+1]=t;
				}
	if(n>=3)
	for(i=0;i<3;i++)                              //???3?
		cout<<stu[i].number<<' '<<stu[i].sum<<endl;
	else
	for(i=0;i<n;i++)
		cout<<stu[i].number<<' '<<stu[i].sum<<endl;
	return 0;
}


typedef struct st
{
      int a,b;
} stu ;
stu s[100000];
int comp(const void *a,const void *b)
{
    return ((stu*)b)->b-((stu*)a)->b;
}
int main()
{
    int i,n,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d%d%d",&s[i].a,&a,&b);
                    s[i].b=a+b;
    }
    qsort(s,n,sizeof(stu),comp);
    printf("%d %d\n%d %d\n%d %d",s[0].a,s[0].b,s[1].a,s[1].b,s[2].a,s[2].b);
    //getch();
    return 0;
}


struct stu
{
	long int num;
	int chi;
	int mat;
	int tot;
};
int main()
{
	struct stu a[100050];
	int n,k,i,j,temp2,max;
	long int temp1;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%ld%d%d",&a[i].num,&a[i].chi,&a[i].mat);
		a[i].tot=a[i].chi+a[i].mat;
	}
	for (j=1;j<=3;j++)
	{
	max=0;
	a[0].tot=0;
	for (i=1;i<=n;i++)
		if (a[max].tot<a[i].tot) max=i;
	printf("%ld %d\n",a[max].num,a[max].tot);
	a[max].tot=0;
	}
	scanf("\n");
	return(0);
}


int main()
{
struct student{
int num;
int yw;
int sx;
int all;
}student[4]={0,0,0,0};
struct student temp={0,0,0,0};
int i, l,n;
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d%d%d",&student[3].num,&student[3].yw,&student[3].sx);
student[3].all=student[3].yw+student[3].sx;

if(student[2].all<student[3].all)
{
temp=student[2];
student[2]=student[3];
student[3]=temp;
}
if(student[1].all<student[2].all)
{
temp=student[1];
student[1]=student[2];
student[2]=temp;
}
if(student[0].all<student[1].all)
{
temp=student[0];
student[0]=student[1];
student[1]=temp;
}
}
for(l=0;l<3;l++)
{
printf("%d %d\n",student[l].num,student[l].all);
}
}


int main()
{
	struct student
	{
		char NUM[100000];
		int Ma;
		int Ch;
	}stu;
    int n,i,x,max1,max2,max3,m1,m2,m3;
	max1=max2=max3=0;
	m1=m2=m3=0;

	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
        scanf("%s %d %d",stu.NUM,&(stu.Ma),&(stu.Ch));
		x=stu.Ma+stu.Ch;
	    if(x>max1)
		{
		max3=max2;
		max2=max1;
		max1=x;
		m3=m2;
		m2=m1;
		m1=i;
		}
    else if(x==max1)
	{
		max3=max2;
		max2=max1;
		max1=max1;
		m3=m2;
		m2=i;
	}
	else if(x<max1 && x>max2)
	{
		max3=max2;
		max2=x;
		m3=m2;
	}

	else if(x==max2)
	{
		max3=max2;
		m3=i;
	}
	else if(x<max2 && x>max3)
	{
		max3=x;
		m3=i;
	}
	}

	printf("%d %d\n",m1,max1);
	printf("%d %d\n",m2,max2);
	printf("%d %d\n",m3,max3);
	return 0;
}


/*
 * score.cpp
 *
 *  Created on: 2010-12-24
 *      Author: ???
 *      function: ????????
 */
int main()
{
	int stuNum,i;
	cin>>stuNum;
	struct student{
		int id,math,chinese,total;
	};//??????student
	struct student stu[stuNum],first,second,third;
	for(i=0;i<stuNum;i++){//???????????????
		cin>>stu[i].id>>stu[i].chinese>>stu[i].math;
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	//????????????
	first=second=third=stu[0];
	for(i=1;i<stuNum;i++)
		if(stu[i].total>first.total) first=stu[i];
	cout<<first.id<<' '<<first.total<<endl;
	for(i=1;i<stuNum;i++)
		if(stu[i].total>second.total&&stu[i].id!=first.id) second=stu[i];
	cout<<second.id<<' '<<second.total<<endl;
	for(i=1;i<stuNum;i++)
		if(stu[i].total>third.total&&stu[i].id!=first.id&&stu[i].id!=second.id) third=stu[i];
	cout<<third.id<<' '<<third.total<<endl;
	return 0;
}


struct student
{
	int num;
	int chi;
	int mat;
	int tol;
	struct student *next;
};

void main()
{

	struct student *p1,*p2,*head;
	struct student *p,*a,*b,*c;
	struct student temp;

	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d%d%d",&p1->num,&p1->chi,&p1->mat);
		p1->tol=p1->chi+p1->mat;
		if(i==0)
			head=p2=p1;
		else
			p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;

	p=head;
	temp.tol=0;
	a=b=c=&temp;
	while(p!=NULL)
	{
		if(p->tol>a->tol)
		{
			c=b;
			b=a;
			a=p;
		}
		else if(p->tol>b->tol)
		{
			c=b;
			b=p;
		}
		else if(p->tol>c->tol)
			c=p;
		p=p->next;
	}

	printf("%d %d\n",a->num,a->tol);
	printf("%d %d\n",b->num,b->tol);
	printf("%d %d\n",c->num,c->tol);
}


struct Student
{
	long Id;
	int yuwen;
	int shuxue;
};

int main()
{
	int i,j;
	long n;
	struct Student student[NUM];
	struct Student temp;
	scanf("%ld\n",&n);
	for(i=0;i<n;i++)
		scanf("%ld%d%d",&student[i].Id,&student[i].yuwen,&student[i].shuxue);
	for(i=0;i<3;i++)
	{
		for(j=0;j<(3-i-1);j++)
		{
			if((student[j+1].yuwen+student[j+1].shuxue)>(student[j].yuwen+student[j].shuxue))
			{
				temp=student[j+1];
				student[j+1]=student[j];
				student[j]=temp;
			}
		}
	}
	for(i=3;i<n;i++)
	{
        if((student[i].yuwen+student[i].shuxue)>(student[2].yuwen+student[2].shuxue))
			{
				student[2]=student[i];
			}
		if((student[i].yuwen+student[i].shuxue)>(student[1].yuwen+student[1].shuxue))
			{
				temp=student[1];
				student[1]=student[i];
				student[2]=temp;
			}
		if((student[i].yuwen+student[i].shuxue)>(student[0].yuwen+student[0].shuxue))
			{
				temp=student[0];
				student[0]=student[i];
				student[1]=temp;
			}
	}
	for(i=0;i<3;i++)
	{
		printf("%ld %d\n",student[i].Id,(student[i].shuxue+student[i].yuwen));
	}
	return 0;
}


struct student
	{
	int number;
	int yuwen;
	int shuxue;
    int sum;
	struct student *next;
	};
int n;
struct student*creat(void)
{struct student*head,*p1,*p2;
 scanf("%d",&n);
 p1=p2=(struct student*)malloc(LEN);
 scanf("%d%d%d",&p1->number,&p1->yuwen,&p1->shuxue);
 p1->sum=p1->yuwen+p1->shuxue;
 head=p1;
 int i;
 for(i=1;i<n;i++)
	{
	p1=(struct student*)malloc(LEN);
	p2->next=p1;
	p2=p1;
	scanf("%d%d%d",&p1->number,&p1->yuwen,&p1->shuxue);
    p1->sum=p1->yuwen+p1->shuxue;
	}
 p2->next=null;
 return head;
}
void compare(struct student*head)
{int max,i;
 struct student*p;
 for(i=1;i<=3;i++)
	{max=0;
     p=head;
	 while(p!=null)
		{if(p->sum>max)max=p->sum;
	     p=p->next;
		}
	 p=head;
     while(p!=null)
		{if(p->sum==max)
			{printf("%d %d\n",p->number,max);
			p->sum=0;
			break;
			}
	     p=p->next;
		}
	}
}
main()
{struct student*head;
 head=creat();
 compare(head);
}


struct student
{
    int xuehao;
    int yuwen;
    int shuxue;
}stu[100000];
int main()
{
    int sum[100000];
    long i,j,n,t;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf ("%d %d %d",&stu[i].xuehao,&stu[i].yuwen,&stu[i].shuxue);
        sum[i]=stu[i].yuwen+stu[i].shuxue;
    }

    for (i=0;i<3;i++)
    {
        t=0;
        for (j=0;j<n-1;j++)
        {
            if (sum[j+1]>sum[t])
            t=j+1;
        }
        printf ("%d %d\n",stu[t].xuehao,sum[t]);
        sum[t]=0;
    }
    getchar();
    getchar();
    getchar();
}


int main()
{
	  int n,i,j;
	  float one=0,two=0,three=0,yi=0,er=0,san=0;
	  float a[100000][2];
	  scanf("%d",&n);
	  struct Student
	  {
		  float xuehao;
		  float yuwen;
		  float shuxue;
	  } student;
	  for (i=0;i<n;i++){
		  scanf("%f %f %f",&student.xuehao,&student.yuwen,&student.shuxue);
		  for (j=0;j<2;j++){
			  a[i][1]=student.yuwen+student.shuxue;
	          a[i][0]=i+1;
		  }
	  }
	  for (i=0;i<n;i++){
          if (a[i][1]>one)
		  {		  one=a[i][1];
		  yi=a[i][0];  }
	  }
      for (i=0;i<n;i++){
          if (a[i][1]>two&&a[i][1]<=one&&a[i][0]!=yi)
		  {		  two=a[i][1];
		  er=a[i][0];  }
	  }
       for (i=0;i<n;i++){
          if (a[i][1]>three&&a[i][1]<=one&&a[i][1]<=two&&a[i][0]!=yi&&a[i][0]!=er)
		  {		  three=a[i][1];
		  san=a[i][0];  }
	  }
	   printf("%.0f %.0f\n",yi,one);
	   printf("%.0f %.0f\n",er,two);
	   printf("%.0f %.0f\n",san,three);
	   return 0;
}


int main(int argc, char* argv[])
{
	int n,max,m;
	scanf("%d",&n);
	struct stu{
		int hao,yuwen,shuxue,zong;
	}stu[100000];
	int i,j;
	for(i=0;i<n;i++)
	{
		scanf("%d""%d""%d",&stu[i].hao,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].zong=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		max=stu[0].zong;
		for(j=1;j<n;j++)
		{
			if(stu[j].zong>max)
			{
				max=stu[j].zong;
				m=j;
			}
					}printf("%d %d\n",stu[m].hao,max);
			stu[m].zong=0;

	}

	return 0;
}


struct student{
	int num;
	int chinese;
	int math;
};
int main()
{
    int n,i;
	scanf("%d",&n);
	struct student a[100000],e ;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i].num,&a[i].chinese,&a[i].math);
	}
	for(i=0;i<n-1;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=0;i<n-2;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=0;i<n-3;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=n-1;i>n-4;i--){
		printf("%d %d\n",a[i].num,a[i].chinese+a[i].math);
	}
	return 0;
}


struct student
{
       long int  id;
       int chinese;
       int math;
};
main()
{
      long int i,maxi1,maxi2,maxi3,num;
      scanf("%d",&num);
      struct student a[num];
      for (i=0;i<num;i++)
      scanf("%d %d %d",&a[i].id,&a[i].chinese,&a[i].math);
      int maxpt1=0,maxpt2=0,maxpt3=0;
      for (i=0;i<num;i++)
      {
          if (maxpt1<a[i].chinese+a[i].math)
          {
                               maxpt3=maxpt2;
                               maxpt2=maxpt1;
                               maxpt1=a[i].chinese+a[i].math;
                               maxi3=maxi2;
                               maxi2=maxi1;
                               maxi1=a[i].id;
          }
          else if (maxpt2<a[i].chinese+a[i].math)
          {
                               maxpt3=maxpt2;
                               maxpt2=a[i].chinese+a[i].math;
                               maxi3=maxi2;
                               maxi2=a[i].id;
          }
          else if (maxpt3<a[i].chinese+a[i].math)
          {
                               maxpt3=a[i].chinese+a[i].math;
                               maxi3=a[i].id;
          }
      }
      printf("%d %d\n%d %d\n%d %d",maxi1,maxpt1,maxi2,maxpt2,maxi3,maxpt3);

}


void main()
{
	struct student
	{
		int ID;
	    int mark1;
		int mark2;
		int total;
	}student[100000],temp;
	int n,k,m;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		scanf("%d%d%d",&student[k].ID,&student[k].mark1,&student[k].mark2);
		student[k].total=student[k].mark1+student[k].mark2;
	}
	for(m=0;m<3;m++)
	{
	for(k=n-1;k>=m;k--)
	{
		if(student[k].total>student[k-1].total)
		{
			temp=student[k-1];
			student[k-1]=student[k];
			student[k]=temp;
		}
	}
	}
	printf("%d %d\n%d %d\n%d %d\n",student[0].ID,student[0].total,student[1].ID,student[1].total,student[2].ID,student[2].total);
}


struct student
{
	long number;
	int chinese;
	int math;
	int sum;
	struct student *next;
	struct student *previous;
};
struct student *creat(long n)
{
	struct student *head,*p1,*p2;
	int i;
	head=null;
	p1=(struct student *)malloc(len);
	scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
	p1->sum=p1->chinese+p1->math;
	p1->next=null;p1->previous=null;
	head=p1;p2=p1;
	for(i=2;i<=n;i++)
	{
		p1=(struct student *)malloc(len);
		scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
	    p1->sum=p1->chinese+p1->math;
	    p1->next=null;
	    p1->previous=p2;
	    p2->next=p1;
	    p2=p1;
	}
	return(head);
}
struct student *print(struct student *head)
{
	struct student *max,*p;
	max=head;
    for(p=head;p!=null;p=p->next)
      if(p->sum>max->sum) max=p;
    printf("%d %d\n",max->number,max->sum);
    if(max==head)
        head=max->next;
    else
        max->previous->next=max->next;
    return(head);
}
void main()
{
    struct student *head;
    long n;
    scanf("%d",&n);
    head=creat(n);
    print(head);
    print(head);
    print(head);
}


struct Student
{int num;
 int yuwen;
 int shuxue;
};
void fun(int*a,int*b);
int main()
{
	int n,i,j;
	int sum[100000];
	scanf ("%d",&n);
	struct Student stu[100000];
	for (i=0;i<n;i++)
	{
		scanf ("%d%d%d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
		sum[i]=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(sum[j]>sum[j-1])
			{
				fun(&sum[j],&sum[j-1]);
				fun(&stu[j-1].num,&stu[j].num);
					fun(&stu[j-1].yuwen,&stu[j].yuwen);
					fun(&stu[j-1].shuxue,&stu[j].shuxue);
			}
		}
	}
	for (i=0;i<3;i++)
		printf ("%d %d\n",stu[i].num,sum[i]);
	return 0;
}
void fun(int*a,int*b)
{
	int k;
	k=*a;
	*a=*b;
	*b=k;
}


struct student{
	int num;
	int yuwen;
	int shuxue;
	int score;
	struct student *next;
};
int n,i=0,a;
struct student *m1,*m2,*m3,*q;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
	p1->score=p1->yuwen+p1->shuxue;
	head=NULL;
	while(i<n-1)
	{
		if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
		p1->score=p1->yuwen+p1->shuxue;
		if(i>=3)
		{
			if(p2->score>m1->score)
			{
				m3=m2;
				m2=m1;
				m1=p2;
			}
			else if(p2->score<=m1->score&&p2->score>m2->score)
			{
				m3=m2;
				m2=p2;
			}
			else if(p2->score<=m2->score&&p2->score>m3->score)
				m3=p2;
			i++;
			continue;
		}
		if(i==0)m1=p2;
		else if(i==1)m2=p2;
		else if(i==2)
		{
			m3=p2;
			if(m1->score>m2->score)
			{
				if(m2->score<=m3->score)
				{
					if(m1->score>m3->score)
					{
						q=m3;
						m3=m2;
						m2=q;
					}
					else if(m1->score<=m3->score)
					{
						q=m1;m1=m2;m2=m3;m3=q;
					}
				}
			}
			else if(m1->score<=m2->score)
			{
				if(m2->score>m3->score)
				{
					if(m1->score>m3->score)
					{
						q=m1;
						m1=m2;
						m2=q;
					}
					else if(m1->score<=m3->score)
					{
						q=m3;m3=m1;m1=m2;m2=q;
					}
				}
				else if(m2->score<=m3->score)
				{
					q=m1;
					m1=m3;
					m3=q;
				}
			}
		}
		i++;
	}
	return(head);
}
int main()
{
	struct student *head;
	scanf("%d",&n);
	head=creat();
	printf("%d %d\n",m1->num,m1->score);
	printf("%d %d\n",m2->num,m2->score);
	printf("%d %d\n",m3->num,m3->score);
	return 0;
}


int main(int argc, char* argv[])
{
	struct student
	{int id;
	int x;
	int y;
	int z;
	}student1,student2,student3,studenta;
	int n,i;
	scanf("%d",&n);
	student1.z=student2.z=student3.z=0;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&studenta.id,&studenta.x,&studenta.y);
		studenta.z=studenta.x+studenta.y;
		if(studenta.z>student1.z){
			student3.z=student2.z;student3.id=student2.id;
			student2.z=student1.z;student2.id=student1.id;
			student1.z=studenta.z;student1.id=studenta.id;
		}
		else if(studenta.z>student2.z){
			student3.z=student2.z;student3.id=student2.id;
			student2.z=studenta.z;student2.id=studenta.id;
		}
		else if(studenta.z>student3.z){
			student3.z=studenta.z;student3.id=studenta.id;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",student1.id,student1.z,student2.id,student2.z,student3.id,student3.z);
	return 0;
}


struct stu
{long num;
int y;
int s;
int t;
struct stu * next;
};
void main()
{
	struct stu * head,*p1,*p2;
	int n,i;
	scanf("%d",&n);
	p1=p2=(struct stu *)malloc(L);
    scanf("%ld %d %d",&p1->num,&p1->y,&p1->s);
	head=p1;
	for(i=1;i<n;i++)
	{
		p1=(struct stu*) malloc(L);
		scanf("%ld %d %d",&p1->num,&p1->y,&p1->s);
		p1->t=p1->y+p1->s;
		p2->next=p1;
		p2=p1;
	}
	p2->next=0;
	int k=0;
	while(k<3)
	{
		p2=head;
	    for(;p2!=0;p2=p2->next)
		{
			for(p1=p2->next;p1!=0;)
			{
				if(p2->t<p1->t) break;
	 	        else p1=p1->next;
			}
			if(p1==0) {printf("%ld %d\n",p2->num,p2->t);break;}
		}
		k=k+1;p2->t=0;
	}
}


struct student{
	int number,chinese,math,total;
}stu[100000];
int main(int argc, char* argv[])
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].number,&stu[i].chinese,&stu[i].math);
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	int a=stu[0].total,b=stu[0].total,c=stu[0].total;
	for(i=0;i<n;i++){
		if(stu[i].total>a){
			c=b;
			b=a;
			a=stu[i].total;
			continue;
		}
		if(stu[i].total<a&&stu[i].total>b){
			c=b;
			b=stu[i].total;
			continue;
		}
		if(stu[i].total<b&&stu[i].total>c){
			c=stu[i].total;
			continue;
		}
	}
	int m=0;
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==a){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==b){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==c){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	return 0;
}


void main()
{
	struct s
	{
		int a;
		int b;
		int c;
		int d;
		struct s *next;
	};
	struct s *p1,*p2,*head;
	int i,j,k,m,n,t;
	scanf("%d",&n);
	p1=p2=(struct s *)malloc(sizeof(struct s));
	head=p1;
	scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	for(i=0;i<n-1;i++)
	{
		p1=(struct s *)malloc(sizeof(struct s));
		p2->next=p1;
		p2=p1;
		scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	}
	p2->next=0;
	p1=p2=head;
	for(i=0;i<n;i++)
	{
		p1->d=p1->b+p1->c;
		p1=p1->next;
	}
	p1=head;
	p2=p1->next;
	for(j=0;j<3;j++)
	{
		p1=head;p2=p1->next;
		for(i=0;i<n-2;i++)
		{
			if(p1->d<p2->d)
			{
				t=p1->d;
				p1->d=p2->d;
				p2->d=t;
				k=p1->a;
				p1->a=p2->a;
				p2->a=k;
			}

			p2=p2->next;

		}
		p1=head;

			printf("%d %d\n",p1->a,p1->d);
			p1->d=0;

	}
}


struct student
{
	int num;
	int liter;
	int math;
	int total;
};
int main()
{
	int i,j,k,n;
	struct student a[100000],n1,n2,n3;
	scanf("%d",&n);
	scanf("%d%d%d",&a[0].num,&a[0].liter,&a[0].math);
	a[0].total=a[0].liter+a[0].math;
	n1=n2=n3=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%d%d%d",&a[i].num,&a[i].liter,&a[i].math);
		a[i].total=a[i].liter+a[i].math;
		if(a[i].total>n1.total)
		{
			n3=n2;
			n2=n1;
			n1=a[i];
		}
		else if(a[i].total>n2.total)
		{
			n3=n2;
			n2=a[i];
		}
		else if(a[i].total>n3.total)
			n3=a[i];
	}
	printf("%d %d\n",n1.num,n1.total);
	printf("%d %d\n",n2.num,n2.total);
	printf("%d %d",n3.num,n3.total);
		return 0;
}


/*
 * 01.cpp
 *
 *  Created on: 2010-12-24
 *      Author: liuquan
 */
int main(){
	struct student{//????
		int number;
		int chinese;
		int math;
		int all;
	}stu[100000];
	int n,i,j,n1=1,n2=1,n3=1;
	cin>>n;
	for(i=1;i<=n;i++){//??
		cin>>stu[i].number>>stu[i].chinese>>stu[i].math;
		stu[i].all=stu[i].chinese+stu[i].math;
	}
	/*for(j=1;j<n;j++){//?????
		for(i=1;i<n-j;i++){
			if(stu[i].all<stu[i+1].all){
				t=stu[i].all;
				stu[i].all=stu[i+1].all;
				stu[i+1].all=t;
				t1=stu[i].number;
				stu[i].number=stu[i+1].number;
				stu[i+1].number=t1;
			}
		}
	}*/
	for(i=2;i<=n;i++){
		if(stu[n1].all<stu[i].all)
			n1=i;

	}
	for(i=2;i<=n;i++){
		if(i==n1)
          continue;
		if(stu[n2].all<stu[i].all)
			n2=i;
	}
	for(i=2;i<=n;i++){
		if(i==n2||i==n1)
           continue;
		if(stu[n3].all<stu[i].all)
			n3=i;
	}
		cout<<stu[n1].number<<" "<<stu[n1].all<<endl;//?????
		cout<<stu[n2].number<<" "<<stu[n2].all<<endl;
		cout<<stu[n3].number<<" "<<stu[n3].all<<endl;
	return 0;
}


struct student
{
	int id;
	int chinese;
	int math;
}student[100000];
void main()
{
	int n,i,j,sum[100000]={0},h1=0,h2=0,h3=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&student[i].id,&student[i].chinese,&student[i].math);
	}
	int first=0;
	int sec=0;
	int thi=0;
	for(j=0;j<n;j++){
		if(first<student[j].chinese+student[j].math)
		{
			thi=sec;
			h3=h2;
			sec=first;
			h2=h1;
			first=student[j].chinese+student[j].math;
			h1=student[j].id;
		}
		else if((first>student[j].chinese+student[j].math)&&(sec<student[j].chinese+student[j].math))
		{
			thi=sec;
			h3=h2;
			sec=student[j].chinese+student[j].math;
			h2=student[j].id;
		}
		else if((sec>student[j].chinese+student[j].math)&&(thi<student[j].chinese+student[j].math))
		{
			thi=student[j].chinese+student[j].math;
			h3=student[j].id;
		}
		else if((first==student[j].chinese+student[j].math)&&(sec<student[j].chinese+student[j].math))
		{
			thi=sec;
			h3=h2;
			sec=student[j].chinese+student[j].math;
			h2=student[j].id;
		}
		else if((sec==student[j].chinese+student[j].math)&&(thi<student[j].chinese+student[j].math))
		{
			thi=student[j].chinese+student[j].math;
			h3=student[j].id;
		}
	}
	printf("%d %d\n%d %d\n%d %d",h1,first,h2,sec,h3,thi);
}


struct student
{
int ID;
int chi;
int math;
int total;
} stu[1000000];

void main()
{
	int STUDENT_NUM,i,j,temp1,temp2;
	scanf("%d",&STUDENT_NUM);
	for(i=0;i<STUDENT_NUM;i++)
	{
		scanf("%d %d %d",&stu[i].ID,&stu[i].chi,&stu[i].math);
		stu[i].total=stu[i].chi+stu[i].math;
	}
	for(i=0;i<3;i++)
	{
	    for(j=i+1;j<STUDENT_NUM;j++)
		{
			if(stu[i].total<stu[j].total)
			{
				temp1=stu[i].ID;
				stu[i].ID=stu[j].ID;
				stu[j].ID=temp1;
				temp2=stu[i].total;
				stu[i].total=stu[j].total;
				stu[j].total=temp2;
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[0].ID,stu[0].total,stu[1].ID,stu[1].total,stu[2].ID,stu[2].total);
}


void main(int argc, char* argv[])
{
	int num,chi,math,sum;
	struct student{
		int num,chi,math,sum;
	}students[100000];
	int i;
	int STUDENT_NUM;
	scanf("%d",&STUDENT_NUM);
	for (i=0;i<STUDENT_NUM;i++)
	{
		scanf("%d %d %d",&num,&chi,&math);
		students[i].num=num;
		students[i].chi=chi;
		students[i].math=math;
		sum=chi+math;
		students[i].sum=sum;
	}
	int sum1=0,sum2=0,sum3=0;
	int num1,num2,num3;
	for (i=0;i<STUDENT_NUM;i++)
	{
		if(i==0)
		{
			sum1=students[0].sum;
			num1=students[0].num;
		}
		else if(i==1)
		{
			if(students[1].sum>students[0].sum)
			{
				sum2=sum1;
				num2=num1;
				sum1=students[1].sum;
				num1=students[1].num;
			}
			else
			{
				sum2=students[1].sum;
				num2=students[1].num;
			}
		}
		else
		{
			if(students[i].sum>sum1)
			{
				sum3=sum2;
				num3=num2;
				sum2=sum1;
				num2=num1;
				sum1=students[i].sum;
				num1=students[i].num;
			}
			else if(students[i].sum>sum2)
			{
				sum3=sum2;
				num3=num2;
				sum2=students[i].sum;
				num2=students[i].num;
			}
			else if(students[i].sum>sum3)
			{
				sum3=students[i].sum;
				num3=students[i].num;
			}
		}
	}
	printf("%d %d\n",num1,sum1);
	printf("%d %d\n",num2,sum2);
	printf("%d %d\n",num3,sum3);
}


int main()
{
    int N,i,j,k;
    cin>>N;
    struct Student_Num    //?????
    {
        int num;         //??
        int Chinese;     //????
        int Math;        //????
    };
    struct Student_Num student[N];       //N??????
    struct Student_Num temp;
    for(i=0;i<N;i++)
    {
        cin>>student[i].num>>student[i].Chinese>>student[i].Math;   //????????
    }
    int total[N],totalNum[3],p[3];       //?????????????????????????
    for(i=0;i<N;i++)
    {
        total[i]=student[i].Chinese+student[i].Math;  //???
    }
    for(i=0;i<3;i++)               //????0
    {
        totalNum[i]=0;
    }
    for(i=0;i<3;i++)      //?????
    {
        for(j=0;j<N;j++)
        {
            if(totalNum[i]<total[j])
            {
                totalNum[i]=total[j];
                p[i]=j;
            }
        }
        total[p[i]]=0;   //?????????????????0???????????????
    }
    for(i=0;i<3;i++)
    {
        cout<<student[p[i]].num<<' '<<totalNum[i]<<endl;   //????????
    }
    return 0;
}


struct student
    {
           int num,chi,mat,tot;
    }stu[100000];

int main()
{
    void max(struct student [],int n);
    int n,i,k;

    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
     scanf("%d%d%d",&stu[i].num,&stu[i].chi,&stu[i].mat);
     stu[i].tot=stu[i].chi+stu[i].mat;
    }

    for(k=0;k<3;k++)
    {
                    max(stu,n);
                    if(k<2)
                    printf("\n");

    }
}

void max(struct student stu[],int n)
{
     int i,j,max;
     max=stu[0].tot;
     for(i=0;i<n;i++)
      if(stu[i].tot>max)
       {
        max=stu[i].tot;
        j=i;
        }

     printf("%d %d",stu[j].num,max);
     stu[j].tot=-1;
}


struct student
{
	int num;
	int score1;
	int score2;
	int score;
};

void main()
{
	int n;
	scanf("%d",&n);
	struct student stu[100000];
	struct student *p,*p1,*t1,*t2,*t3;
	int tem,tem1;
	for(p=stu;p<stu+n;p++)
	{
		scanf("%d %d %d",&p->num,&p->score1,&p->score2);
		p->score=p->score1+p->score2;
	}
	int max;
	for(p=stu,t1=stu,max=stu->score;p<stu+n;p++)
	{
		if(p->score>max) {t1=p;max=p->score;}
	}
	for(p=stu,t2=stu,max=stu->score;p<stu+n;p++)
	{
		if(p==t1) continue;
		if(p->score>max) {t2=p;max=p->score;}
	}
	for(p=stu,t3=stu,max=stu->score;p<stu+n;p++)
	{
		if((p==t1)||(p==t2)) continue;
		if(p->score>max) {t3=p;max=p->score;}
	}
	printf("%d %d\n",t1->num,t1->score);
	printf("%d %d\n",t2->num,t2->score);
	printf("%d %d\n",t3->num,t3->score);
}


struct inf
{
	int nu;
	int b;
	int c;
	int sum;
} a[100010],tmp;
int main()
{
	int n,i,j,k,tmp1,tmp2;
	char c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		{
			a[i-1].sum=0;
			scanf("%d%d%d",&a[i-1].nu,&a[i-1].b,&a[i-1].c);
			a[i-1].sum=a[i-1].b+a[i-1].c;
	}
	for(i=0;i<3;i++)
	{
		tmp1=i;tmp2=a[i].sum;
		for(j=i+1;j<n;j++)
		{
			if(a[j].sum>tmp2)
				{
					tmp2=a[j].sum;
					tmp1=j;
			}
		}
		tmp=a[i];
		a[i]=a[tmp1];
		a[tmp1]=tmp;
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",a[i].nu,a[i].sum);
	return 0;
}


int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	struct student{
		int a,b,c;
	}student_1;
	int x,i=0;
	int a1=0,a2=0,b1=0,b2=0,c1=0,c2=0;
	while(i<n){
		scanf("%d%d%d",&student_1.a,&student_1.b,&student_1.c);
		x=student_1.b+student_1.c;
			if(x>a2){
				c1=b1;
				c2=b2;
				b1=a1;
				b2=a2;
				a1=student_1.a;
				a2=x;
			}
			else if(x==a2){
				if (x > b2)
				{
					c1 = b1;
					c2 = b2;
					b1=student_1.a;
					b2=x;
				}
				else if (x > c2)
				{
					c1 = student_1.a;
					c2 = x;
				}
			}
			else if(x>b2){
				c1=b1;
				c2=b2;
				b1=student_1.a;
				b2=x;
			}
			else if(x==b2){
				if (x > c2)
				{
					c1=student_1.a;
					c2=x;
				}
			}
			else if(x>c2){
				c1=student_1.a;
				c2=x;
			}
		i++;
	}
	printf("%d %d\n",a1,a2);
	printf("%d %d\n",b1,b2);
	printf("%d %d\n",c1,c2);
	return 0;
}


struct student
{
	int num;
	int chinese;
	int math;
	int total;
}s[N];

int main()
{
	int n,i,j,tn,tt;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&s[i].num,&s[i].chinese,&s[i].math);
		s[i].total=s[i].math+s[i].chinese;
	}
	for (i=1;i<4;i++)
	{
		for (j=0;j<n-i;j++)
		{
			if (s[j].total>=s[j+1].total)
			{
				tt=s[j].total;            tn=s[j].num;
				s[j].total=s[j+1].total;  s[j].num=s[j+1].num;
				s[j+1].total=tt;          s[j+1].num=tn;
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",s[n-1].num,s[n-1].total,s[n-2].num,s[n-2].total,s[n-3].num,s[n-3].total);
    return (0);
}


int main(){
	struct student{
		int stuno;
		int score1;
		int score2;
		int score0;
	};
	int n,i,j,temp;
	cin>>n;
	struct student num[n];
	for(i=0;i<n;i++){
		cin>>num[i].stuno;
		cin>>num[i].score1;
		cin>>num[i].score2;
		num[i].score0=num[i].score1+num[i].score2;
	}
	for(i=0;i<3;i++)
		for(j=i+1;j<n;j++)
			if(num[i].score0<num[j].score0){
				temp=num[i].score0;
				num[i].score0=num[j].score0;
				num[j].score0=temp;
				temp=num[i].stuno;
				num[i].stuno=num[j].stuno;
				num[j].stuno=temp;
			}
	for(i=0;i<3&&i<n;i++)
		cout<<num[i].stuno<<" "<<num[i].score0<<endl;
	return 0;
}


struct student
{int num;
 int yw;
 int sx;
 struct student *next;
};
void main()
{
	struct student *head,*p1,*p2;
	int i,max,n;
	scanf("%d",&n);
	p1=p2=head=NULL;
	for(i=0;i<n;i++)
	  {p1=(struct student*)malloc(LEN);
	   scanf("%d%d%d",&p1->num,&p1->yw,&p1->sx);
	   if(i==0)head=p1;
	   else p2->next=p1;
	   p2=p1;
	   }
	 p2->next=NULL;

   for(i=0;i<3;i++)
   {p1=p2=head;
    max=p1->yw+p1->sx;
	while(p1!=NULL)
	   {if((p1->yw+p1->sx)>max)
	       {max=p1->yw+p1->sx;
	        p2=p1;
	       }
	   p1=p1->next;
	   }
	printf("%d %d\n",p2->num,max);
	p1=head;
	while(p1->next!=p2)
	   {p1=p1->next;}
	p1->next=p2->next;
   }
}


int main()
{
    int n,i,j,k,h,b;
    scanf("%d",&n);
    struct sb
    {
         int ID;
         int m;
         int c;
         int sum;
    }a[n];
    for(i=0;i<n;i++)
    {
         scanf("%d%d%d",&a[i].ID,&a[i].m,&a[i].c);
         a[i].sum=a[i].m+a[i].c;
    }
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    a[h].sum=-1;
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    a[h].sum=-1;
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    getchar();
    getchar();
}


int b[100000];

struct student
	{   int num;
	    int  score1;
		int score2;

	}a[100000];

void main()
{   int max(int b[],int n);

		int i,j=0,n,c;

		scanf("%d",&n);

     for (i=0;i<n;i++)
	 {
		 scanf("%d%d%d",&a[i].num,&a[i].score1,&a[i].score2);
	      b[i]=a[i].score1+a[i].score2;
	 }
	while(j<3)
	{
	       	c=max(b,n) ;
		 for (i=0;i<n;i++)
		 {
			 if (b[i]==c)
			 {
				 printf("%d %d\n",a[i].num,b[i]);
				 b[i]=0;j=j+1;
				 if (j==3) break;
			 }

		 }
	}

}
int max(int b[],int n)
{
	int c,i;
	   c=b[0];
      for (i=0;i<n;i++)
	  {
      if (c<b[i])
		  c=b[i];
	  }
	  return(c);
}


struct student
{
	int number;
	int score1;
	int score2;
};
struct student stu[100000];
int main()
{
	int n,i,first=0,second=0,third=0,a[100000];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].number,&stu[i].score1,&stu[i].score2);
		a[i]=stu[i].score1+stu[i].score2;
	}
	for(i=0;i<n-1;i++)
	{
		if(a[first]<a[i])
		{
			third=second;
			second=first;
			first=i;
		}
		else if(a[second]<a[i])
		{
			third=second;
			second=i;
		}
		else if(a[third]<a[i])
		{
			third=i;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[first].number,a[first],stu[second].number,a[second],stu[third].number,a[third]);
	return(0);
}


struct stu
{
	int num;
	int score1;
	int score2;
}
main()
{
	struct stu damn[4];
	int n,i,j,total;
	scanf("%d",&n);
	for(i=0;i<3;i++) scanf("%d %d %d",&damn[i].num,&damn[i].score1,&damn[i].score2);
	for(i=0;i<2;i++)
	{
		for(j=0;j<2-i;j++)
		{
			if(damn[j].score1+damn[j].score2<damn[j+1].score1+damn[j+1].score2)
			{
				damn[3]=damn[j];
				damn[j]=damn[j+1];
				damn[j+1]=damn[3];
			}
		}
	}
	for(i=0;i<n-3;i++)
	{
		scanf("%d %d %d",&damn[3].num,&damn[3].score1,&damn[3].score2);
		if(damn[3].score1+damn[3].score2<damn[2].score1+damn[2].score2) continue;
		else if(damn[3].score1+damn[3].score2<=damn[1].score1+damn[1].score2&&damn[3].score1+damn[3].score2>damn[2].score1+damn[2].score2)
		{
			damn[2]=damn[3];
		}
		else if(damn[3].score1+damn[3].score2<=damn[0].score1+damn[0].score2&&damn[3].score1+damn[3].score2>damn[1].score1+damn[1].score2)
		{
			damn[2]=damn[1];
			damn[1]=damn[3];
		}
		else if(damn[3].score1+damn[3].score2>damn[0].score1+damn[0].score2)
		{
			damn[2]=damn[1];
			damn[1]=damn[0];
			damn[0]=damn[3];
		}

	}
	for(i=0;i<2;i++)
	{
		total=damn[i].score1+damn[i].score2;
		printf("%d %d\n",damn[i].num,total);
	}
	total=damn[i].score1+damn[i].score2;
	printf("%d %d",damn[i].num,total);
}


struct student
	{
		char number[20];
		int chinese;
		int math;
		int sum;
		struct student *next;
	}stu[100000],*s1,*s2,*s3;

int n,max1=0,max2=0,max3=0;

struct student *creat(void)
{
	int i;
	struct student *head,*p1,*p2;
    p1=p2=(struct student*)malloc(LEN);
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d",&p1->number,&p1->chinese,&p1->math);
		p2=p1;
		p1->sum=p1->chinese+p1->math;
		if(p1->sum>max1)
		{max3=max2;s3=s2;max2=max1;s2=s1;max1=p1->sum;s1=p1;}
		else if(p1->sum>max2)
		{max3=max2;s3=s2;max2=p1->sum;s2=p1;}
		else if(p1->sum>max3)
		{max3=p1->sum;s3=p1;}
		if(i==0)head=p1;
		else p2->next=p1;

		p1=(struct student*)malloc(LEN);
	}
	p1=NULL;
	return(head);
}

void main()
{
	struct student *p;
	scanf("%d",&n);
	p=creat();
    printf("%s %d\n",s1->number,s1->sum);
	printf("%s %d\n",s2->number,s2->sum);
	printf("%s %d",s3->number,s3->sum);
}


int pfCompare(const void * elem1, const void * elem2)
{
    int c;
    c=*(int*)elem1-*(int*)elem2;
    return c;
}
struct student
{
      int num;
      int x;
      int y;
}a[100000];
main()
{
    int n,i,j,d=0,b[100000],c[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d",&a[i].num);
                    scanf("%d",&a[i].x);
                    scanf("%d",&a[i].y);
    }
    for(i=0;i<n;i++)
    {
                    b[i]=a[i].x+a[i].y;
    }
    qsort(b,n,sizeof(int),pfCompare);
    for(j=0;j<n;j++)
    {
             if(b[n-1]==a[j].x+a[j].y)
             {
                     printf("%d"" ""%d",a[j].num,b[n-1]);
                     printf("\n");
                     d++;
             }
             if(d==3)
             break;
    }
    for(i=n-2;i>n-4;i--)
    {
                  if(b[i]==b[i+1])
                  continue;
                  else
                  {
                                  for(j=0;j<n;j++)
                                  {
                                              if(b[i]==a[j].x+a[j].y)
                                              {
                                                      printf("%d"" ""%d",a[j].num,b[i]);
                                                      printf("\n");
                                                      d++;
                                              }
                                              if(d==3)
                                              break;
                                  }
                                  if(d==3)
                                  break;
                  }
    }
   }


struct student
{
	int num;
	int score1;
	int score2;
	int sum;
	struct student *next;
	struct student *before;
};
main()
{
	int i,n,n1=0,n2=0,n3=0,m1=0,m2=0,m3=0;
	struct student *head;
	struct student *p1,*p2;
	scanf("%d",&n);
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->score1,&p1->score1);
	p1->sum=p1->score1+p1->score2;
	m1=p1->sum;
	n1=p1->num;
	head=0;
	i=0;
	while(i<=n-2)
	{
		i++;
		if(i==1)
			head=p1;
		else
		{
			p1->before=p2;
			p2->next=p1;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
        scanf("%d %d %d",&p1->num,&p1->score1,&p1->score2);
		p1->sum=p1->score1+p1->score2;
		if(p1->sum>m3 && p1->sum<=m2)
		{
			m3=p1->sum;
			n3=p1->num;
		}
		if(p1->sum>m2 && p1->sum<=m1)
		{
			m3=m2;
			n3=n2;
			m2=p1->sum;
			n2=p1->num;
		}
		if(p1->sum>m1)
		{
			m3=m2;
			n3=n2;
			m2=m1;
			n2=n1;
			m1=p1->sum;
			n1=p1->num;
		}
	}
	printf("%d %d\n",n1,m1);
	printf("%d %d\n",n2,m2);
	printf("%d %d\n",n3,m3);
}


void main()
{
	struct student
	{
		int xh;
		int yw;
		int sx;
		int zf;
		struct student *next;
	};
	int i,j,k,n,m,max;
	struct student *p1,*p2,*head;
	scanf("%d",&n);
	head=p1=p2=(struct student *)malloc(sizeof(struct student));
	scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
	p1->zf=p1->yw+p1->sx;
	for(i=2;i<=n;i++)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
		p1->zf=p1->yw+p1->sx;
		p2->next=p1;
		p2=p1;
		if(i==n)p1->next=0;
	}
	p1=head;
	for(i=1;i<=3;i++)
	{
		p1=head;
		max=0;
		for(j=1;j<=n;j++)
		{
			max=max>p1->zf?max:p1->zf;
			p1=p1->next;
		}
		//printf("%d\n",max);
		p1=head;
		for(j=1;j<=n;j++)
		{
			if(p1->zf==max)
			{
				printf("%d %d\n",p1->xh,p1->zf);
				p1->zf=0;
				break;

			}
			p1=p1->next;
		}
	}

}


struct stu
{int xuehao,yuwen,shuxue,sum;
struct stu *next;
};
void max(struct stu *h)
{
	struct stu *a,*b,*c,*d;
	int m=0;
	a=h;
	do
	{
		c=a;
		a=a->next;
		if(m<a->sum)
		{
			m=a->sum;
			d=c;
			b=a;
		}
		}while(a->next);
		printf("%d %d\n",b->xuehao,b->sum);
		d->next=b->next;
		free(b);
}

void main()
{
	struct stu *head,*p,*q;
	int n,i;
	scanf("%d",&n);
	head=M;
	p=M;
	head->next=p;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&p->xuehao,&p->yuwen,&p->shuxue);
		p->sum=p->yuwen+p->shuxue;
	    q=M;
		p->next=q;
		p=q;
	}
	p->next=NULL;
	max(head);
	max(head);
	max(head);
}


struct student
{
	int id;
	int yu;
	int shu;
	struct student *next;
};
void main()
{
    int n,i,j=0;

	struct student *head,*p1,*p2;

	scanf("%d",&n);
	head=p1=p2=(struct student *)malloc(LEN);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&p1->id,&p1->yu,&p1->shu);
		p1=(struct student *)malloc(LEN);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	p1=head;
	for(i=200;i>10;i--)
	{
		p1=head;
		while(p1!=NULL)
		{
		    if((p1->yu+p1->shu)==i)
		    {
			    printf("%d %d\n",p1->id,i);
			    j++;

		    }
		    p1=p1->next;
		    if(j==3)break;
		}
		if(j==3)break;
	}
}


struct stu
{
	char name[20];
	int sbu[3];
};
int main()
{
       int n;
      scanf("%d",&n);
	int i,j=0,j2=0,j3=0,min=0;
	struct stu stu[100000];
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d",stu[i].name,&stu[i].sbu[0],&stu[i].sbu[1]);
		stu[i].sbu[2]=stu[i].sbu[0]+stu[i].sbu[1];
	}

	for(i=0;i<n;i++)
	{
		if(stu[i].sbu[2]>min)
		{min=stu[i].sbu[2];
		j=i;}
	}
		printf("%s %d\n",stu[j].name,min);
min=0;
for(i=0;i<n;i++)
	{
		if(stu[i].sbu[2]<=stu[j].sbu[2]&&stu[i].sbu[2]>min&&i!=j)
		{min=stu[i].sbu[2];
		j2=i;}
	}
		printf("%s %d\n",stu[j2].name,min);
min=0;
for(i=0;i<n;i++)
	{
		if(stu[i].sbu[2]<=stu[j2].sbu[2]&&stu[i].sbu[2]>min&&i!=j&i!=j2)
		{min=stu[i].sbu[2];
		j3=i;}
	}
		printf("%s %d\n",stu[j3].name,min);
}


struct student
{
	int num;
    int chinese;
	int maths;
	int sum;};
int main()
{ struct student stu[4]={0,0,0,0};
  struct student temp[4]={0,0,0,0};
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
	  scanf("%d%d%d",&stu[3].num,&stu[3].chinese,&stu[3].maths);
	  stu[3].sum=stu[3].chinese+stu[3].maths;
	  //printf("%d",stu[3].chinese);
	  if(stu[3].sum>stu[0].sum)
	  {stu[2]=stu[1];stu[1]=stu[0];stu[0]=stu[3];}
	  else if(stu[3].sum>stu[1].sum)
	  {stu[2]=stu[1];stu[1]=stu[3];}
	  else if(stu[3].sum>stu[2].sum)
	  {stu[2]=stu[3];}
  }
  for(i=0;i<3;i++)
  {
	  printf("%d %d\n",stu[i].num,stu[i].sum);
  }
  return 0;
}


struct Student
{
	int No;
	int Chinese;
	int Maths;
    int Total;
};

void bubble(struct Student a[],int n)
{
	int i,j;
	struct Student temp;
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(a[j].Total<a[j+1].Total)
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
}

int main()
{
	int n,i;
	struct Student stu[4];
	scanf("%d",&n);
	if(n>3)
	{
		for(i=0;i<3;i++)
		{
	    	scanf("%d%d%d",&stu[i].No,&stu[i].Chinese,&stu[i].Maths);
	    	stu[i].Total=stu[i].Chinese+stu[i].Maths;
		}
        for(i=3;i<n;i++)
		{
		    scanf("%d%d%d",&stu[3].No,&stu[3].Chinese,&stu[3].Maths);
			stu[3].Total=+stu[3].Chinese+stu[3].Maths;
			bubble(stu,4);
		}
	}
	else
	{
		for(i=0;i<n;i++)
		{
	    	scanf("%d%d%d",&stu[i].No,&stu[i].Chinese,&stu[i].Maths);
	    	stu[i].Total=stu[i].No+stu[i].Chinese+stu[i].Maths;
		}
		bubble(stu,n);
	}
	for(i=0;i<n&&i<3;i++)printf("%d %d\n",stu[i].No,stu[i].Total);
	return 0;
}


struct student
{
int num;
int yuwen;
int shuxue;
struct student *next;
};
int m;

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

struct student *creat(int n);
void print(struct student *head,int n);

struct student *head;
head=creat(n);
print(head,n);
print(head,n);
print(head,n);
}

struct student *creat(int n)
{
struct student *head;
struct student *p1,*p2;
m=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%d %d %d\n",&p1->num,&p1->yuwen,&p1->shuxue);
head=NULL;
for(;n!=0;n--)
{
 m+=1;
 if(m==1)head=p1;
 else p2->next=p1;
 p2=p1;
 p1=(struct student*)malloc(LEN);
 scanf("%d %d %d\n",&p1->num,&p1->yuwen,&p1->shuxue);
 }
p2->next=NULL;
return(head);
}

void print(struct student *head,int n)
{
struct student *p,*q;
p=head;
int max=0,index=0;
for(;n!=0;n--)
{
 if(max<((p->yuwen)+(p->shuxue)))
 {
 max=((p->yuwen)+(p->shuxue));
 index=p->num;
 q=p;
  }
 p=p->next;
 }
printf("%d %d\n",index,max);
q->yuwen=0;
q->shuxue=0;
}


void main()
{
    struct student
    {
    	long num;
    	int chinese;
    	int math;
    };
    struct student stu[100001];
    int i,t,h,l=0;
    long n;
    int a[100001];
    scanf("%ld",&n);
    for(i=0;i<n;i++)
    scanf("%d%d%d",&stu[i].num,&stu[i].chinese,&stu[i].math);
    for(i=0;i<n;i++)
    a[i]=stu[i].chinese+stu[i].math;
    leap:
    t=a[0];
    h=0;
    for(i=1;i<n;i++)
    {
    	if(a[i]>t)
    	{
    		t=a[i];
    	    h=i;
    	}
    }
    printf("%ld %d\n",stu[h].num,a[h]);
    l++;
    a[h]=0;
    if(l<3)
    goto leap;
}


 struct stu
 {
	 int num;
	 int m;
	 int c;
	 int sum;
 };

int main()
{
	long int n;
	int a=0,b=0,c=0,x=0,y=0,z=0;
	struct stu student[65535];
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d %d %d",&student[i].num,&student[i].c,&student[i].m);
		student[i].sum=student[i].m+student[i].c;
	}
	for (int i=0;i<n;i++)
	{
		if(student[i].sum>a)
		{
			c=b;
			z=y;
			b=a;
			y=x;
			a=student[i].sum;
			x=student[i].num;
			continue;
		}
		if(student[i].sum>b)
		{
			c=b;
			z=y;
			b=student[i].sum;
			y=student[i].num;
			continue;
		}
		if (student[i].sum>c)
		{
			c=student[i].sum;
			z=student[i].num;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",x,a,y,b,z,c);
getchar();
getchar();
return 0;
}


void main()
{
	struct data
	{
		int number;
		int chinese;
		int math;
		int total;
	}student[100000],temp;

	long n,i,j;

	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&student[i].number,&student[i].chinese,&student[i].math);
		student[i].total=student[i].chinese+student[i].math;
	}

	for(i=0;i<3;i++)
		for(j=i+1;j<n;j++)
			if(student[i].total<student[j].total)
			{
				temp.number=student[i].number;
				temp.chinese=student[i].chinese;
				temp.math=student[i].math;
				temp.total=student[i].total;

				student[i].number=student[j].number;
				student[i].chinese=student[j].chinese;
				student[i].math=student[j].math;
				student[i].total=student[j].total;

				student[j].number=temp.number;
				student[j].chinese=temp.chinese;
				student[j].math=temp.math;
				student[j].total=temp.total;
			}

	for(i=0;i<3;i++)
		printf("%d %d\n",student[i].number,student[i].total);

}


struct student
{
	long num;
	int math;
	int chinese;
	struct student *next;
};

long stu_num;
struct student *max1,*max2,*max3;

struct student *creat(void)
{
	struct student *head,*p1,*p2;
	long n;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%ld%d%d",&p1->num,&p1->math,&p1->chinese);
	head=NULL;
	n=0;
	while(n<stu_num)
	{
		n++;
		if(n==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%ld%d%d",&p1->num,&p1->math,&p1->chinese);
	}
	p2->next=NULL;
	return(head);
}

void Max1(struct student *head,long stu_num)
{
	struct student *q1;
	q1=head;
	max1=head;
	for(;q1!=NULL;)
		if((max1->math+max1->chinese)<(q1->math+q1->chinese))
		{
			max1=q1;
			q1=q1->next;
		}
		else
            q1=q1->next;
	printf("%ld %d\n",max1->num,max1->math+max1->chinese);
}

void Max2(struct student *head,long stu_num)
{
	struct student *q2;
	q2=head;
	if(head!=max1)
		max2=head;
	else
		max2=q2->next;
	for(;q2!=NULL;)
		if((max2->math+max2->chinese)<(q2->math+q2->chinese)&&q2!=max1)
		{
			max2=q2;
			q2=q2->next;
		}
		else
            q2=q2->next;
	printf("%ld %d\n",max2->num,max2->math+max2->chinese);
}

void Max3(struct student *head,long stu_num)
{
	struct student *q3;
	q3=head;
	for(;q3!=NULL;)
		if(q3==max1||q3==max2)
			q3=q3->next;
		else
		{
			max3=q3;
			break;
		}
	q3=head;
	for(;q3!=NULL;)
		if((max3->math+max3->chinese)<(q3->math+q3->chinese)&&q3!=max1&&q3!=max2)
		{
			max3=q3;
			q3=q3->next;
		}
		else
            q3=q3->next;
	printf("%ld %d\n",max3->num,max3->math+max3->chinese);
}

void main()
{
	struct student *head;
	scanf("%ld",&stu_num);
	head=creat();
	Max1(head,stu_num);
	Max2(head,stu_num);
	Max3(head,stu_num);
}


main()
{
	struct student{
		int id;
		float yuwen,shuxue,sum;
	}stu[100000],t;
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	  {scanf("%d %f %f",&stu[i].id,&stu[i].yuwen,&stu[i].shuxue);
	   stu[i].sum=stu[i].yuwen+stu[i].shuxue;}
    for(i=0;i<3;i++)
      for(j=n-1;j>i;j--)
       	if(stu[j].sum>stu[j-1].sum)
       {
       	t=stu[j];
       	stu[j]=stu[j-1];
       	stu[j-1]=t;
       }
    for(i=0;i<3;i++)
     printf("%d %g\n",stu[i].id,stu[i].sum);
}


int main()
{
	struct st
	{int id;
	int yu;
	int ma;
	};
	int n,i;
	struct st st1={0,0,0},st2={0,0,0},st3={0,0,0},stn;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stn.id,&stn.yu,&stn.ma);
		if(stn.yu+stn.ma>st1.yu+st1.ma){
			st3=st2;
			st2=st1;
			st1=stn;
		}else{
			if(stn.yu+stn.ma>st2.yu+st2.ma){
				st3=st2;
				st2=stn;
			}else{
				if(stn.yu+stn.ma>st3.yu+st3.ma){
					st3=stn;
				}
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d",st1.id,st1.yu+st1.ma,st2.id,st2.yu+st2.ma,st3.id,st3.yu+st3.ma);
}


struct stu
{
	int no;
	int chi;
	int math;
	int sum;
	struct stu *next;
};
void main()
{
	struct stu a,*head,*p,*tail,*q;
	int k,i,m1,m2,m3,n1,n2,n3,temp1,temp2;
	head=NULL;
	scanf("%d",&k);
    for(i=0;i<k;i++)
	{
		p=(struct stu*)malloc(LEN);
        scanf("%d %d %d",&p->no,&p->chi,&p->math);
		p->sum=(p->chi+p->math);
        if(head==NULL)
			head=tail=p;
        else
		{
			tail->next=p;
            tail=p;
			tail->next=&a;
		}
	}
	a.next=NULL;
	p=head;
	for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m1=p->no;
	n1=p->sum;
	head=p->next;
	p=head;
	for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m2=p->no;
	n2=p->sum;
	head=p->next;
	p=head;
    for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m3=p->no;
	n3=p->sum;
    printf("%d %d\n%d %d\n%d %d\n",m1,n1,m2,n2,m3,n3);
}


struct
{
int ID[100000],Chinese[100000],Maths[100000];
}stu;
int main()
{
	int n,i,sum[100000],max1=0,max2=0,max3=0,num1,num2,num3;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d %d %d",&stu.ID[i],&stu.Chinese[i],&stu.Maths[i]);
	}
	i=0;
	while(stu.ID[i]>0){
	sum[i]=stu.Chinese[i]+stu.Maths[i];
	i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max1){
		max1=sum[i];
		num1=i;
		}
		i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max2&&sum[i]<=max1&&i!=num1){
		max2=sum[i];
		num2=i;
		}
	i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max3&&sum[i]<=max2&&i!=num2&&i!=num1){
		max3=sum[i];
		num3=i;
		}
	i++;
	}
	printf("%d %d\n%d %d\n%d %d",stu.ID[num1],max1,stu.ID[num2],max2,stu.ID[num3],max3);
	return 0;
}


struct Student
{
	int num,yuwen,shuxue,sum;
};

void main()
{
	int n,max1=0,max2=0,max3=0,stu1=0,stu2=0,stu3=0;
	struct Student student[100000],*stu;
	scanf("%d",&n);

	for(stu=student;stu<student+n;stu++){
		scanf("%d",&stu->num);
		scanf("%d",&stu->yuwen);
		scanf("%d",&stu->shuxue);
		(stu->sum)=(stu->yuwen)+(stu->shuxue);
		if(stu->sum>=max3){
			if(stu->sum>=max2){
				if(stu->sum>=max1){
					if(stu->sum>max1){
						max3=max2;
						max2=max1;
						max1=stu->sum;
						stu3=stu2;
						stu2=stu1;
						stu1=stu->num;
					}
					else{
						max3=max2;
						max2=max1;
						max1=stu->sum;
						stu3=stu2;
						stu2=stu->num;
					}
				}
				else{
					if(stu->sum>max2){
						max3=max2;
						max2=stu->sum;
						stu3=stu2;
						stu2=stu->num;
					}
					else{
						max3=max2;
						max2=stu->sum;
						stu3=stu->num;
					}
				}
			}
			else{
				if(stu->sum>max3){
					max3=stu->sum;
					stu3=stu->num;
				}
				else max3=stu->sum;
			}
		}
	}
	stu=student;
	printf("%d %d\n",(stu+stu1-1)->num,(stu+stu1-1)->sum);
	printf("%d %d\n",(stu+stu2-1)->num,(stu+stu2-1)->sum);
	printf("%d %d\n",(stu+stu3-1)->num,(stu+stu3-1)->sum);
}


struct student
{
	int num;
	int yu;
	int shu;
	struct student *next;
};
int n;
struct student *creat(void)
{
	int i;
	struct student *head;
	struct student *p1,*p2;
	scanf("%d",&n);
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	head=p1;
	for(i=1;i<=n-1;i++)
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return(head);
}
void main()
{
	int i,j,k=0;
	struct student *head;
	struct student *p1,*p2;
	head=creat();
	p1=head;
	for(j=1;j<=3;j++)
	{
		p1=p2=head;
		for(i=1;i<=n-j;i++)
		{
			if( (p1->yu+p1->shu)>k )
			k=p1->yu+p1->shu;
			p1=p1->next;
		}
		p1=p2=head;
		if((head->yu+head->shu)==k)
		{
			printf("%d %d",p1->num,p1->yu+p1->shu);
			head=head->next;
		}
		else
		{
			for(i=1;;i++)
			{
				if( (p1->yu+p1->shu)==k )
				{
					printf("%d %d\n",p1->num,p1->yu+p1->shu);
					//printf("%d \n",p2->num);
					if((p1->next)!=NULL)
					p2->next=p1->next;
					else p2->next=NULL;
					k=0;
					break;
				}
				p2=p1;
				p1=p1->next;
			}
		}
	}
}


struct student
{
	int num;
	int chinese;
	int maths;
	int sum;
	struct student *next;
};
int m,max[3]={0},t[3]={0};
struct student *head;
struct student *p1,*p2;
struct student *creat(int n)
{
	m=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->chinese,&p1->maths);
	p1->sum=p1->chinese+p1->maths;
	head=NULL;
	while(m<n-1)
	{
		m=m+1;
		if(m==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->chinese,&p1->maths);
		p1->sum=p1->chinese+p1->maths;
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;
	return(head);
}
void main()
{
	int n;
	scanf("%d",&n);
	creat(n);

	struct student *p1;
	p1=head;
     do
	{
		if(p1->sum>max[0])
		{
			max[0]=p1->sum;
			t[0]=p1->num;
		}
		p1=p1->next;
	}	while(p1!=NULL);
	printf("%d %d\n",t[0],max[0]);
	p1=head;
	do
	{
		if(p1->sum>max[1]&&p1->num!=t[0])
		{
			max[1]=p1->sum;
			t[1]=p1->num;
		}
		p1=p1->next;
	}	while(p1!=NULL);
		printf("%d %d\n",t[1],max[1]);
	p1=head;
	do
	{
		if(p1->sum>max[2]&&p1->num!=t[0]&&p1->num!=t[1])
	{
		max[2]=p1->sum;
		t[2]=p1->num;
	}
		p1=p1->next;
	}	while(p1!=NULL);
		printf("%d %d\n",t[2],max[2]);
}


void main()
{
	struct student
	{
		int num;
		int sum;
	}stu[100000],temp;
	int total,i,j,chin,math;
	scanf("%d",&total);
	for(i = 0;i<total;i++)
	{
		scanf("%d %d %d",&stu[i].num,&chin,&math);
		stu[i].sum = chin+math;
	}
	for(i = 2;i<5;i++)
	{
		for(j = total-i;j>=0;j--)
		{
			if(stu[j].sum<stu[j+1].sum)
			{
				temp = stu[j];
				stu[j] = stu[j+1];
				stu[j+1] = temp;
			}
		}
	}
	for(i = 0;i<3;i++)
		printf("%d %d\n",stu[i].num,stu[i].sum);
}


struct student
{
	int no;
	int yuwen;
	int shuxue;
	int total;
};
void main()
{
	int n,i;
	struct student *p,*stu,temp;
	scanf("%d",&n);
	stu=(struct student *)calloc(n,sizeof(struct student));
	for(p=stu;p-stu<n;p++)
	{
		scanf("%d%d%d",&p->no,&p->yuwen,&p->shuxue);
		p->total=p->yuwen+p->shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(p=stu+n-1;p>stu+i;p--)
		{
			if(p->total>(p-1)->total)
			{
				temp=*p;
				*p=*(p-1);
				*(p-1)=temp;
			}
		}
		printf("%d %d\n",p->no,p->total);
	}
	free(stu);
}


struct student {
	int id;
	int chinese;
	int math;
	int total;
};

int main() {
	int i, num;
	struct student stu[100000];
	int max_0 = 0, max_1 = 0, max_2 = 0;
	int max_0_id, max_1_id, max_2_id;

	scanf("%d", &num);
	for (i = 0; i < num; ++i) {
		scanf("%d %d %d", &(stu[i].id), &(stu[i].chinese), &(stu[i].math));
		stu[i].total = stu[i].chinese + stu[i].math;
		if (stu[i].total > max_0) {
			// update second and third highest
			max_2 = max_1;
			max_2_id = max_1_id;
			max_1 = max_0;
			max_1_id = max_0_id;
			max_0 = stu[i].total;
			max_0_id = stu[i].id;
		}
		else if (stu[i].total > max_1) {
			// update third highest
			max_2 = max_1;
			max_2_id = max_1_id;
			max_1 = stu[i].total;
			max_1_id = stu[i].id;
		}
		else if (stu[i].total > max_2) {
			max_2 = stu[i].total;
			max_2_id  = stu[i].id;
		}
	}

	printf("%d %d\n", max_0_id, max_0);
	printf("%d %d\n", max_1_id, max_1);
	printf("%d %d\n", max_2_id, max_2);

	return 0;
}


int main()
{
   struct student
   {
       int ID,Chinese,math,sum;
   }
   stu[100000],temp1,temp2,temp3;
   int n,i,j,k;
   scanf("%d\n",&n);
   for(i=0;i<n;i++)
   {
       scanf("%d%d%d",&stu[i].ID,&stu[i].Chinese,&stu[i].math);
       stu[i].sum=stu[i].Chinese+stu[i].math;
   }
   temp1=stu[0];
   for(i=1;i<n-1;i++)
   if(stu[i].sum>temp1.sum)
   temp1=stu[i];
   printf("%d %d\n",temp1.ID,temp1.sum);
   if(temp1.ID==stu[0].ID) temp2=stu[1];
   else temp2=stu[0];
   for(i=1;i<n-1;i++)
   {if(stu[i].ID==temp1.ID) continue;
    else if(stu[i].sum>temp2.sum) temp2=stu[i];}
    printf("%d %d\n",temp2.ID,temp2.sum);
    for(i=0;i<n;i++)
    if(stu[i].ID==temp1.ID||stu[i].ID==temp2.ID)
    stu[i].sum=0;
    temp3=stu[0];
    for(i=1;i<n-1;i++)
   if(stu[i].sum>temp3.sum)
   temp3=stu[i];
   printf("%d %d\n",temp3.ID,temp3.sum);
   return 0;
}


int main()
{
	struct score
	{
		int n;
		int a;
		int b;
		int c;
	}score[5];
	int i,m;
	scanf("%d",&m);
	score[1].n=0;
	score[1].c=0;
	score[2].n=0;
	score[2].c=0;
	score[3].n=0;
	score[3].c=0;
	for (i=0;i<m;i++)
	{
		scanf("%d%d%d",&score[4].n,&score[4].a,&score[4].b);
		score[4].c=score[4].a+score[4].b;
		if (score[4].c>score[1].c)
		{
			score[3]=score[2];
			score[2]=score[1];
			score[1]=score[4];
		}
		else if (score[4].c>score[2].c)
		{
			score[3]=score[2];
			score[2]=score[4];
		}
		else if (score[4].c>score[3].c)
			score[3]=score[4];
	}
	printf("%d %d\n%d %d\n%d %d\n",score[1].n,score[1].c,score[2].n,score[2].c,score[3].n,score[3].c);
	return 0;
}


struct student
{
    int num;
    int yw;
    int sx;
    int he;
}student[100000];

int main()
{
    int i,n,j,s=0,m;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&student[i].num,&student[i].yw,&student[i].sx);
        student[i].he=student[i].yw+student[i].sx;
    }
    for(i=0;i<n;i++)
    {m=student[0].he;
        for(j=n-1;j>0;j--)
        {

            m=student[j].he>m?student[j].he:m;
        }

        for(j=0;j<n;j++)
        {
            if(student[j].he==m)
            {printf("%d %d\n",student[j].num,student[j].he);
			student[j].he=0;s=s+1;if(s==3)
            {goto guiyi;}}

        }

    }
	guiyi: return 0;

}


struct student
{
int num;
int chn;
int math;
int sum;
}stu[100000];
main()
{
      int n,i;
      scanf("%d",&n);
                     for(i=0;i<n;i++)
                     {scanf("%d%d%d",&stu[i].num,&stu[i].math,&stu[i].chn);
                     stu[i].sum=stu[i].math+stu[i].chn;
                     }
    int j,sum[100000],order[4]={n-1},t,m;
    struct student temp;
    for(j=n-1;j>=n-3;j--)
    {
           for (i=0;i<j;i++)
          {if  (stu[i].sum>=stu[i+1].sum)
               {
                temp=stu[i+1];
                stu[i+1]=stu[i];
                stu[i]=temp;
               }
          }
    }
   printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
   printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
   printf("%d %d\n",stu[n-3].num,stu[n-3].sum);
   getchar();
   getchar();
}


struct Student
{
      int Num;
      int Chinese;
      int Math;
      int Sum;
};
int main()
{
     int n,i,s;
     scanf("%d",&n);
     struct Student stu[n];
     struct Student temp,*p=stu;
     for(i=0;i<n;i++)
     {
     scanf("%d%d%d",&stu[i].Num,&stu[i].Chinese,&stu[i].Math);
     stu[i].Sum=stu[i].Chinese+stu[i].Math;
     }
     if(n==2)
     {
             if(stu[0].Sum >stu[1].Sum)
             temp=stu[0];
             stu[0]=stu[1];
             stu[1]=temp;
             printf("%d %d %d\n",stu[0].Num,stu[0].Chinese,stu[0].Math);
             printf("%d %d %d\n",stu[1].Num,stu[1].Chinese,stu[1].Math);
             }
     else
     {
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         }
         getchar();
         getchar();
         getchar();
         }


struct Student
{
	int number;
	int a;
	int b;
	int c;
};

int main()
{
	int n, i;
	int x, y, z;

	struct Student stu;
	struct Student maxStu, smaxStu, tmaxStu;

	scanf("%d",&n);
	scanf("%d%d%d",&x,&y,&z);
	stu.number = x;
	stu.a = y;
	stu.b = z;
	stu.c = stu.a + stu.b;
	maxStu = stu;
	smaxStu = stu;
	tmaxStu = stu;

	for (i = 0; i < n-1; i++){
		scanf("%d%d%d",&x,&y,&z);
		stu.number = x;
		stu.a = y;
		stu.b = z;
		stu.c = stu.a + stu.b;
		if (stu.c > maxStu.c){
			if (maxStu.c > smaxStu.c){
				if (smaxStu.c > tmaxStu.c){
					tmaxStu = smaxStu;
				}
				smaxStu = maxStu;
			}
			else if (maxStu.c > tmaxStu.c){
					tmaxStu = maxStu;
			}
			maxStu = stu;
		}
		else if (stu.c > smaxStu.c){
			if (smaxStu.c > tmaxStu.c){
				tmaxStu = smaxStu;
			}
			smaxStu = stu;
		}
		else if (stu.c > tmaxStu.c){
			tmaxStu = stu;
		}
	}

	printf ("%d %d\n%d %d\n%d %d",maxStu.number,maxStu.c,smaxStu.number,smaxStu.c,tmaxStu.number,tmaxStu.c);
	return 0;
}


struct student{
		int j;
		int x,y;
		int z;
	}stu[100000];
int main(int argc, char* argv[])
{
	int n,i,a=0,b=0,c=0,a1,b1,c1;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].j,&stu[i].x,&stu[i].y);
		stu[i].z=stu[i].x+stu[i].y;
	}
	for(i=0;i<n;i++)
	{
		if(a<stu[i].z)
		{
			a=stu[i].z;
	    	a1=i;
		}
	}

	for(i=0;i<n;i++)
	{
		if(b<stu[i].z&&i!=a1)
		{
			b=stu[i].z;
	    	b1=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(c<stu[i].z&&i!=a1&&i!=b1)
		{
			c=stu[i].z;
	    	c1=i;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[a1].j,stu[a1].z,stu[b1].j,stu[b1].z,stu[c1].j,stu[c1].z);
	return 0;
}


int n,i,max=0,d,t=0;
struct stu
{
	int id;
	int chi;
	int ma;
	struct stu *next;
} *p1,*p2;

struct stu *creat(void)
{
	struct stu *head;
	scanf("%d",&n);
	p2=p1=(struct stu *)malloc(sizeof(struct stu));
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&p1->id,&p1->chi,&p1->ma);
		if(i==0) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct stu *)malloc(sizeof(struct stu));
	}
	p2->next=NULL;
	return (head);
}

void find (struct stu *head)
{
	while(t<3)
	{
	p1=head;
	for(i=0;i<n;i++)
	{
		if(p1->chi+p1->ma>max)
		{
			max=p1->chi+p1->ma;
			d=p1->id;
		}
		p1=p1->next;
	}
	printf("%d %d\n",d,max);
	t=t+1;	max=0;
	p1=head;
	for(i=0;i<n;i++)
	{
		if(p1->id==d)
		{
			p1->chi=0;
			p1->ma=0;
		}
		p1=p1->next;
	}
	}
}

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


int main(){
	int n,i,j,temp;
	cin>>n;
	struct stu{
		int xuehao[100000];
		int yuwen[100000];
		int shuxue[100000];
		int zongfen[100000];
	}a;
	for(i=0;i<n;i++)
	{
		cin>>a.xuehao[i];
		cin>>a.yuwen[i];
		cin>>a.shuxue[i];
		a.zongfen[i]=a.shuxue[i]+a.yuwen[i];
	}
	for(i=n-1;i>=n-3;i--)
		for(j=i;j>=1;j--)
			if(a.zongfen[j]>a.zongfen[j-1])
			{
				temp=a.zongfen[j-1];
				a.zongfen[j-1]=a.zongfen[j];
				a.zongfen[j]=temp;
				temp=a.xuehao[j-1];
				a.xuehao[j-1]=a.xuehao[j];
				a.xuehao[j]=temp;
			}
	for(i=0;i<=2;i++)
		cout<<a.xuehao[i]<<" "<<a.zongfen[i]<<endl;
	return 0;
}


struct student
{int num;
 int yu;
 int shu;
 int score;
 struct student *next;
};
void main()
{
	int n,i,max;
	struct student *p1,*p2,*head;
	p1=p2=head=NULL;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p1=(struct student *)malloc(sizeof(struct student));

		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);

		p1->score=p1->yu+p1->shu;
	    if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
	}
	    p2->next=NULL;

		for(i=0;i<3;i++)
		{
			p2=p1=head;
			max=p1->score;
			while(p1!=NULL)
			{
				if(p1->score>max){max=p1->score;p2=p1;}
				p1=p1->next;
			}
			printf("%d %d\n",p2->num,max);
            p1=head;
			while(p1->next!=p2)
			{
				p1=p1->next;
			}
			p1->next=p2->next;
		}
}


int main()
{
	struct student{
		long num;
		long chinese;
		long maths;
		long sum;
	}t[100000];
	long n,i,j,k,tmp;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%ld %ld %ld",&t[i].num,&t[i].chinese,&t[i].maths);
	}
    for(i=0;i<n;i++)
	{
		t[i].sum=t[i].chinese+t[i].maths;
	}
	for(i=0;i<3;i++)
	{
        k=i;
		for(j=i+1;j<n;j++)
		{
			if(t[j].sum>t[k].sum)
				k=j;
		}
		tmp=t[i].sum;
		t[i].sum=t[k].sum;
		t[k].sum=tmp;

		tmp=t[i].num;
		t[i].num=t[k].num;
		t[k].num=tmp;
	}
	for(i=0;i<3;i++)
	{
	    printf("%ld %ld\n",t[i].num,t[i].sum);
	}
	return 0;
}


struct Stu{
	int StuNo;
	int Chinese;
	int math;
	int sum;
	struct Stu *next;
};
void main()
{
	struct Stu *p,*head,*tail;
	int n,i,max1,max2,max3,n1,n2,n3;
	scanf("%d",&n);
	head=tail=NULL;
	for(i=1;i<=n;i++)
	{
		p=(struct Stu*)malloc(len);
		scanf("%d%d%d",&p->StuNo,&p->Chinese,&p->math);
		if(head==NULL)
			head=tail=p;
		else
		{
			tail->next=p;
			tail=p;}
		p->sum=p->Chinese+p->math;
	}

	max1=head->sum;n1=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
		if((p->sum)>max1) {max1=p->sum;n1=i;}
	}
    for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
	 if(i==n1) p->sum=0;}

    max2=head->sum;n2=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
		if((p->sum)>max2) {max2=p->sum;n2=i;}
	}
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
	 if(i==n2) p->sum=0;}

	max3=head->sum;n3=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
         if((p->sum)>max3) {max3=p->sum;n3=i;}
	}
	printf("%d %d\n%d %d\n%d %d\n",n1,max1,n2,max2,n3,max3);
}


int main()
{
struct stu
    {
    int num;
    int ch;
    int ma;
    int to;
    };
    int i,j1,j2,j3,k,max;
    struct stu student[100000]={0};
    struct stu temp;
    scanf("%d",&k);
    for(i=0;i<=k-1;i++)
    {
    scanf("%d%d%d",&student[i].num,&student[i].ch,&student[i].ma);
    student[i].to=student[i].ch+student[i].ma;
    }
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j1=i;
                      }
    }
     printf("%d ",student[j1].num);
     printf("%d\n",student[j1].to);
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(i==j1) continue;
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j2=i;
                      }
    }
     printf("%d ",student[j2].num);
     printf("%d\n",student[j2].to);max=0;
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(i==j1||i==j2) continue;
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j3=i;
                      }
    }
     printf("%d ",student[j3].num);
     printf("%d\n",student[j3].to);
return 0;
}


struct student
{
	int num;
	int yu;
	int shu;
	int he;
	struct student *next;
};

struct student *create(int n)
{
	struct student *head,*p1,*p2;
	int i;

	p1=(struct student*)malloc(len);
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	p1->he=p1->yu+p1->shu;
	p1->next=NULL;

	head=p1;
	p2=p1;
	for(i=1;i<=n-1;i++)
	{
		p1=(struct student*)malloc(len);
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p1->he=p1->yu+p1->shu;
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	return head;
}

struct student *max(struct student *head)
{
	struct student *p,*m;
	m=head;
	p=head->next;
	while(p)
	{
		if(p->he>m->he) m=p;
		p=p->next;
	}
	return m;
}

void main()
{
	int n,i;
	struct student *head,*m;
	struct student *create(int n);
	struct student *max(struct student *head);
	scanf("%d",&n);
	head=create(n);
	for(i=1;i<=3;i++)
	{
		m=max(head);
		printf("%d %d\n",m->num,m->he);
		m->he=-1;
	}
}


void main()
{
	int i,n,j,max;
	scanf("%d",&n);
	struct student
	{
		int num;
		int yuwen;
		int shuxue;
		struct student * next;
	};
	struct student *head,*ppre,*p0,*p3;
	struct student *p1,*p2;
	head=p1=p2=(struct student *)malloc(sizeof(struct student));
	for(i=0;i<n;i++)
	{
	     scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
	    p1=(struct student *)malloc(sizeof(struct student));
	    p2->next=p1;
	    p2=p1;
	}
	p2->next=NULL;           /*????*/

	for(j=0;j<3;j++)
	{
		ppre=p1=head;
	    max=p1->yuwen+p1->shuxue;
	    p1=p1->next;
	for(i=0;i<n-j;i++)
	{
           if((p1->yuwen+p1->shuxue)>max)
		   {
			   max=p1->yuwen+p1->shuxue;
			   p0=p1;
			   p3=ppre;
		   }
		   ppre=p1;
	       p1=p1->next;
	}
	printf("%d %d\n",p0->num,max);
	     p3->next=p0->next;
	}
}


struct stu
{
	int id;
	int verbal;
	int math;
	int sum;
};

int main()
{
	struct stu *a,t;
	int n,i,j;
	scanf("%d",&n);
	a=(struct stu *)malloc(n*sizeof(struct stu));
		for (i=0;i<n;i++)
		{
			scanf("%d %d %d",&a[i].id,&a[i].verbal,&a[i].math);
			a[i].sum=a[i].verbal+a[i].math;
		}
		for (j=0;j<3;j++)
			for (i=n;i>j;i--)
				if (a[i].sum>a[i-1].sum)
				{
					t=a[i];
					a[i]=a[i-1];
					a[i-1]=t;
				}
		for (i=0;i<3;i++)
		printf("%d %d\n",a[i].id,a[i].sum);

	return 0;

}


struct score
{
 long num;
 int yu;
 int shu;
 int sum;
 }stu[100000];
void main()
{
  long  i,n,j,k;
   int t;
  scanf("%ld",&n);
 for(i=0;i<n;i++)
 {
   scanf("%ld%d%d",&stu[i].num,&stu[i].yu,&stu[i].shu);
   stu[i].sum=stu[i].yu+stu[i].shu;
 }
 for(i=0;i<3;i++)
{
  for(j=0;j<n-i-1;j++)
    if(stu[j].sum>stu[j+1].sum)
       {
         t=stu[j].sum;
         stu[j].sum=stu[j+1].sum;
         stu[j+1].sum=t;
        }
 }
for(k=n-1;k>n-4;k--)
{
  if(k!=n-1&&stu[k].sum==stu[k+1].sum)continue;
    for(i=0;i<n;i++)
   {
	   if(stu[k].sum==(stu[i].yu+stu[i].shu))
        { printf("%ld %ld\n",stu[i].num,stu[k].sum);
       if(k==n-3)break;}
   }
}
 }


int main()
{
	struct student
	{
		int num;
		int chinese;
		int math;
		int sum;
	}m[4],t;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=3;i++)
		m[i].sum=-1;
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&t.num,&t.chinese,&t.math);
		t.sum=t.chinese+t.math;
		if(t.sum>m[1].sum)
		{
			m[3]=m[2];
			m[2]=m[1];
			m[1]=t;
		}
		else
			if(t.sum>m[2].sum)
			{
				m[3]=m[2];
				m[2]=t;
			}
			else
				if(t.sum>m[3].sum)
					m[3]=t;
	}
	for(i=1;i<=3;i++)
		printf("%d %d\n",m[i].num,m[i].sum);
}


struct a
{
	char No[20];
	int y;
	int s;
	struct a* next;
};
int n;
struct a* creat(void)
{
	struct a *p1,*p2,*head;
	int i;
	scanf("%d\n",&n);
	p1=p2=(struct a* )malloc(LEN);
	head=NULL;
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d",p1->No,&p1->y,&p1->s);
		if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct a* )malloc(LEN);
	}
	p2->next=NULL;
	return(head);
}

int main()
{
	struct a *head,*p1,*p2,*p;
	int i,j,k,m1,m2;
	char r[10];
	head=creat();
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d\n",r,j);
	for(p1=head;p1!=NULL;)
	{
		p2=p1;p1=p1->next;
		if(p1==p){p2->next=p1->next;break;}
		else if(p2==p){head=p1->next;break;}
	}
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d\n",r,j);
	for(p1=head;p1!=NULL;)
	{
		p2=p1;p1=p1->next;
		if(p1==p){p2->next=p1->next;break;}
		else if(p2==p){head=p1->next;break;}
	}
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d",r,j);
}


struct student
{
	int ID;
	int chinese;
	int math;
	int total;
}st[4],temp;
int main()
{
	int n,cnt=3;
	cin>>n;
	for(int i=0;i<3;i++)
	{
	  cin>>st[i].ID>>st[i].chinese>>st[i].math;
	  st[i].total=st[i].chinese+st[i].math;
	}
	do{
		cin>>st[3].ID>>st[3].chinese>>st[3].math;
	    st[3].total=st[3].chinese+st[3].math;
		cnt++;
		 for(int i=1;i<4;i++)
		 {
			 for(int j=0;j<4-i;j++)
			 {
			 if(st[j+1].total>st[j].total)
			 {
				 temp=st[j];
				 st[j]=st[j+1];
				 st[j+1]=temp;
			 }
			 }
		 }}while(cnt<n);
    for(int i=0;i<3;i++)
	{
		cout<<st[i].ID<<" "<<st[i].total<<endl;
	}
	return 0;
}


struct Student
{
long id;
int chn;
int mth;
int total;
struct Student *next;
};

struct Student * insert(struct Student *head,struct Student *stu)
{
int j=0;
struct Student *p0,*p1,*p2;
p1=head;
p0=stu;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{
while((p0->total<=p1->total)&&(p1->next!=NULL)&&j<4)
{p2=p1;p1=p1->next;j++;}
if(p0->total>p1->total)
{
if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{p1->next=p0;p0->next=NULL;}
}
return(head);
}

void main()
{
struct Student *p1,*head,*stu;
long int i,n;
scanf("%ld",&n);

p1=head=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&head->id,&head->chn,&head->mth);
head->total=head->chn + head->mth;
head->next=NULL;
for(i=1;i<n;i++)
{
stu=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&stu->id,&stu->chn,&stu->mth);
stu->total=stu->chn + stu->mth;
head=insert(head,stu);
}
p1=head;
for(i=0;i<3;i++)
{printf("%d %d\n",p1->id,p1->total);p1=p1->next;}
}


void main()
{
	struct student
	{
		int num,sum;
	} stu[100000];
	int n,i,j,t,chi,math;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].num,&chi,&math);
		stu[i].sum=chi+math;
	}
	for (i=0;i<3;i++)
	{
		for (j=n-1;j>i;j--)
		{
			if (stu[j].sum>stu[j-1].sum)
			{
				t=stu[j].sum;
				stu[j].sum=stu[j-1].sum;
				stu[j-1].sum=t;
				t=stu[j].num;
				stu[j].num=stu[j-1].num;
				stu[j-1].num=t;
			}
		}
	}
	printf("%d %d\n",stu[0].num,stu[0].sum);
	printf("%d %d\n",stu[1].num,stu[1].sum);
	printf("%d %d",stu[2].num,stu[2].sum);
}


int main()
{
struct student
	{
		int num;
		int yuwen;
		int math;
		int zong;
	};
struct student stu[100000];
struct student *p,*p1,*p2,*p3,*p4;
int n;
scanf("%d",&n);
for(p=stu;p<stu+n;p++)
	{
		scanf("%d",&p->num);
		scanf("%d",&p->yuwen);
		scanf("%d",&p->math);
	}
for(p=stu;p<stu+n;p++)
	{
		(p->zong)=(p->yuwen)+(p->math);
	}
p1=&stu[0];
p2=&stu[1];
p3=&stu[2];
p4=p1;
if(p2->zong>p1->zong)
{
	p4=p1;
	p1=p2;
	p2=p4;
}
else
p1=p1;
if(p3->zong>p1->zong)
{
	p4=p1;
	p1=p3;
	p3=p4;
}
else
p1=p1;
if(p3->zong>p2->zong)
{
p4=p2;
p2=p3;
p3=p4;
}
else
p1=p1;

for(p=stu+3;p<stu+n;p++)
{
if((p->zong)>(p1->zong))
{
	p3=p2;
	p2=p1;
	p1=p;
}
else if(p->zong>p2->zong)
{
	p3=p2;
	p2=p;
}
else if(p->zong>p3->zong)
{
p3=p;
}
else
p1=p1;
}
printf("%d %d\n",p1->num,p1->zong);
printf("%d %d\n",p2->num,p2->zong);
printf("%d %d",p3->num,p3->zong);
return 0;
}


int main()
{
	struct student
	{int num;
	 int chi;
	 int math;
	}stu[100000];

	int n,i,j,mid;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].num,&stu[i].chi,&stu[i].math);
	}

	for(i=0;i<3;i++){
		for(j=n-1;j>0;j--){
			if(stu[j].math+stu[j].chi>stu[j-1].chi+stu[j-1].math){
				mid=stu[j].num;
				stu[j].num=stu[j-1].num;
				stu[j-1].num=mid;

				mid=stu[j].chi;
				stu[j].chi=stu[j-1].chi;
				stu[j-1].chi=mid;

				mid=stu[j].math;
				stu[j].math=stu[j-1].math;
				stu[j-1].math=mid;
			}
		}
	}

    for(i=0;i<3;i++){
		printf("%d %d\n",stu[i].num,stu[i].math+stu[i].chi);
	}

	return 0;
}


int main(){
	int num;
	cin>>num;
	struct {
		int No;
		int Chinese;
		int Math;
		int Sum;  //??
	}student[100000],t;  //??????
	int i,j;
	for(i=0;i<num;i++){
		cin>>student[i].No>>student[i].Chinese>>student[i].Math;
	    student[i].Sum=student[i].Math+student[i].Chinese;
	}
	for(i=0;i<3;i++)  //????
		for(j=0;j<num-1-i;j++){
			if(student[j].Sum>=student[j+1].Sum){
				t=student[j];
				student[j]=student[j+1];
				student[j+1]=t;
			}
		}
	for(i=0;i<3;i++)
		cout<<student[num-i-1].No<<" "<<student[num-i-1].Sum<<endl;  //?????
	return 0;
}


struct student
{long num;
int yuwen;
int shuxue;
int sum;
struct student *next;
};
int n;
void main()
{
	struct student *creat(void);
	void shuchu(struct student *head);
	int i;
	struct student *head;
	scanf("%d",&n);
	head=creat();
	for(i=0;i<3;i++)
		shuchu(head);
}
struct student *creat(void)
{
	int i,k=0;
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(len);/*???????*/
	scanf("%ld%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
	p1->sum=p1->shuxue+p1->yuwen;
	head=NULL;
	for(i=0;i<n;i++)
	{
		k++;
		if(k==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(len);
		scanf("%ld%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
		p1->sum=p1->shuxue+p1->yuwen;
	}
	p2->next=NULL;
	return(head);
}
void shuchu(struct student *head)
{
	struct student *p;
	int max,i;
	p=head;
	max=p->sum;
	for(i=0;i<n;i++)
	{
		if(p->sum>max)
			max=p->sum;
		p=p->next;
	}
		p=head;
		for(i=0;i<n;i++)
		{
			if(p->sum==max)
			{
				printf("%ld %d\n",p->num,p->sum);
				p->sum=0;
				break;
			}
			p=p->next;
		}
}


struct student
{
	int stuID;
	int yuwen;
	int shuxue;
	int zongfen;
}stu[100000];
int main()
{
	int i,n,j,x,str;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].stuID,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(stu[j].zongfen>stu[j+1].zongfen||((stu[j].zongfen==stu[j+1].zongfen)&&(stu[j].stuID<stu[j+1].stuID)))
			{
				x=stu[j].zongfen;
				stu[j].zongfen=stu[j+1].zongfen;
				stu[j+1].zongfen=x;
				str=stu[j].stuID;
				stu[j].stuID=stu[j+1].stuID;
				stu[j+1].stuID=str;
			}
		}
			printf("%d %d\n",stu[n-1-i].stuID,stu[n-1-i].zongfen);
	}
	return 0;
}


struct score
{int num;
 int yuwen;
 int shuxue;
 int total;
 struct score*next;
};
int n;

struct score*creat()
{struct score*p1,*p2,*head;
 head=p2=(struct score*)malloc(len);
 scanf("%d%d%d",&p2->num,&p2->yuwen,&p2->shuxue);
 p2->total=p2->shuxue+p2->yuwen;
 n--;
 while(n--)
	{p1=(struct score*)malloc(len);
     scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
     p1->total=p1->shuxue+p1->yuwen;
	 p2->next=p1;
	 p2=p1;
	}
 p2->next=NULL;
 return head;
}

void search(struct score*head)
{struct score*p;int i,max;
 for(i=0;i<3;i++)
	{max=0;
	 p=head;
	  while(p!=NULL)
		{
		if(p->total>max)max=p->total;
		p=p->next;
		}
     p=head;
	 while(p!=NULL)
	 {if(p->total==max)
		{printf("%d %d\n",p->num,p->total);
		 p->total=0;
		 break;
		}
	     p=p->next;
	 }
	}
}

main()
{scanf("%d",&n);
 struct score*head;
 head=creat();
search(head);
}


struct student{
		int xuehao;
		int yuwen;
		int shuxue;
		int mark;
		struct student *next;
};
int n;
struct student *creat(int max)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->xuehao,&p1->yuwen,&p1->shuxue);
	head=p1;
	while(n<max-1)
	{
		n++;
		if(n!=1)p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->xuehao,&p1->yuwen,&p1->shuxue);

	}
	p2->next=p1;
	p1->next=0;
	return head;
}
void main()
{
	int max,i;
	struct student *table;
	scanf("%d",&max);
	table=creat(max);
	for(i=0;i<3;i++)
	{
		int mmax=0;
		int mark=0;
		struct student *p;
		p=table;

		do{
		if(p->shuxue+p->yuwen>mmax&&p->mark!=-1){mark++;p->mark=mark;mmax=p->shuxue+p->yuwen;}
		p=p->next;
		}while(p!=0);
		p=table;
		do{
			if(p->mark==mark){
				printf("%d %d\n",p->xuehao,p->shuxue+p->yuwen);
			p->mark=-1;}
					p=p->next;
		}while(p!=0);

	}
}


 int main()
{
   struct gpa
    {
     int num;
     int math;
     int chin;
     int total;
    }
    STUDENT_NUM[100000], first,second,third;

  int num,math,chin;
  long n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d",&num);
    scanf("%d",&math);
    scanf("%d",&chin);
    STUDENT_NUM[i].num=num;
    STUDENT_NUM[i].math=math;
    STUDENT_NUM[i].chin=chin;
    STUDENT_NUM[i].total=math+chin;
  }

    first.num=0;
    first.total=0;
    second.num=0;
    second.total=0;
    third.num=0;
    third.total=0;

    for(i=1;i<=n;i++)
    {
           if(STUDENT_NUM[i].total>first.total)
           {
           first.num=STUDENT_NUM[i].num;
           first.total=STUDENT_NUM[i].total;
           }
    }

          for(i=1;i<=n;i++)
            {
               if(STUDENT_NUM[i].num==first.num)
               {STUDENT_NUM[i].total=0;}
            }
    for(i=1;i<=n;i++)
    {
        if(STUDENT_NUM[i].total>second.total)
        {
           second.num=STUDENT_NUM[i].num;
           second.total=STUDENT_NUM[i].total;
        }
    }

            for(i=1;i<=n;i++)
            {
                if (STUDENT_NUM[i].num==second.num)
                {STUDENT_NUM[i].total=0;}
            }
    for(i=1;i<=n;i++)
    {
       if(STUDENT_NUM[i].total>third.total)
       {
           third.num=STUDENT_NUM[i].num;
           third.total=STUDENT_NUM[i].total;
       }
    }

   printf("%d %d\n",first.num,first.total);
   printf("%d %d\n",second.num,second.total);
   printf("%d %d\n",third.num,third.total);
    getchar();
    getchar();
    getchar();
    getchar();
}


struct student
{
	int id;
	int cs;
	int ms;
	int s;
	struct student *next;
};
void main()
{
	int n,i,m=0;
	scanf("%d",&n);
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
	p1->s=p1->cs+p1->ms;
	head=NULL;
	while(p1->id!=n)
	{
		m=m+1;
		if(m==1) head=p1;
		else
		p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
		p1->s=p1->cs+p1->ms;
	}
p2->next=p1;
p2=p1;
	p2->next=NULL;
	for(i=0;i<3;i++)
	{
		p1=p2=head;
		do
		{
			p2=p2->next;
			if(p1->s<p2->s)
				p1=p2;
		}while(p2->next!=NULL);
		printf("%d %d\n",p1->id,p1->s);
		p1->s=-1;
	}
}


	struct student
	{
	int xuehao;
	int shuxue;
	int yuwen;
	int zongfen;
	};

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

    struct student stu[100001];
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d", &stu[i].xuehao,&stu[i].shuxue,&stu[i].yuwen);
		stu[i].zongfen=stu[i].shuxue+stu[i].yuwen;
	}
	for(i=1;i<4;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(stu[j].zongfen>=stu[j+1].zongfen)
			{
				stu[100000]=stu[j+1];
				stu[j+1]=stu[j];
				stu[j]=stu[100000];
			}
		}
	}
	for(i=n-1;i>n-4;i--)
	{
       printf("%d %d\n", stu[i].xuehao,stu[i].zongfen);
	}

	return 0;
}


struct Student
{int ID;
int chi;
int math;
int total;
};
int main()
{
struct Student stu[100000];
struct Student temp;
int i,n,j,m;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&stu[i].ID,&stu[i].chi,&stu[i].math);
stu[i].total=stu[i].chi+stu[i].math;
}
for(j=1;j<4;j++){
 for(m=0;m<n-j;m++){
  if(stu[m].total>=stu[m+1].total){
  temp=stu[m];
  stu[m]=stu[m+1];
  stu[m+1]=temp;
  }
 }
       }
for(i=n-1;i>n-4;i--)
printf("%d %d\n",stu[i].ID,stu[i].total);
return 0;
}


struct student
{
	int num;
	float chinese;
	float math;
	float sum;
};
void main()
{
     int n,i;
	 struct student *pt,*p,temp;
	 scanf("%d",&n);
     pt=(struct student *)malloc(n*LEN);
     for(p=pt;p<pt+n;p++)
	 {
		 scanf("%d%f%f",&p->num,&p->chinese,&p->math);
		 p->sum=p->chinese+p->math;
	 }

	 for(i=0;i<3;i++)
	 {
		 for(p=pt;p<pt+n-1-i;p++)
		 {
			 if(p->sum>=(p+1)->sum)
			 {temp=*p;*p=*(p+1);*(p+1)=temp;}
		 }
	 }
	 for(p=pt+n-1;p>pt+n-4;p--)
	 {
		 printf("%d %g\n",p->num,p->sum);
	 }
}


int main()
{
	struct student
	{
		int num;
		int math;
		int chinese;
		int sum;
	}a[100000];
	int n,i,j,temp;
	char c[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i].num,&a[i].math,&a[i].chinese);
		a[i].sum=a[i].math+a[i].chinese;
	}
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i].sum<a[j].sum)
			{
				temp=a[i].sum,a[i].sum=a[j].sum,a[j].sum=temp;
				temp=a[i].num,a[i].num=a[j].num,a[j].num=temp;
			}
		}
		printf("%d %d\n",a[i].num,a[i].sum);
	}
	return 0;
}


struct student
{
int id;
int ch;
int math;
};
void main()
{
struct student stu[100000];
int n,i,j,sum=0,id1=0,flag=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&stu[i].id,&stu[i].ch,&stu[i].math);
for(i=0;i<3;i++)
{
for(j=0;j<n;j++)
{
if((stu[j].ch+stu[j].math)>sum)
{sum=stu[j].ch+stu[j].math;
id1=stu[j].id;
flag=j;}
}
printf("%d %d\n",id1,sum);
sum=0;
id1=0;
stu[flag].ch=0;
stu[flag].math=0;
flag=0;
}
}


int main()
{
	struct{
		int n;
		int a;
		int b;
	}n[100000];
	int m,i,sum[100000],first,second,third,d,e,f;
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&n[i].n);
		scanf("%d",&n[i].a);
		scanf("%d",&n[i].b);
		sum[i]=n[i].a+n[i].b;
	}
	if(sum[0]>sum[1]&&sum[0]>sum[2]&&sum[1]>sum[2])
	{
		first=sum[0];
		second=sum[1];
		third=sum[2];
		d=1;
		e=2;
		f=3;
	}
	else if (sum[0]>sum[1]&&sum[1]<sum[2]&&sum[0]>sum[2])
	{
		first=sum[0];
		second=sum[2];
		third=sum[1];
		d=1;
		e=3;
		f=2;
	}
	else if (sum[0]<sum[1]&&sum[1]>sum[2]&&sum[0]>sum[2])
	{
		first=sum[1];
		second=sum[0];
		third=sum[2];
		d=2;
		e=1;
		f=3;
	}
    else if (sum[0]<sum[1]&&sum[1]>sum[2]&&sum[0]<sum[2])
	{
		first=sum[1];
		second=sum[2];
		third=sum[0];
		d=2;
		e=3;
		f=1;
	}
    else if (sum[0]<sum[1]&&sum[1]<sum[2]&&sum[0]<sum[2])
	{
		first=sum[2];
		second=sum[1];
		third=sum[0];
		d=3;
		e=2;
		f=1;
	}
    else if (sum[0]>sum[1]&&sum[1]<sum[2]&&sum[0]<sum[2])
	{
		first=sum[2];
		second=sum[0];
		third=sum[1];
		d=3;
		e=1;
		f=2;
	}
	for(i=3;i<m;i++)
	{
		if(sum[i]>first)
		{
			third=second;
			second=first;
			first=sum[i];
			f=e;
			e=d;
			d=i+1;
		}
		else if (sum[i]<=first&&sum[i]>second)
		{
			third=second;
			second=sum[i];
			f=e;
			e=i+1;
		}
		else if (sum[i]<=second&&sum[i]>third)
		{
			third=sum[i];
			f=i+1;
		}
	}
	printf("%d %d\n",d,first);
	printf("%d %d\n",e,second);
	printf("%d %d\n",f,third);
	return 0;
}


int main()
{
	int num[3], chinese[100000], math[100000], sum[100000];
	int m, i, n;
	cin >> n;
	for (i = 0; i < n; i ++)
	{
		cin >> m >> chinese[i] >> math[i];
		sum[i] = chinese[i] + math[i];
	}
	int largest = 0;
	for (i = 0; i < 3; i ++)
	{
		largest = 0;
		for (int j = 0; j < n; j ++)
			if (sum[j] > largest)
			{
				largest = sum[j];
				num[i] = j;
			}
		cout << num[i] + 1 << " " << sum[num[i]] << endl;
		sum[num[i]] = 0;
	}
	return 0;
}


struct stu
	{
		int num;
		int yuwen;
		int shuxue;
		int sum;
	}score[100000];
int main()
{
	int n,i,a,b,c,a1,b1,c1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&score[i].num,&score[i].yuwen,&score[i].shuxue);
		score[i].sum=score[i].shuxue+score[i].yuwen;
	}a=0;
	b=0;
	c=0;
	a1=0;
	b1=0;
	c1=0;
	for(i=0;i<n;i++){
		if(score[i].sum>a){
		    c=b;
			b=a;
			a=score[i].sum;
			c1=b1;
			b1=a1;
			a1=score[i].num;
		}else if(score[i].sum>b){
			c=b;
			b=score[i].sum;
			c1=b1;
			b1=score[i].num;
		}else if(score[i].sum>c){
			c=score[i].sum;
			c1=score[i].num;
		}
	}printf("%d %d\n%d %d\n%d %d",a1,a,b1,b,c1,c);
	return 0;
}


struct stu
{
 int a;
 int b;
 int c;
 struct stu *next;
};
void main()
{
 int i,j,n,t,sum[100000];
 struct stu *head,*p1,*p2;
 scanf("%d",&n);
 p1=(struct stu*)malloc(sizeof(struct stu));
     scanf("%d%d%d",&(p1->a),&(p1->b),&(p1->c));
     sum[0]=p1->b+p1->c;
     head=p1;
	 p2=p1;
 for(i=1;i<n;i++)
  {
     p1=(struct stu*)malloc(sizeof(struct stu));
     p2->next=p1;
     scanf("%d%d%d",&(p1->a),&(p1->b),&(p1->c));
     sum[i]=p1->b+p1->c;
	 p2=p1;
   }
   p2->next=NULL;
  for(i=0;i<3;i++)
   for(j=i+1;j<n;j++)
    if(sum[i]<sum[j])
     {
      t=sum[i];
      sum[i]=sum[j];
      sum[j]=t;
	}
  for(i=0;i<3;i++)
  {
   p1=head;
   while(p1->b+p1->c!=sum[i]&&p1)
    {
     p1=p1->next;
    }
   if(p1)
   {
   printf("%d %d\n",p1->a,sum[i]);
   p1->b=0;
   p1->c=0;
   }
  }
}


struct student
{
	int num;
	int chinese;
	int math;
	int sum;
};
void main()
{
	int n,i,j;
	struct student stu[100000];
	struct student stud;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].num,&stu[i].chinese,&stu[i].math);
		stu[i].sum=stu[i].chinese+stu[i].math;
	}
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(stu[i].sum<stu[j].sum)
			{
				stud=stu[i];
				stu[i]=stu[j];
				stu[j]=stud;
			}
		}
	}
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",stu[i].num,stu[i].sum);
	}
}


int main()
{
	int n;
	scanf("%d",&n);
	struct student{
		int num;
		int chi;
		int math;
		int sum;
	};
	struct student*fig;
	fig=(struct student*)malloc(sizeof(student)*n);
	int i,a=0,b=0,c=0,numa=0,numb=0,numc=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&(fig+i)->num,&(fig+i)->chi,&(fig+i)->math);
		(fig+i)->sum=(fig+i)->chi+(fig+i)->math;
		if((fig+i)->sum>a)
		{
			c=b;
			numc=numb;
			b=a;
			numb=numa;
			a=(fig+i)->sum;
			numa=(fig+i)->num;
		}
		else if((fig+i)->sum>b)
		{
			c=b;
			numc=numb;
			b=(fig+i)->sum;
			numb=(fig+i)->num;
		}
		else if((fig+i)->sum>c)
		{
			c=(fig+i)->sum;
			numc=(fig+i)->num;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",numa,a,numb,b,numc,c);
	return 0;

}


int main()
{
	int n,i;
	int fir=0,sec=0,thi=0;
	int fir_n=0,sec_n=0,thi_n=0;
	struct
	{
		int num;
		int ma;
		int cn;
		int score;
	}s;

	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&s.num,&s.ma,&s.cn);
		s.score=s.ma+s.cn;

		if(s.score>fir)
		{
			thi=sec;
			thi_n=sec_n;
			sec=fir;
			sec_n=fir_n;
			fir=s.score;
			fir_n=s.num;
		}

       else if(s.score>sec)
		{
			thi=sec;
			thi_n=sec_n;
			sec=s.score;
			sec_n=s.num;
		}
	   else if(s.score>thi)
		{
			thi=s.score;
			thi_n=s.num;
		}
	}

	printf("%d %d\n",fir_n,fir);
	printf("%d %d\n",sec_n,sec);
	printf("%d %d\n",thi_n,thi);

	return 0;
}


struct student{
  int num;
  int chin;
  int math;
  int sum;
}tem_stu;
int main()
{
 int n,i;
 scanf("%d",&n);
 struct student *stu;
 stu=(struct student*)malloc(n*sizeof(int)*4);
 for(i=0;i<n;i++){
  scanf("%d%d%d",&stu[i].num,&stu[i].chin,&stu[i].math);
  stu[i].sum=stu[i].chin+stu[i].math;
 }
 int j;
 for(j=1;j<4;j++){
  for(i=0;i<n-j;i++){
   if(stu[i].sum>=stu[i+1].sum){
         tem_stu=stu[i+1];
         stu[i+1]=stu[i];
	stu[i]=tem_stu;
   }
  }
 }

 printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
 printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
 printf("%d %d\n",stu[n-3].num,stu[n-3].sum);
 free(stu);
 return 0;
}


int pfCompare( const void*elem1, const void*elem2)
{
    int *p1,*p2;
    p1=(int*)elem1;
    p2=(int*)elem2;
    return (*p2)-(*p1);
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],b[n],c[n],d[n],e[n];
    int i;
    for(i=0;i<n;i++)
    {
                    scanf("%d %d %d",&a[i],&b[i],&c[i]);
                    d[i]=b[i]+c[i];
                    e[i]=d[i];
    }
    qsort(e,n,4,pfCompare);
    for(int k=0;k<3;k++)
    {
            for(i=0;i<n;i++)
            if(d[i]==e[k])
            {printf("%d %d\n",a[i],d[i]);
            d[i]=0;
            break;
            }
    }
    getchar();getchar();
}


struct stu
{
	int num;
	struct stu *next;
};

void main()
{
	int i=0,n,a,b,score,first=0,second=0,third=0;
	struct stu *head,*p,*p1,*p2,*p3;
	scanf("%d",&n);
	head=p=(struct stu *)malloc(sizeof(struct stu));
	while(i++<n)
	{
		scanf("%d %d %d",&(*p).num,&a,&b);
		score=a+b;
if(score>first)
		{
			third=second;second=first;first=score;
			p3=p2;p2=p1;p1=p;
		}
		else if(score>second){third=second;second=score;p3=p2;p2=p;}
		else if(score>third){third=score;p3=p;}
		p=(*p).next=(struct stu *)malloc(sizeof(struct stu));
	}
	printf("%d %d\n%d %d\n%d %d\n",(*p1).num,first,(*p2).num,second,(*p3).num,third);
}


void main()
{
	int n,i;
	int diyi,dier,disan;
	diyi=0;
	dier=0;
	disan=0;
	struct student
	{
		int num;
		int yuwen;
		int shuxue;
		int sum;
	}stu[99999];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].sum=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].sum>stu[diyi].sum){diyi=i;}
	}
	for(i=0;i<n;i++)
	{
		while(i!=diyi)
		{
			dier=i;
			break;
		}
		break;
	}
    for(i=0;i<n;i++)
	{
		if(i!=diyi)
		{
		if(stu[i].sum>stu[dier].sum){dier=i;}
		}
	}
	for(i=0;i<n;i++)
	{
		while(i!=diyi && i!=dier)
		{
			disan=i;
			break;
		}
		break;
	}
	for(i=0;i<n;i++)
	{
		if(i!=diyi && i!=dier)
		{
		if(stu[i].sum>stu[disan].sum){disan=i;}
		}
	}
	printf("%d %d\n",diyi+1,stu[diyi].sum);
	printf("%d %d\n",dier+1,stu[dier].sum);
	printf("%d %d\n",disan+1,stu[disan].sum);
}


struct grade
{
	char ID[20];
	int math,cn;
};

int main(){
	int n,i,j,max,m;
	int *s;
struct grade stu[100000];
	scanf("%d",&n);
	s=(int*)malloc(n*sizeof(int));
	if(n==1){
		scanf("%s %d %d",stu[0].ID,&stu[0].math,&stu[0].cn);
		printf("%s %d",stu[0].ID,stu[0].math+stu[0].cn);
	}
	else if(n==2){
		scanf("%s %d %d",stu[0].ID,&stu[0].math,&stu[0].cn);
		scanf("%s %d %d",stu[1].ID,&stu[1].math,&stu[1].cn);
		if(stu[0].math+stu[0].cn>stu[1].math+stu[1].cn){
			printf("%s %d\n",stu[0].ID,stu[0].math+stu[0].cn);
			printf("%s %d\n",stu[1].ID,stu[1].math+stu[1].cn);
		}else{
			printf("%s %d\n",stu[0].ID,stu[0].math+stu[0].cn);
			printf("%s %d\n",stu[1].ID,stu[1].math+stu[1].cn);
		}
	}
	else if(n>=2){
		for(i=0;i<n;i++){
			scanf("%s %d %d",stu[i].ID,&stu[i].math,&stu[i].cn);
			s[i]=stu[i].math+stu[i].cn;
		}
		for(i=1;i<4;i++){
			max=s[0];
			for(j=1;j<n;j++){
				if(s[j]>max){
					max=s[j];
					m=j;
				}
			}
			printf("%s %d\n",stu[m].ID,max);
			s[m]=0;
		}
	}
	return 0;
}


int main()
{
	struct
	{
		int number;
		float score1;
		float score2;
		float score3;

	}stu[100000],temp;
	int n,i,j;
	cin>>n;
	for(i=0;i<=n-1;i++)
		{
		cin>>stu[i].number>>stu[i].score1>>stu[i].score2;
		stu[i].score3=stu[i].score2+stu[i].score1;
		}
	for(i=n-1;i>=n-3;i--)
		for(j=n-1;j>=n-i;j--)
			if(stu[j-1].score3<stu[j].score3)
			{
				temp=stu[j];
				stu[j]=stu[j-1];
				stu[j-1]=temp;
			}
	cout<<stu[0].number<<" "<<stu[0].score3<<endl;
	cout<<stu[1].number<<" "<<stu[1].score3<<endl;
	cout<<stu[2].number<<" "<<stu[2].score3;
	return 0;
}


struct student
{
    int num;
    int yw;
    int sx;
};
int main()
{
    int n,i,x=0,y=0,z=0;
    scanf("%d",&n);
    struct student a[n];
    int b[n];
    for(i=0;i<n;i++)
        {
            scanf("%d%d%d",&a[i].num,&a[i].yw,&a[i].sx);
            b[i]=a[i].yw+a[i].sx;
        }
    for(i=1;i<n;i++)
        {
            if(b[x]<b[i])
                x=i;
        }
    printf("%d %d\n",a[x].num,b[x]);
    for(i=1;i<n;i++)
        {
            if(i==x) continue;
            if(b[y]<b[i])
                y=i;
        }
    printf("%d %d\n",a[y].num,b[y]);
    for(i=1;i<n;i++)
        {
            if(i==x) continue;
            if(i==y) continue;
            if(b[z]<b[i])
                z=i;
        }
    printf("%d %d\n",a[z].num,b[z]);
    getchar();
    getchar();
}


void main()
{
	struct student
	{
	char a[6];
	int c;
	int m;
	int s;
	struct student * next;
	};
	struct student * head;
	struct student * p1,* p2;
	struct student first={"",0,0,0,0};
	struct student second={"",0,0,0,0};
	struct student third={"",0,0,0,0};
	int n,i,j;
	char ch;
	scanf("%d",&n);
	p1=p2=(struct student * )malloc(LEN);
	for(j=0;j<6;j=j+1)
		p1->a[j]='\0';
	getchar();
	for(j=0;(ch=getchar())!=' ';j=j+1)
		p1->a[j]=ch;
	scanf("%d%d",&p1->c,&p1->m);
	p1->s=p1->c+p1->m;
	head=0;
	for(i=1;i<n;i=i+1)
	{
		if(i==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student * )malloc(LEN);
		for(j=0;j<6;j=j+1)
			p1->a[j]='\0';
		getchar();
		for(j=0;(ch=getchar())!=' ';j=j+1)
			p1->a[j]=ch;
		scanf("%d%d",&p1->c,&p1->m);
		p1->s=p1->c+p1->m;
	}
	p2->next=0;
	for(p1=head;p1!=0;p1=p1->next)
	{
		if(p1->s>first.s)
		{
			third=second;
			second=first;
			first=* p1;
		}
		else if(p1->s>second.s)
		{
			third=second;
			second=* p1;
		}
		else if(p1->s>third.s)
		{
			third=* p1;
		}
		else
			continue;
	}
	printf("%s %d\n",first.a,first.s);
	printf("%s %d\n",second.a,second.s);
	printf("%s %d\n",third.a,third.s);
}


int main()
{
	int n,i,j,k,l,sum[100001],temp=0;
	cin>>n;
	struct student
	{
		int ID;
		int chinese;
		int math;
	}person[100001];//???????,??ID?????????
	for(i=1;i<=n;i++)
	{
		cin>>person[i].ID>>person[i].chinese>>person[i].math;
		sum[i]=person[i].chinese+person[i].math;//????
	}
	for(i=1;i<=n;i++)
	{
		if(sum[i]>temp)
		{
			temp=sum[i];
			j=i;//?????
		}
	}
	temp=0;
	for(i=1;i<=n;i++)
	{
		if(sum[i]>temp&&i!=j)//???
		{
			temp=sum[i];
			k=i;
		}
	}
temp=0;
	for(i=1;i<=n;i++)
	{
		if(sum[i]>temp&&i!=j&&i!=k)//???
		{
			temp=sum[i];
			l=i;
		}
	}
	cout<<person[j].ID<<" "<<sum[j]<<endl;
	cout<<person[k].ID<<" "<<sum[k]<<endl;
	cout<<person[l].ID<<" "<<sum[l]<<endl;
	return 0;
}


void main()
{
	int n,i,j,t;
	struct score
	{int num;
	 int verbal;
	 int math;
	 int sum;
	};
	struct score a[4];
	scanf("%d",&n);
	for(i=0;i<=2;i++)
	{
		scanf("%d%d%d",&a[i].num,&a[i].verbal,&a[i].math);
		a[i].sum=a[i].verbal+a[i].math;
	}
	for(i=0;i<=1;i++)
		for(j=1;j<=2-i;j++)
		{
			if(a[i].verbal+a[i].math<a[i+j].verbal+a[i+j].math)
			{
				t=a[i].num;
				a[i].num=a[i+j].num;
				a[i+j].num=t;
				t=a[i].sum;
				a[i].sum=a[i+j].sum;
				a[i+j].sum=t;
			}
		}
	for(i=3;i<n;i++)
	{
		scanf("%d%d%d",&a[3].num,&a[3].verbal,&a[3].math);
		if(a[3].verbal+a[3].math>a[0].sum)
		{
			t=a[1].num;
			a[1].num=a[0].num;
			a[2].num=t;
			a[0].num=a[3].num;
			t=a[1].sum;
			a[1].sum=a[0].sum;
			a[2].sum=t;
			a[0].sum=a[3].verbal+a[3].math;
		}
		else if(a[3].verbal+a[3].math>a[1].sum)
		{
			a[2].num=a[1].num;
			a[1].num=a[3].num;
			a[2].sum=a[1].sum;
			a[1].sum=a[3].verbal+a[3].math;
		}
		else if(a[3].verbal+a[3].math>a[2].sum)
		{
			a[2].num=a[3].num;
			a[2].sum=a[3].verbal+a[3].math;
		}
	}
	for(i=0;i<=2;i++)
		printf("%d %d\n",a[i].num,a[i].sum);
}


struct stu1
{
	long num;
	int score1;
	int score2;
	struct stu1 *next;
};

struct stu1 *creat(void)
{
	int n,i=1;

	struct stu1 *h;

	struct stu1 *q1,*q2;
	scanf("%d",&n);

	q2=q1=(struct stu1 *)malloc(LEN1);

	h=NULL;
	while(i<=n)
	{
		scanf("%ld %d %d",&q1->num,&q1->score1,&q1->score2);

		if(i==1){h=q1;}
		else{q2=q1;}
		if(i!=n)
		{

		    q1=q2->next=(struct stu1 *)malloc(LEN1);
		}
		else {q1->next=NULL;}
		i++;
	}
	return(h);
}

struct stu1 *turn(struct stu1 *h)
{
	int t=1;
	struct stu1 *p1,*p2;
	int m,n,w;
	for(p1=h,t=1;p1->next!=NULL,t<=3;p1=p1->next,t++)
	{
		p2=p1->next;
		while(p2!=NULL)
		{
			if((p1->score1+p1->score2)<(p2->score1+p2->score2))
			{
				m=p1->num;n=p1->score1;w=p1->score2;
				p1->num=p2->num;p1->score1=p2->score1;p1->score2=p2->score2;
				p2->num=m;p2->score1=n;p2->score2=w;
			}
			p2=p2->next;
		}
		printf("%ld %d\n",p1->num,(p1->score1+p1->score2));
	}
	return(h);
}
/*void print(struct stu1 *h)
{
	int t=1;
	struct stu1 *p;
	p=h;
	for(t=1;t<=3;t++)
	{
		printf("%ld %d\n",p->num,(p->score1+p->score2));
		p=p->next;
	}
}*/
void main()
{
	struct stu1 *ip/*,*is*/;
	ip=creat();
	/*is=*/turn(ip);
	/*print(is);*/
}


main()
{
    struct student
    {int num;
     int sc;
     int sm;
     int score;
    } student[100001];
    int n,i,j,k,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++) {scanf("%d %d %d",&student[i].num,&student[i].sc,&student[i].sm);}
    for(i=1;i<=n;i++) {student[i].score=(student[i].sc+student[i].sm);}
    int x,y,z,r,s,t,a,b,d;
    a=1;
    b=1;
    d=1;
    for(i=n;i>=1;i--) if(student[i].score>=a) {a=student[i].score;x=i;}
    for(i=n;i>=1;i--)
    {
                      if((i!=x)&&(student[i].score>=b)) {b=student[i].score;y=i;}
    }
    for(i=n;i>=1;i--)
    {
                      if((i!=x)&&(i!=y)&&(student[i].score>=d)) {d=student[i].score;z=i;}
    }

    printf("%d %d\n%d %d\n%d %d",student[x].num,student[x].score,student[y].num,student[y].score,student[z].num,student[z].score);
}


int main(int argc, char* argv[])
{
	int i;
	long n;
	int sum[100000];
	int max=0,second=0,third=0;
	int a=0,b=0,c=0;
	scanf("%d",&n);
	struct student
	{
		int id;
		int chi;
		int math;
	};
	struct student wangchong[100000];
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&wangchong[i].id,&wangchong[i].chi,&wangchong[i].math);
		sum[i]=wangchong[i].chi+wangchong[i].math;
		if (sum[i]>third)
		{
			if (sum[i]<=second)
			{
				third=sum[i];
		        c=i+1;
			}
			else
			{
				if (sum[i]<=max)
				{
					third=second;
					second=sum[i];
					c=b;
					b=i+1;
				}
				else
				{
					third=second;
					c=b;
					second=max;
					b=a;
					max=sum[i];
					a=i+1;
				}
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",a,max,b,second,c,third);
	return 0;
}


struct linknode *CreateLinkList();
void DisplayLinkList(struct linknode *linklist1);
void qiansan(struct linknode *linklist2);
struct linknode
{
	int id;
	int chinese;
	int math;
	int total;
	int mark;
	struct linknode *next;
};
int main()
{
	qiansan(CreateLinkList());

}
struct linknode *CreateLinkList()
{
	long n,i;
	struct linknode *head,*p;
	scanf("%ld",&n);
	head=(struct linknode *)malloc(sizeof(struct linknode));
	p=head;
	if (p==NULL)
	{
		printf("fail");
		exit(-1);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&p->id,&p->chinese,&p->math);
		p->total=p->chinese+p->math;
		p->mark=0;
		if (i==n)
			p->next=NULL;
		else
		{
			p->next=(struct linknode *)malloc(sizeof(struct linknode));
			p=p->next;
		}
	}
	return head;
}
void  qiansan(struct linknode *linklist2)
{
   struct linknode *head,*p,*max;

   head=linklist2;
   p=head;
   max=(struct linknode *)malloc(sizeof(struct linknode));
   int j;
   for (j=1;j<=3;j++)
   {
	   p=head;
	   max->total=0;
	   while (p!=NULL)
	   {
		   if (p->total>max->total&&p->mark==0)
		   {
               max=p;
		   }
		   p=p->next;
	   }
	   max->mark=1;
	   printf("%d %d\n",max->id,max->total);
	}
}


struct student
{
	int num;
	int Chinese;
	int math;
	int sum;
};

void main()
{
	int i,n,p,q,r,b=0,c=0,d=0;
	struct student a[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[i].num,&a[i].Chinese,&a[i].math);
		a[i].sum=a[i].Chinese+a[i].math;
		if(i==0)
			p=q=r=a[i].sum;
		else
		{
			if(a[i].sum>p)
			{
				r=q;
				q=p;
				p=a[i].sum;
				d=c;
				c=b;
				b=i;
			}
			else if(a[i].sum>q)
			{
				r=q;
				q=a[i].sum;
				d=c;
				c=i;
			}
			else if(a[i].sum>r)
			{
				r=a[i].sum;
				d=i;
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",a[b].num,a[b].sum,a[c].num,a[c].sum,a[d].num,a[d].sum);
}


struct student
{
        int num;
        int sum;
};

int main()
{

   int n,i,j,t,a,b,m;
   int tempSum;
   int tempMax;
   int rank[3]={0};
   scanf("%d",&n);
   struct student * stu;
   stu = (struct student *)malloc(sizeof(struct student) * n);
   for(i=0;i<n;i++)
   {
        tempSum = 0;
           scanf("%d",&stu[i].num);
           stu[i].sum = 0;
           for(j=0;j<2;j++){
            scanf("%d",&tempSum);
            stu[i].sum += tempSum;
           }
   }
   for(b=0;b<3;b++)
   {
       tempMax = 0;
       for(a=b;a<n;a++)
       {
           if(stu[a].sum > tempMax){
            tempMax = stu[a].sum;
            rank[b] = a;
           }
       }
       t = stu[b].num;
       stu[b].num = stu[rank[b]].num;
       stu[rank[b]].num = t;
       t = stu[b].sum;
       stu[b].sum = stu[rank[b]].sum;
       stu[rank[b]].sum = t;
   }
   for(a=0;a<3;a++)
   printf("%d %d\n",stu[a].num,stu[a].sum);

  return 0;
}


struct Stu{
	int stuID;
	int mark;
}stu[3]={0};

int compare(const void *p1,const void *p2)
{
	struct Stu *a;
	struct Stu *b;
	a=(struct Stu*)p1;
	b=(struct Stu*)p2;
	if(a->mark>b->mark) return -1;
	if(a->mark<b->mark) return 1;
	if(a->mark==b->mark) return 0;
}

void main(){
	int n,i;
	int ID,chi,math;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&ID,&chi,&math);
		if(chi+math>stu[2].mark) {
			stu[2].mark=chi+math;
			stu[2].stuID=ID;
		}
		qsort(stu,3,sizeof(struct Stu),compare);
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",stu[i].stuID,stu[i].mark);
}


   struct student
   {
      int n;
      int y;
      int s;
   };
int cmp(const void *a,const void *b)
{
return(((struct student *)b)->y > ((struct student *)a)->y?1:-1);
}

main()
{
    int num;
    scanf("%d",&num);
    struct student s[100000];
    for(int i=0;i<num;i++)
    {
            scanf("%d %d %d",&s[i].n,&s[i].y,&s[i].s);
            s[i].y=s[i].y+s[i].s;
    }
    qsort(s,num,sizeof(s[0]),cmp);
    for(int i=0;i<3;i++)
     printf("%d %d\n",s[i].n,s[i].y);
}


struct student
{
	int id;
	int cs;
	int ms;
	int s;
	struct student *next;
};
void main()
{
	int n,i,m=0;
	scanf("%d",&n);
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
	p1->s=p1->cs+p1->ms;
	head=NULL;
	while(p1->id!=n)
	{
		m=m+1;
		if(m==1) head=p1;
		else
		p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
		p1->s=p1->cs+p1->ms;
	}
	p2->next=NULL;
	for(i=0;i<3;i++)
	{
		p1=p2=head;
		do
		{
			p2=p2->next;
			if(p1->s<p2->s)
				p1=p2;
		}while(p2->next!=NULL);
		printf("%d %d\n",p1->id,p1->s);
		p1->s=-1;
	}
}