#include<stdio.h>
main()
{
	struct student{
		char name[20];
		int year;
		int month;
		int day;
		char phone[13];
		
	};
	student s[30];
int n,j,i,t;
printf("n=");
scanf("%d",&n);
for(i=0;i<n;++i)
{
	scanf("%s",&s[i].name);
	for(j=0;j<4;++j)
		scanf("%d%d%d%s",&s[i].year,&s[i].month,&s[i].day,&s[i].phone);
}
for(i=0;i<n;++i)
for(j=0;j<n-1-i;++j)
{
	if(s[j].year<s[j+1].year)
	{
		t=s[j].year;
		s[j].year=s[j+1].year;
		s[j+1].year=t;
	}
}
printf("%d",s[n-1].year);
}