int main(int argc, char* argv[])
{
	int n,i,j,diji=0;
	double a,b,distance,d,max=0;
	struct point{
	    double x;
		double y;
	};
	struct point*dian;
	scanf("%d",&n);
	dian=(struct point*)malloc(sizeof(struct point)*n);
	for(i=0;i<n;i++){
		scanf("%lf%lf",&a,&b);
		dian[i].x=a;
        dian[i].y=b;
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			d=(dian[i].x-dian[j].x)*(dian[i].x-dian[j].x)+(dian[i].y-dian[j].y)*(dian[i].y-dian[j].y);
			distance=sqrt(d);
			if(distance>max)max=distance;
		}
	}
    printf("%.4f\n",max);

	return 0;
}


int main(){
	int n,i=0,j=0,m=1;
	double dis,dist=0;
	scanf("%d",&n);
	double plx[n],ply[n];
	for(i=0;i<n;i++){
		double X,Y;
		scanf("%lf %lf",&plx[i],&ply[i]);
	}
	for(j=0;j<n;j++){
		for(m=1;m<n;m++){
			dis=sqrt((plx[j]-plx[m])*(plx[j]-plx[m])+(ply[j]-ply[m])*(ply[j]-ply[m]));
			if(dis>=dist){
				dist=dis;
			}
		}
	}
	printf("%.4f\n",dist);
	return 0;
}


int main() {
	double distance = 0;
	double max = 0;
	double point[200][2] = {0};
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {      // store the position of each point
		cin >> point[i][0] >> point[i][1];
	}
	for(int i = 0; i < n - 1; i++)
		for(int j = i + 1; j < n; j++) {          // calculate the distances
			distance = (point[i][0] - point[j][0]) * (point[i][0] - point[j][0]) + (point[i][1] - point[j][1]) * (point[i][1] - point[j][1]);
			if(distance > max) max = distance;
		}
	max = sqrt(max);
	printf("%.4f\n", max);
	getchar();
	getchar();
	return 0;
}


double point[2][100];
double distance(int i,int j);
void main ()
{
	int n,i,j;
	double dis=0;

	scanf("%d",&n);
	scanf("%lf %lf",&point[0][0],&point[1][0]);

	for(i=1;i<n;i++)
	{
		scanf("%lf %lf",&point[0][i],&point[1][i]);

		for(j=0;j<i;j++)
			if(dis<distance(i,j)) dis=distance(i,j);
	}
	printf("%.4lf\n",dis);
}

double distance(int i,int j)
{
	double x=point[0][i]-point[0][j];
	double y=point[1][i]-point[1][j];
	return sqrt(x*x+y*y);
}


int main(int argc, char* argv[])
{
	struct point{
		float x,y;
	}p[num];
	int n,i,m;
	float max=0,d,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{

		scanf("%f %f",&(p[i].x),&(p[i].y));
		for(m=0;m<i;m++)
		{
			d=(p[i].x-p[m].x)*(p[i].x-p[m].x)+(p[i].y-p[m].y)*(p[i].y-p[m].y);
			c=(float)pow(d,0.5);

	if(c>max)
	{
		max=c;
	}
		}
	}
	printf("%.4f",max);
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	double x[10],y[10];
	double dis=0;
	double m;
	int i,j;
	for(i=0;i<n;i++)
	{
		double a,b;
		scanf("%lf %lf",&a,&b);
		x[i]=a;
		y[i]=b;
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			m=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			if(dis<=m)
			{
				dis=m;
			}
		}
	}
	printf("%.4f\n",dis);
	return 0;
}


int main(int argc,  char* argv[])
{
	int n,i,j;
	double distance=0,d;
	struct point {
		double x,y;
	};
    struct point *p;
	scanf ("%d",&n);
	p=(struct point*)malloc(sizeof(point)*n);
	for (i=0;i<n;i++)
	{
		scanf ("%lf%lf",&p[i].x,&p[i].y);
	}
	for (i=0;i<n-1;i++)
	{
		for (j=i+1;j<n;j++)
		{
			d=(p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y);
			if (sqrt(d)>distance) distance=sqrt(d);
		}
	}
	printf("%.4lf\n",distance);
	free(p);
	return 0;
}


int  main(int argc, char* argv[])
{
	int a,i,j;// a ????????
	double value[100];
	int number=0;//????
	scanf("%d",&a);
	struct{
		double x;
		double y;

	} point[10];
	for(i=0;i<a;i++){//?point ??
		double m,n;
		scanf("%lf%lf",&m,&n);
		point[i].x=m;
		point[i].y=n;
	}

	for(i=0;i<a-1;i++){
		for(j=a-1;j>i;j--){
	   value[number]=sqrt( pow((point[i].x -point[j].x),2) +pow((point[i].y-point[j].y),2));
	    number++;
		}
	}

	for(i=0;i<number;i++){  //???? a-1
		double turn;
		if(value[i]>value[i+1]){
		turn= value[i+1];
		value[i+1]=value[i];
		value[i]=turn;
		}
		else;
	}

		printf("%.4lf",value[number]);

    return 0;

}


int main()
{

int n,i,j;
double Ldist,dist;
struct dis
{
	double x;
	double y;
}dis[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%lf%lf",&dis[i].x,&dis[i].y);
}
Ldist=sqrt((dis[0].x-dis[1].x)*(dis[0].x-dis[1].x)+(dis[0].y-dis[1].y)*(dis[0].y-dis[1].y));
for(i=0;i<n;i++)
{for(j=i+1;j<n;j++)
{dist=sqrt((dis[i].x-dis[j].x)*(dis[i].x-dis[j].x)+(dis[i].y-dis[j].y)*(dis[i].y-dis[j].y));
 if(dist>Ldist)
	 Ldist=dist;
}
}
printf("%.4lf",Ldist);
return 0;
}


  struct point
   {
     double x;
     double y;

   };
main ()
{
   struct point p[20];
   int n;
   scanf ("%d\n",&n);
   int i,j;
   for (i=0;i<n;i++)
   {
     scanf ("%lf%lf\n",&p[i].x,&p[i].y);
   }
      double dis[400] ;
      double t;
      int k=0;
      for (i=0;i<n-1;i++)
      {
         for (j=i+1;j<n;j++)
         {
            t=(p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y);
            dis[k] =sqrt (t);
            k++;
         }
      }
    double max=dis [0];
    for (i=1;dis[i]!='\0';i++)
          {
          if (dis [i]>max)
            max =dis [i];

          }

        printf ("%.4lf\n",max);

getchar ();
getchar ();

}


int main()
{
	double distance(double,double,double,double);
	int n,i,j;
	double a[50][2];
	double max=0,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%lf %lf",&a[i][0],&a[i][1]);
	for(i=0;i<n-1;i++)
	{
		for(j=1;j<n;j++)
		{temp=distance(a[i][0],a[i][1],a[j][0],a[j][1]);
		if(temp>max) max=temp;}
	}
	printf("%.4f\n",max);
}
double distance(double a,double b,double c,double d)
{
	double k;
	k=sqrt((a-c)*(a-c)+(b-d)*(b-d));
	return (k);
}


int main()
{
	int i,j,n;
	scanf ("%d",&n);
	double *x,*y;
	double s=0;
         double d;
	x=(double*)malloc(sizeof(double)*n);
	y=(double*)malloc(sizeof(double)*n);
	for (i=0;i<n;i++)
	{
		double x1,y1;
		scanf ("%lf%lf",&x1,&y1);
		*(x+i)=x1;
		*(y+i)=y1;
    }

for(i=0;i<n-1;i++)
{
		double x2,y2;
		for(j=1;j<n-i;j++)
		{
			x2=*(x+i)-*(x+i+j);
			y2=*(y+i)-*(y+i+j);
			d=sqrt(x2*x2+y2*y2);
	   		if(d>s)s=d;
		}
}
  printf ("%.4lf\n",s);
  free (x);
  free (y);
  return 0;
}


int main ()
{
    int n;
    double point[3000][2],
           ans=0;
    cin >>n;
    for (int i=1;i<=n;i++)
        cin >>point[i][0]>>point[i][1];
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
        {
            if (i==j)
                continue;
            double f;
            f=hypot(point[i][0]-point[j][0],point[i][1]-point[j][1]);
            ans=max(ans,f);
        }
    }
    cout <<fixed<<setprecision(4)<<ans;
    return 0;
}


int main()
{
	int n, i;
	double max=0;
	scanf("%d", &n);
	struct
	{
		double x, y;
	}a[100];
	for(i=0;i<n;i++)
	{
		scanf("%lf%lf", &a[i].x, &a[i].y);
	}
	for(i=0;i<n;i++)
	{
		for(int j=0;j<n&&j!=i;j++)
		{
			double dis=sqrt(pow(a[i].x-a[j].x,2)+pow(a[i].y-a[j].y,2));
		    if(dis>max)
			{
				max=dis;
			}
		}
	}
	printf("%.4f\n", max);
	return 0;
}


int main(int argc, char* argv[])
{
	double c,d,z,max=0;
	struct{
		double x,y;
	}a[100];
	int i,n,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lf%lf",&c,&d);
		a[i].x=c;
		a[i].y=d;

	}
    for(i=0;i<n;i++)
	{
		for(b=0;b<n;b++)
		{
		   z=sqrt((a[i].x-a[b].x)*(a[i].x-a[b].x)+(a[i].y-a[b].y)*(a[i].y-a[b].y));
		   if(z>max)
			   max=z;
		   else
			   max=max;
	}
	}
	printf("%.4f\n",max);
	return 0;
}


int main()
{
     int n,i,k;
     scanf("%d",&n);
     double l=0,lest=0;
     double *x;
     x=(double*)malloc(sizeof(double)*n);
     double *y;
     y=(double*)malloc(sizeof(double)*n);
     for(i=0;i<n;i++)
	 {
         scanf("%lf%lf",&x[i],&y[i]);
	 }
	 for(i=0;i<n;i++)
	 {
		 for(k=i+1;k<n;k++)
		 {
			 l=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
			 if(lest<l)
			 {
				 lest=l;
			 }
		 }
	 }
     printf("%.4lf\n",lest);
     free(x);
     free(y);
     return 0;
}


int main ()
{
	int n,i,j;
	int year,month1,month2;
	int relation=0,middle;
	int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin >> n;
	for (i=0;i<n;i++)
	{
		cin >> year >> month1 >> month2;
		if (month1>month2)
		{
			middle=month1;
			month1=month2;
			month2=middle;
		}
		if(year%4==0&&year%100!=0||year%400==0)
		{
			day[1]=29;
			for(j=month1;j<month2;j++)
			{
				relation=relation+day[j-1];
			}
			if (relation%7==0)
			{
				cout << "YES" << endl;
			}
			else
			{
				cout << "NO" <<endl;
			}
			day[1]=28;
		}
		else
		{
				for(j=month1;j<month2;j++)
				{
			    	relation=relation+day[j-1];
				}
		    	if (relation%7==0)
				{
			    	cout << "YES" << endl;
				}
		    	else
				{
			    	cout << "NO" <<endl;
				}
		}
		relation=0;
	}
	return 0;
}


int main()
{
	int y,m1,m2,n,i,j,k,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2)
		{
			t=m1;
			m1=m2;
			m2=t;
		}
		if(y%4==0&&y%100!=0||y%400==0)
		{
			k=0;
			for(j=m1;j<m2;j++)
			{
				switch(j)
				{
				case 1: k=k+31;break;
				case 2: k=k+29;break;
				case 3: k=k+31;break;
				case 4: k=k+30;break;
				case 5: k=k+31;break;
				case 6: k=k+30;break;
				case 7: k=k+31;break;
				case 8: k=k+31;break;
				case 9: k=k+30;break;
				case 10: k=k+31;break;
				case 11: k=k+30;break;
				}
			}
		}
		else
		{
			k=0;
			for(j=m1;j<m2;j++)
			{
				switch(j)
				{
				case 1: k=k+31;break;
				case 2: k=k+28;break;
				case 3: k=k+31;break;
				case 4: k=k+30;break;
				case 5: k=k+31;break;
				case 6: k=k+30;break;
				case 7: k=k+31;break;
				case 8: k=k+31;break;
				case 9: k=k+30;break;
				case 10: k=k+31;break;
				case 11: k=k+30;break;
				}
			}
		}
		if(k%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


int djt(int year,int month)
{
	int i,sum=1;
	for(i=1;i<month;i++){
		switch(i)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
				sum+=31;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				sum+=30;
				break;
			case 2:
				if(year%4==0&&year%100!=0||year%400==0){
					sum+=29;
				}
				else{
					sum+=28;
				}
		}
	}
	return sum;
}
int main()
{
	int n,i,year[200],month1[200],month2[200];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&(year[i]),&(month1[i]),&(month2[i]));
	}
	for(i=0;i<n;i++){
		if((djt(year[i],month1[i])-djt(year[i],month2[i]))%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}

	}
	return 0;
}


int leap(int n)
{
	if((n%4==0&&n%100!=0)||n%400==0)
		return 1;
	else
		return 0;
}
int main()
{
	int year,mon1,mon2;
	int mon[]={0,3,0,3,2,3,2,3,3,2,3,2,3};
	int i,j,n,temp,day;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&mon1,&mon2);
		if(mon1>mon2)
		{
			temp=mon1;
			mon1=mon2;
			mon2=temp;
		}
		if(leap(year))
			mon[2]++;
		day=0;
		for(j=mon1;j<mon2;j++)
		{
			day+=mon[j];
		}
		if(day%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		if(leap(year))
			mon[2]--;
	}
}


int main()
{
	int n, i, leap, j, month;
	int year, m1, m2, d=0;

	cin >> n;
	for(i = 1;i <= n;i++)
	{
                d = 0;
		cin >> year >> m1 >> m2;

		if((year % 400 == 0)||(year % 100 != 0 && year % 4 == 0)) leap = 1;
		else leap = 0;
		if(m1 > m2)
		{
			month = m2;
			m2 = m1;
			m1 = month;
		}
		for(j = m1;j < m2;j++)
		{
			switch(j)
			{
			case 1 :
			case 3 :
			case 5 :
			case 7 :
			case 8 :
			case 10 :
			case 12 : d += 31;break;

        	case 4 :
			case 6 :
			case 9 :
			case 11 : d += 30;break;

        	case 2 : d = d + 28 + leap;break;
			}
		}
		if(d % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


void main()
{
	void func(int,int,int);
	int y,x,z,n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&y,&x,&z);
		func(y,x,z);
	}
}
void func(year,m1,m2)
{
	int judge(int);
	int p,q;
	if(judge(year)==1)
	{
		switch(m1)
		{
		case 1:p=1;break;
		case 2:p=32;break;
		case 3:p=61;break;
		case 4:p=92;break;
		case 5:p=122;break;
		case 6:p=153;break;
		case 7:p=183;break;
		case 8:p=214;break;
		case 9:p=245;break;
		case 10:p=275;break;
		case 11:p=306;break;
		default:p=336;break;
		}
		switch(m2)
		{
		case 1:q=1;break;
		case 2:q=32;break;
		case 3:q=61;break;
		case 4:q=92;break;
		case 5:q=122;break;
		case 6:q=153;break;
		case 7:q=183;break;
		case 8:q=214;break;
		case 9:q=245;break;
		case 10:q=275;break;
		case 11:q=306;break;
		default:q=336;break;
		}
		if((p-q)%7==0)
		{
			printf("YES\n");
		}
		else printf("NO\n");
	}
	else if(judge(year)==2)
	{
		switch(m1)
		{
		case 1:p=1;break;
		case 2:p=32;break;
		case 3:p=60;break;
		case 4:p=91;break;
		case 5:p=121;break;
		case 6:p=152;break;
		case 7:p=182;break;
		case 8:p=213;break;
		case 9:p=244;break;
		case 10:p=274;break;
		case 11:p=305;break;
		default:p=335;break;
		}
		switch(m2)
		{
		case 1:q=1;break;
		case 2:q=32;break;
		case 3:q=60;break;
		case 4:q=91;break;
		case 5:q=121;break;
		case 6:q=152;break;
		case 7:q=182;break;
		case 8:q=213;break;
		case 9:q=244;break;
		case 10:q=274;break;
		case 11:q=305;break;
		default:q=335;break;
		}
		if((p-q)%7==0)
		{
			printf("YES\n");
		}
		else printf("NO\n");
	}
}
int judge(year)
{
	int f;
	if((year%4==0&&year%100!=0)||year%400==0) f=1;
	else f=2;
	return f;
}


int DiJiTian(int, int, int);
int main(){
	int n;
	int nian;
	int x,y;
	int i;
	int e;
	int day;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	         scanf("%d %d %d", &nian, &x, &y);
	         if(x<y){
	                        e=x;
		                    x=y;
		                    y=e;
			 }
	         day=DiJiTian(nian,x,1)-DiJiTian(nian,y,1);
	         if(day%7==0){
		              printf("YES\n");
			 }else {
	                	printf("NO\n");
			 }
	}
	return 0;
}

int DiJiTian(int year, int month, int day){
	int result = 0;
	for(int i = 1; i < month; i++){ 	//step1
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(year%400 == 0 ||(year%4==0 && year%100!=0)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result += day;	//step2
	return result;
}


int run(int x)
{
    if(x%4!=0)
        return 0;
    if(x%100!=0)
        return 1;
    if(x%400==0)
        return 1;
    return 0;
}
main()
{
    int n,y,mon1,mon2;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d %d %d",&y,&mon1,&mon2);
        if(mon1>mon2)
        {
            int temp=mon1;
            mon1=mon2;
            mon2=temp;
        }
        if(run(y)==1)
        {
            int d=0;
            for(int j=mon1;j<mon2;j++)
            {
                if(j==2)
                    d+=29;
                else if(j==4||j==6||j==9||j==11)
                    d+=30;
                else
                    d+=31;
            }
            if(d%7==0)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            int d=0;
            for(int j=mon1;j<mon2;j++)
            {
                if(j==2)
                    d+=28;
                else if(j==4||j==6||j==9||j==11)
                    d+=30;
                else
                    d+=31;
            }
            if(d%7==0)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    getchar();
    getchar();getchar();
}


int DATE0(int M0)
{
	int DATE0;
    switch(M0)
	{
	    case 1:
			DATE0=1;
			break;
		case 2:
			DATE0=32;
			break;
		case 3:
			DATE0=61;
			break;
		case 4:
			DATE0=92;
		    break;
		case 5:
			DATE0=122;
			break;
		case 6:
			DATE0=153;
			break;
		case 7:
			DATE0=183;
			break;
		case 8:
			DATE0=214;
			break;
		case 9:
			DATE0=245;
			break;
		case 10:
			DATE0=275;
			break;
		case 11:
			DATE0=306;
			break;
		case 12:
			DATE0=336;
			break;
	}
	return DATE0;
}

int DATE1(int M1)
{
	int DATE1;
    switch(M1)
	{
	    case 1:
			DATE1=1;
			break;
		case 2:
			DATE1=32;
			break;
		case 3:
			DATE1=60;
			break;
		case 4:
			DATE1=91;
			break;
		case 5:
			DATE1=121;
			break;
		case 6:
			DATE1=152;
			break;
		case 7:
			DATE1=182;
			break;
		case 8:
			DATE1=213;
			break;
		case 9:
			DATE1=244;
			break;
		case 10:
			DATE1=274;
			break;
		case 11:
			DATE1=305;
			break;
		case 12:
			DATE1=335;
			break;
	}
	return DATE1;
}

int main()
{
	int i,n,YEAR[210],MONTH1[210],MONTH2[210],P[210],Q[210],A[210],B[210];
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&YEAR[i],&MONTH1[i],&MONTH2[i]);
	    if(YEAR[i]%4!=0)
		{
			P[i]=1;
		}
		else if(YEAR[i]%4==0&&YEAR[i]%100!=0)
		{
			P[i]=0;
		}
		else if(YEAR[i]%100==0&&YEAR[i]%400!=0)
		{
			P[i]=1;
		}
		else
		{
			P[i]=0;
		}
		if(P[i]==0)
		{
			A[i]=DATE0(MONTH1[i]);
			B[i]=DATE0(MONTH2[i]);
			if((A[i]-B[i])%7==0)
			{
				Q[i]=1;
			}
			else
			{
				Q[i]=0;
			}
		}
		else
		{
			A[i]=DATE1(MONTH1[i]);
			B[i]=DATE1(MONTH2[i]);
			if((A[i]-B[i])%7==0)
			{
				Q[i]=1;
			}
			else
			{
				Q[i]=0;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			printf("\n");
		}
		if(Q[i]==1)
		{
			printf("YES");
		}
		else
		{
			printf("NO");
		}
	}
    return 0;
}


void main(){
	int leap_or_not(int year);
    int daysnotleap(int month);
    int daysleap(int month);
	int data[201][3],i,j,sum[201]={0},num,temp;
	scanf("%d",&num);
	for (i=1;i<=num;i++){
		for (j=0;j<3;j++)
			scanf("%d",&data[i][j]);
	}
	for (i=1;i<=num;i++){
		if (data[i][1]>data[i][2]){
				temp=data[i][1];
				data[i][1]=data[i][2];
				data[i][2]=temp;
			}
		}
	for (i=1;i<=num;i++){
		if (leap_or_not(data[i][0])==0){
		for (j=data[i][1];j<data[i][2];j++)
			sum[i]+=daysnotleap(j);
		}
		else {
			for(j=data[i][1];j<data[i][2];j++)
				sum[i]+=daysleap(j);
		}
	}
	for (i=1;i<=num;i++)
	{if (sum[i]%7==0) printf("YES\n");
	else printf("NO\n");
	}
}

int leap_or_not(int year){
	 int leap;
	 if (year%4==0){
		 if (year%100==0){
			 if (year%400==0)
				 leap=1;
			 else leap=0;
		 }
		 else leap=1;
	 }
	 else leap=0;
	return leap;
}

int daysnotleap(int month){
	int day;
    if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
		day=31;
	else if (month==4||month==6||month==9||month==11)
		day=30;
	else day=28;
    return (day);
}
int daysleap(int month){
	int day;
    if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
		day=31;
	else if (month==4||month==6||month==9||month==11)
		day=30;
	else day=29;
    return (day);
}


int main()
{
	int n, i, year, days, mon1, mon2, tmon1, tmon2,
		month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> year >> tmon1 >> tmon2;
		mon1 = tmon1 < tmon2 ? tmon1 : tmon2;
		mon2 = tmon1 > tmon2 ? tmon1 : tmon2;
		if (mon1 <= 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
			days = 1;
        else
			days = 0;
		for (; mon1 < mon2; mon1++)
		{
			days += month[mon1 - 1];
		}

		if (days % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


int isRunNian(int year){
	int result;
	if(year%400==0||(year%4==0&&year%100!=0)){
		result=1;
	}else{
		result=0;
	}
      return result;
}
int DiJiTian(int year, int month, int day){
	int result=0;
	for(int i=1; i<month;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i==4||i==6||i==9||i==11){
			result += 30;
		} else if(i==2){
			if(isRunNian(year)){
				result+=29;
			} else {
				result+=28;
			}
		}
	}
	result+=day;
	return result;
}

int main(){
	int n,a,b,c;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if((DiJiTian(a,b,1)-DiJiTian(a,c,1))%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}


int is_leapyear(int y);
int main(){
	int n;
	cin>>n;
	const int md[12]={
		31,28,31,30,31,30,31,31,30,31,30,31
	};
	for(int i=0;i<n;i++){
		int yy,m1,m2;
		cin>>yy>>m1>>m2;
		int d=0;
		for(int i=min(m1,m2);i<max(m1,m2);i++) d+=md[i-1];
		if((m1<=2||m2<=2)&&is_leapyear(yy)) d++;
		if(!(d%7)) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}
int is_leapyear(int y){
	if(!(y%100)){
		if(!(y%400)) return 1;
		else return 0;
	}
	else if(!(y%4)) return 1;
	else return 0;
}


int main()
{
	int n;
	cin >> n;
	int year, month1, month2;
	for (int i= 1; i <= n; i++)
	{
		cin >> year >> month1 >> month2;
		int difference = month1 - month2;
		if (difference > 0)
		{
			month1 -= difference;
			month2 += difference;
		}
		int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		if (((!(year % 4)) && (year % 100)) || !(year % 400))
			m[2] = 29;
		int d = 0;
		for (int j = month1; j < month2; j++)
			d += m[j];
		if (d % 7)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}

	return 0;
}


int main()
{
	int i,n,a,b,c;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
		if(a%4!=0 || (a%100==0 & a%400!=0))
		{
            if(b==3 & c==11)
			    cout << "YES"<<endl;
		    else if(b==4 & c==7)
				cout << "YES"<<endl;
			else if(b==9 & c==12)
				cout << "YES"<<endl;
			else if(b==7 & c==4)
				cout << "YES"<<endl;
			else if(b==12 & c==9)
				cout << "YES"<<endl;
			else if(b==11 & c==3)
				cout << "YES"<<endl;
			else if(b==1 & c==10)
				cout << "YES"<<endl;
			else if(b==10 & c==1)
				cout << "YES"<<endl;
			else if(b==2 &c==11)
				cout << "YES"<<endl;
			else if(b==11 & c==2)
				cout << "YES"<<endl;
			else if(b==3 & c==2)
				cout << "YES"<<endl;
			else if(b==2 & c==3)
				cout << "YES"<<endl;
			else cout << "NO"<<endl;
		}
		else
		{
			if(b==3 & c==11)
			    cout << "YES"<<endl;
		    else if(b==4 & c==7)
				cout << "YES"<<endl;
			else if(b==9 & c==12)
				cout << "YES"<<endl;
			else if(b==7 & c==4)
				cout << "YES"<<endl;
			else if(b==12 & c==9)
				cout << "YES"<<endl;
			else if(b==11 & c==3)
				cout << "YES"<<endl;
			else if(b==1 & c==4)
				cout << "YES"<<endl;
			else if(b==1 & c==7)
				cout << "YES"<<endl;
			else if(b==7 & c==1)
				cout << "YES"<<endl;
			else if(b==4 & c==1)
				cout << "YES"<<endl;
			else if(b==2 & c==8)
				cout << "YES"<<endl;
			else if(b==8 & c==2)
				cout << "YES"<<endl;
			else cout << "NO"<<endl;
		}
	}
	return 0;
}


int main ()
{
	int n, i, year, m1, m2, leap, days;
	cin >> n;
	for (i = 1; i <= n; i++ )
	{
		cin >> year >> m1 >> m2;
		days = 0;
		leap = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
		if (m1 > m2)
		{
			int c = m1;
			m1 = m2;
			m2 = c;
		}
		for ( ; m1 < m2; m1++ )
		{
			switch(m1)
			{
				case(2):
					days += 28 + leap;
					break;
				case(4):
				case(6):
				case(9):
				case(11):
					days += 30;
					break;
				case(1):
				case(3):
				case(5):
				case(7):
				case(8):
				case(10):
				case(12):
					days += 31;
					break;
			}
		}
		if (days % 7 == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}


int dijitian(int y,int m,int d);
int main(){
    int n,k,year,month1,month2,cha;
	scanf("%d",&n);
	for(k=0;k<n;k++){
	   scanf("%d %d %d",&year,&month1,&month2);
       cha=dijitian(year,month1,1)-dijitian(year,month2,1);
	   if(cha<0){
	      cha=-cha;
	   }
	   if(cha%7==0){
	      printf("YES\n");
	   }else{
	      printf("NO\n");
	   }
	}
return 0;
}
int dijitian(int y,int m,int d){
    int sum=0;
	int i;
	for(i=1;i<m;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
		    sum+=31;
		}else if(i!=2){
		    sum+=30;
		}else{
			if((y%400==0)||(y%100!=0&&y%4==0)){
			   sum+=29;
			}else{
			   sum+=28;
			}
		}
	}
    sum+=d;
	return sum;
}


int run ( int x )
{
	if ( (x % 400 ==0) || ( (x % 4 == 0 )&& (x % 100 != 0 )) )
		return 0 ;
	else return 1 ;
}
int main()
{
	int i , n , j , day = 0 ;
	scanf("%d", &n);
	for ( i = 0 ; i < n ; i ++)
	{
		int year , mona ,monb , max , min;
		int run(int x);
		scanf ("%d %d %d" , &year , &mona , &monb);
		if (mona > monb)
		{
			max = mona ;
			min = monb ;
		}
		else
		{
			max = monb ;
			min = mona ;
		}
		if ( run(year) == 0 )
		{
			for ( j = min ; j < max ; j ++)
			{
				if ( j == 2)
				{
					day += 29;
				}
				else if ( j == 4 || j == 6 || j == 9 || j == 11)
				{day += 30 ;}
				else {day += 31;}

			}
		}
		if ( run(year) == 1 )
		{
			for ( j = min ; j < max ; j ++)
			{
				if ( j == 2)
				{
					day += 28;
				}
				else if ( j == 4 || j == 6 || j == 9 || j == 11)
				{day += 30 ;}
				else {day += 31;}

			}
		}

		if ( day % 7 == 0 )  printf("YES\n");
		else printf("NO\n");
		day = 0 ;

	}
	return 0 ;
}


int xgy(int year,int month1,int month2){
	int i,m,days=0;
	if(month1>month2){
		m=month1;
		month1=month2;
		month2=m;
	}
	for(i=month1;i<month2;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			days+=31;
		}
		else if(i==4||i==6||i==9||i==11){
			days+=30;
		}
		else if(i==2){
			if(year%400==0||(year%4==0&&year%100!=0)){
				days+=29;
			}
			else{
				days+=28;
			}
		}
	}
	if(days%7==0){return 1;}
	if(days%7!=0){return 0;}
}
int main(){
	int i,n,year,month1,month2;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year,&month1,&month2);
		if(xgy(year, month1, month2)){
			printf("YES\n");
		}
		else{printf("NO\n");}
	}
return 0;
}


int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int run(int year)
{
	if(year%4!=0)
		return 0;
	if(year%4==0)
	{
		if(year%100==0)
		{

		    if(year%400==0)
				return 1;
			else

			return 0;
		}
		else
			return 1;
	}
}

int main()
{

	int n,i,j,year,date1,date2,tem;
	int day[201]={0};

	scanf("%d",&n);
	for(i=1;i<n+1;i++)
	{
		scanf("%d%d%d",&year,&date1,&date2);
		month[2]=28;
		if(run(year))
			month[2]=29;
		if (date1>date2)
		{

			tem=date1;
			date1=date2;
			date2=tem;
		}
		for(j=date1;j<date2;j++)
		{
			day[i]+=month[j];
		}
	}

	for(i=1;i<n+1;i++)
	{

		if(day[i]%7==0)
			printf("YES\n");

		else

			printf("NO\n");
	}

	return 0;

}


int max(int b,int c);
int min(int b,int c);
int main(void)
{
	int i,j,k;
	int n,m;
	int a,b,c;
	scanf("%d",&n);
	int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	while(n--)
	{
		m=0;
		scanf("%d%d%d",&a,&b,&c);
		if(a%4==0&&(a%100)!=0||a%400==0)
		{
			if(b==1&&c==2||b==2&&c==1)
			{
				printf("NO\n");
				continue;
			}
			else if(c<=2&&b>2||c>2&&b<=2)
			{
				for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				    m++;
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
			}
			else if(c==b)
		{
				printf("NO\n");
					continue;
		}
			else
			{
				for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
			}
		}
		else if(c!=b)
		{
			for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
		}
		else if(c==b)
		{
				printf("NO\n");
					continue;
		}
	}
	return 0;
}
int max(int b,int c)
{
	if(b>c)
	    return b;
	return c;
}
int min(int b,int c)
{
	if(b<c)
	    return b;
	return c;
}


int main()
{
	int tianshu(int nian,int yue);
	int i,n,nian,yue1,yue2,dur;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&nian,&yue1,&yue2);
		dur=tianshu(nian,yue2)-tianshu(nian,yue1);
		if(dur%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
int tianshu(int nian,int yue)
{
	int i,result=0;
	for(i=1;i<=yue-1;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			result=result+31;
		else if(i==4||i==6||i==9||i==11)
			result=result+30;
		else if(i==2){
			if(nian%4==0&&nian%100!=0||nian%400==0)
				result=result+29;
			else
				result=result+28;
		}
	}
	return result;
}


int isRunNian(int year)
{
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0))
         {
		result = 1;
	}
          else
         {
		result = 0;
	}
      return result;
 }
 int DiJiTian(int year, int month, int day)
 {
	int result = 0;
         int i;
	for(i = 1; i < month; i++)
          {
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
                  {
			result += 31;
		}
                  else if (i == 4 || i ==6 || i == 9 || i==11)
                  {
			result += 30;
		}
                  else if(i == 2)
                  {
			if(isRunNian(year))
                             {
				result += 29;
			  }
                             else
                                {
				result += 28;
			     }
		}
	}
	result += day;
	return result;
}
 int main ()
  {
   int n,j;
   scanf("%d",&n);
   for(j=0;j<n;j++)
   {
     int a,b,c,d;
     scanf("%d%d%d",&a,&b,&c);
     d= DiJiTian(a,c,1)- DiJiTian(a,b,1);
     if(d%7==0)
     printf("YES\n");
     else
     printf("NO\n");
    }
 return 0;
}


int getday(int year,int month);

int main(){
	int n,j;
	scanf("%d",&n);
	int *a;
	a=(int *)malloc( sizeof(int) *n );
	for(j=0;j<n;j++){
		a[j]=0;
	}

	for(j=0;j<n;j++){

	int year1,month1,month2;
	int total1, total2, days;
	scanf("%d%d%d", &year1,&month1,&month2);
	total1 =getday(year1, month1);
	total2 =getday(year1, month2);

	days = total2-total1;

	if(days%7==0){
		a[j]=1;
	}
	else a[j]=0;
	}

	for(j=0;j<n;j++){
		if(a[j]==1){
			printf("YES\n");
		}
		else if(a[j]==0){
			printf("NO\n");
		}
	}

	return 0;
}

int getday(int year,int month)
{
	int total, i;

	total = 0;
	for( i=1; i<month; i++){
		if ( i ==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12){
			total = total +31;
		}
		if ( i ==4 || i==6 || i==9 || i==11){
			total = total +30;
		}
		if ( i ==2){
			if( (year%4==0&&year%100!=0) || year%400==0 ){
				total = total +29;
			}
			else{
				total = total +28;
			}
		}
	}
	total  =  total+1;

	return total;
}


int main()
{
	int n, year, month1, month2, leap, days, month;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		days =0;
		cin >> year >> month1 >> month2;
		if((year % 4 == 0 && year % 100 != 0) || year % 400 ==0)
			leap = 1;
		else
			leap = 0;
		if(month1 > month2)
		{
			for(month = month2; month < month1; month++)
			{
				switch(month)
				{
					case 1	:
					case 3	:
					case 5	:
					case 7	:
					case 8	:
					case 10	:
					case 12 : days += 31; break;
					case 4	:
					case 6	:
					case 9	:
					case 11 : days += 30; break;
					case 2 : days += 28 + leap; break;
				}
			}
		}
		if(month1 < month2)
		{
			for(month = month1; month < month2; month++)
			{
				switch(month)
				{
					case 1	:
					case 3	:
					case 5	:
					case 7	:
					case 8	:
					case 10	:
					case 12 : days += 31; break;
					case 4	:
					case 6	:
					case 9	:
					case 11 : days += 30; break;
					case 2 : days += 28 + leap; break;
				}
			}
		}
		if(days % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


int DiJiTian(int year, int month, int day);
int main(){
int year,montho,montht;
int n,i,k;
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%d %d %d",&year,&montho,&montht);
	k=DiJiTian(year,montht,1)-DiJiTian(year,montho,1);
	if(k%7==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
}

	return 0;
}
int DiJiTian(int year, int month, int day){
	int result = 0;
	for(int i = 1; i < month; i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(year%400==0||((year%4==0)&&(year%100!=0))){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result += day;
	return result;
}


int leapyear(int y);                             //???????
int monthday(int y,int m);                       //???????

void main()
{

	int n,year,month1,month2,i,j,temp,sum=0;

	scanf("%d",&n);

	for(i=1;i<=n;i++){
		scanf("%d%d%d",&year,&month1,&month2);
		if(month1>month2){               //?????
			temp=month1;
			month1=month2;
			month2=temp;
		}

		for(j=month1;j<month2;j++)       //??????????????
			sum+=monthday(year,j);
		if(sum%7==0) printf("YES\n");
		else printf("NO\n");
		sum=0;
	}
}

int leapyear(int y)
{
	if(y%400==0||(y%4==0&&y%100!=0))
		return 1;
	else return 0;
}

int monthday(int y,int m)
{
	if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
		return 31;
	else if(m==2)
		return 28+leapyear(y);
	else return 30;
}


int leapyear(int n)
{
    if(n%4==0&&n%100!=0||n%400==0)
    return 1;
    else
    return 0;
}
int lf(int m1,int m2)
{
    int max=m1,min=m2,k=0;
    if(m1<m2)
    {max=m2;min=m1;}
    switch(max)
    {
              case 12: k +=30;
              case 11: if(min==11) break; else k+=31;
              case 10: if(min==10) break; else k+=30;
              case 9: if(min==9) break; else k+=31;
              case 8: if(min==8) break; else k+=31;
              case 7: if(min==7) break; else k+=30;
              case 6: if(min==6) break; else k+=31;
              case 5: if(min==5) break; else k+=30;
              case 4: if(min==4) break; else k+=31;
              case 3: if(min==3) break; else k+=29;
              case 2: if(min==2) break; else k+=31;
              case 1: break;
    }
    if (k%7==0)
    return 1;
    else
    return 0;
}
int nf(int m1,int m2)
{
    int max=m1,min=m2,k=0;
    if(m1<m2)
    {max=m2;min=m1;}
    switch(max)
    {
              case 12: k +=30;
              case 11: if(min==11) break; else k+=31;
              case 10: if(min==10) break; else k+=30;
              case 9: if(min==9) break; else k+=31;
              case 8: if(min==8) break; else k+=31;
              case 7: if(min==7) break; else k+=30;
              case 6: if(min==6) break; else k+=31;
              case 5: if(min==5) break; else k+=30;
              case 4: if(min==4) break; else k+=31;
              case 3: if(min==3) break; else k+=28;
              case 2: if(min==2) break; else k+=31;
              case 1: break;
    }
    if (k%7==0)
    return 1;
    else
    return 0;
}
main()
{
      int e,n,m1,m2,t,k,i;
      scanf("%d",&e);
      for(i=0;i<e;i++)
      {
      scanf("%d",&n);
      scanf("%d %d",&m1,&m2);
      t=leapyear(n);
      if(t==1)
      k=lf(m1,m2);
      else
      k=nf(m1,m2);
      if(k==1)
      printf("YES\n");
      else
      printf("NO\n");
      }
}


/*???2011-12-30
 *??????
 *????08.cpp
 *????? - ??(10.5) ???
 */

int main()
{
	int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int n = 0;
	int year = 0;
	int month1 = 0;
	int month2 = 0;
	int days = 0;
	cin >> n;
	for (int temp = 0; temp < n; temp++)
	{
		cin >> year >> month1 >> month2;
		days = 0;
		if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
			month[2] = 29;
		else
			month[2] = 28;
		if (month1 < month2)
			for (int temp2 = month1; temp2 < month2; temp2++)
				days += month[temp2];
		else
			for (int temp2 = month2; temp2 < month1; temp2++)
				days += month[temp2];
		if (days % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


int main()
{
int n,year,m1,m2,x=0,i,m,a,b;
scanf("%d",&n);
for(i=0;i<n;i++)
{
   scanf("%d %d %d",&year,&m1,&m2);
       if(m1<m2)
	   {
		   a=m1;
		   b=m2;
	   }
	   else
	   {a=m2;
	   b=m1;
	   }

   if((year%4==0 && year%100!=0)||(year%400==0))
   {

    for(m=a;m<b;m++)
    {
    switch(m)
    {
     case 1:x +=31;break;
     case 3:x +=31;break;
     case 5:x +=31;break;
     case 7:x +=31;break;
     case 8:x +=31;break;
     case 10:x +=31;break;
     case 12:x +=31;break;
     case 2:x +=29;break;
     default :x +=30;
    }

    }

    if(x%7==0){
     printf("YES\n");
    }
    else
		printf("NO\n");x=0;}
    else
   {
    for(m=a;m<b;m++)
    {
    switch(m)
    {
     case 1:x +=31;break;
     case 3:x +=31;break;
     case 5:x +=31;break;
     case 7:x +=31;break;
     case 8:x +=31;break;
     case 10:x +=31;break;
     case 12:x +=31;
      break;
     case 2:x +=28;
      break;
     default :x +=30;
    }

    }
 if(x%7==0){
     printf("YES\n");
    }
 else{
     printf("NO\n");
	x=0;
   }
	}
}
return 0;
}


int main()
{
int n,year,month1,month2;
int leap;
int days=0;
cin>>n;
while(n--)
{
cin>>year>>month1>>month2;
int temp;
if(month1>month2)
{
	temp=month2;
	month2=month1;
	month1=temp;
}
if(year%400==0||(year%4==0&&year%100!=0))
	leap=0;
else leap=1;
int day[2][12]={31,29,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30,31,30,31};
for(int i=month1;i<month2;i++)
	days+=day[leap][i-1];
if(days%7==0)
	cout<<"YES"<<endl;
else cout<<"NO"<<endl;
days=0;
}

return 0;
}


int main()
{
	int n,a[10000],b[10000],c[10000],i=0,s,m;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
		if(a[i]%4!=0||a[i]%100==0&&a[i]%400!=0)
		{
			switch(b[i])
			{
			case 1:s=1;break;
			case 2:s=32;break;
			case 3:s=60;break;
			case 4:s=91;break;
			case 5:s=121;break;
			case 6:s=152;break;
			case 7:s=182;break;
			case 8:s=213;break;
			case 9:s=244;break;
			case 10:s=274;break;
			case 11:s=305;break;
			case 12:s=335;break;
			default :;
			}
			switch(c[i])
			{
				case 1:m=1;break;
			case 2:m=32;break;
			case 3:m=60;break;
			case 4:m=91;break;
			case 5:m=121;break;
			case 6:m=152;break;
			case 7:m=182;break;
			case 8:m=213;break;
			case 9:m=244;break;
			case 10:m=274;break;
			case 11:m=305;break;
			case 12:m=335;break;
			default :;
			}
		}
		else
		{
				switch(b[i])
			{
			case 1:s=1;break;
			case 2:s=32;break;
			case 3:s=61;break;
			case 4:s=92;break;
			case 5:s=122;break;
			case 6:s=153;break;
			case 7:s=183;break;
			case 8:s=214;break;
			case 9:s=245;break;
			case 10:s=275;break;
			case 11:s=306;break;
			case 12:s=336;break;
			default :;
			}
			switch(c[i])
			{
				case 1:m=1;break;
			case 2:m=32;break;
			case 3:m=61;break;
			case 4:m=92;break;
			case 5:m=122;break;
			case 6:m=153;break;
			case 7:m=183;break;
			case 8:m=214;break;
			case 9:m=245;break;
			case 10:m=275;break;
			case 11:m=306;break;
			case 12:m=336;break;
			default :;
			}
		}
		if((abs(s-m))%7==0)
			cout<<"YES";
		else
			cout<<"NO";
		cout<<endl;
		s=0;
		m=0;
	}
	return 0;
}


int main()
{
	int n;
	int i,j;
	int year,m1,m2;
	int length1=0,length2=0;
	int length;
	int A[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int B[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(i=0;i<n;i++)
	{
        length1=0;length2=0;
		cin>>year>>m1>>m2;

	if(year%4==0&&year%100!=0||year%400==0)
	{
		for(j=1;j<m1;j++)
			length1=A[j]+length1;
		for(j=1;j<m2;j++)
            length2=A[j]+length2;
		length=abs(length1-length2);
	}
	else
	{
		for(j=1;j<m1;j++)
			length1=B[j]+length1;
		for(j=1;j<m2;j++)
            length2=B[j]+length2;
		length=abs(length1-length2);
	}
	if(length%7==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	}

	return 0;
}


int runnian(int n);
int day(int m);
int main()
{
	int n,y,m1,m2;
	int i;
	int e,da;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2)
		{
			e=m1;
			m1=m2;
			m2=e;
		}
		if((m1==1||m1==2)&&(m2!=1&&m2!=2)&&runnian(y)==1)
		{
			da=day(m2)-day(m1)+1;
		}
		else
			da=day(m2)-day(m1);
	if(da%7==0)
		printf("YES\n");
	else printf("NO\n");
	}
	return 0;
}
int runnian(int n)
{
	if(n%400==0)
		return 1;
	else if(n%100==0)
		return 0;
	else if(n%4==0)
		return 1;
	else return 0;
}
int day(int m)
{
	int num;
	if(m==1)
		num=0;
	else if(m==2)
		num=31;
	else if(m==3)
		num=59;
	else if(m==4)
		num=90;
	else if(m==5)
		num=120;
	else if(m==6)
		num=151;
	else if(m==7)
		num=181;
	else if(m==8)
		num=212;
	else if(m==9)
		num=243;
	else if(m==10)
		num=273;
	else if(m==11)
		num=304;
	else if(m==12)
		num=334;
	return num;
}


int DiJiTian(int year, int month);
int isRunNian(int year);

int main(){
	int n,i;
	int year[200],mon1[200],mon2[200],a[200];

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d %d",&year[i],&mon1[i],&mon2[i]);
	}

	for(i=0;i<n;i++){
		a[i]=DiJiTian(year[i],mon1[i])-DiJiTian(year[i],mon2[i]);
		a[i]=(a[i]>=0?a[i]:(0-a[i]));
	}

	for(i=0;i<n;i++){
		if(a[i]%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}

	return 0;
}

int DiJiTian(int year, int month){
	int result = 0;
	int day=1;
	for(int i = 1; i < month; i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result += day;
	return result;
}

int isRunNian(int year){
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
		result = 1;
	} else{
		result = 0;
	}
      return result;
}


int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int b[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int judge[100];
int main()
{
    memset(judge,0,sizeof judge);
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        int year,month1,month2;
        cin>>year>>month1>>month2;
        if(month1>month2)
        {
            int temp=month1;
            month1=month2;
            month2=temp;
        }
        int day=0,j;

        if(month1==month2) day=0;
        else if((year%4==0&&year%100!=0)||year%400==0)
        {
            for(j=month1;j<month2;j++)  day+=b[j];
        }
        else
        {
            for(j=month1;j<month2;j++) day+=a[j];
        }
        if(day%7==0) judge[i]=1;
        else judge[i]=0;

    }
    for(i=1;i<=n;i++)
    {

        if(judge[i]==1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

    return 0;
}


/*
 * 1.cpp
 *
 *  Created on: 2012-11-2
 *      Author: 99003
 */

int luna(int year)
{
	if (year%400==0) return 1;
	if(year%100==0) return 0;
	if(year%4==0) return 1;
	else return 0;}
int main(){
	int year,month1,month2,day;
	int n;
	int mon[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(;n>=1;n--){
		day=0;
		cin>>year>>month1>>month2;
		mon[2]=mon[2]+luna(year);
		if(month1-month2>0)
		{
			for(;month2<month1;month2++)
			{
				day=day+mon[month2];
			}
		}
		if(month1-month2<0)
				{
					for(;month1<month2;month1++)
					{
						day=day+mon[month1];
					}
				}
		if(day%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
		mon[2]=28;
	}
	return 0;
}


int Run(int);
int DI(int,int);
int main()
{
	int n,j,m;
	int year[200],month[200][2],a[200];
		scanf("%d",&n);
	for(m=0;m<n;m++){
		scanf("%d %d %d",&year[m],&month[m][0],&month[m][1]);
		if((DI(year[m],month[m][1])-DI(year[m],month[m][0]))%7==0)
			a[m]=1;
		else
			a[m]=0;
	}
	for( j=0;j<n;j++){
		if(a[j]==1)
	printf("YES\n");
		else
	printf("NO\n");}
return 0;
}

	int DI(int year,int month)
	{
		int i;
		int Run(int);
	int total=1;
	for(i=1;i<month;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			total+=31;
		else if(i==4||i==6||i==9||i==11)
			total+=30;
		else if(i==2){
			if(Run(year)){
				total+=29;
			}else {
				total+=28;
			}
	}}

		return total;

}
int Run(int year){

		int result=0;
		if(year%400==0||(year%4==0&&year%100!=0)){
			result=1;
		}else {
			result=0;
	}
	return result;
	}


int run(int a)
{ int day;
if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	day=3;
else if(a==2)
	day=1;
else day=2;
return(day);
}

int feirun(int a)
{ int day;
if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	day=3;
else if(a==2)
	day=0;
else day=2;
return(day);
}

int main()
{
	int n,sum;
	cin>>n;
	int year[300],mon1[300],mon2[300];
	int i,j;
	for(i=0;i<n;i++)
	{
		cin>>year[i]>>mon1[i]>>mon2[i];
	}

	for(i=0;i<n;i++)
	{
		sum=0;
		if(year[i]%400==0||year[i]%4==0&&year[i]%100!=0)
		{
			if(mon1[i]>mon2[i])
			{
				for(j=mon2[i];j<mon1[i];j++)
				{
					sum=sum+run(j);
				}
			}
			else
			{
				for(j=mon1[i];j<mon2[i];j++)
				{
					sum=sum+run(j);
				}
			}
		}
		else
			{
			if(mon1[i]>mon2[i])
			{
				for(j=mon2[i];j<mon1[i];j++)
				{
					sum=sum+feirun(j);
				}

			}
			else
			{
				for(j=mon1[i];j<mon2[i];j++)
				{
					sum=sum+feirun(j);
				}

			}
		}
		if(sum%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
	}
	return 0;
}


int leap(int a)
{
    if (((a % 4 == 0) && (a % 100 != 0)) || a % 400 == 0) return 1;
    else return 0;
}

int bigger(int a, int b)
{
    if (a >= b) return a;
    else return b;
}

int main()
{
    int n, year, month1, month2, big, small, countdays;
    int days[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                       {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> year >> month1 >> month2;
        big = bigger(month1, month2);
        small = month1 + month2 - big;
        countdays = 0;
        for (int j = small - 1; j < big - 1; j++)
        {
            countdays += days[leap(year)][j];
        }
        if (countdays % 7 == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}


int main()
{
	int n, k, year, mon, mona, monb, monc, leap, days;
	cin >> n;
	for (k = 1; k <= n; k++)
	{
		days = 0;
		cin >> year >> mona >> monb;
		leap = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
		if (mona < monb)
		{
		}
			else
			{
				monc = mona;
				mona = monb;
				monb = monc;
			}
			for (mon = mona; mon <= monb - 1; mon++)
			{
				switch (mon)
				{
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					{
						days += 31;
						break;
					}
				case 4:
				case 6:
				case 9:
				case 11:
					{
						days += 30;
						break;
					}
				case 2:
					{
						days += 28 + leap;
						break;
					}
				}
			}
			//cout << "days=" << days << endl;
			if (days % 7 == 0)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
	}
	return 0;

}


int leapyear(int year)
{
	if (year%400==0 || (year%4==0 && year%100!=0))
		return 1;
	return 0;
}

int daycount(int year,int month)
{
	int i, sum=0;
	for (i=1;i<month;i++)
		if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
			sum+=31;
		else if (i==4 || i==6 || i==9 || i==11)
			sum+=30;
		else if (i==2 && leapyear(year))
			sum+=29;
		else sum+=28;
	return sum;
}
int main()
{
	int n,i;
	int year[200],month1[200],month2[200];
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%d%d%d",&year[i],&month1[i],&month2[i]);

	for (i=0;i<n;i++)
		if (abs(daycount(year[i],month1[i])-daycount(year[i],month2[i]))%7==0)
			printf("YES\n");
		else printf("NO\n");
	return 0;
}


int main()
{
	int n, i, a;
	int year, month1, month2;
	int day = 0;

	scanf("%d",&n);
	for (i = 0; i < n; i++){
		day=0;
		scanf("%d%d%d",&year,&month1,&month2);
		if (month1 > month2){
			a = month1;
			month1 = month2;
			month2 = a;
		}

		for (;;){
			if (month1 == month2){
				break;
			}

			if(month1 == 1 || month1 == 3 || month1 == 5 || month1 == 7 || month1 == 8 || month1 == 10 || month1 == 12){
				day = day + 31;
				month1++;
				continue;
			}
			if (month1 == 4 || month1 == 6 || month1 == 9 || month1 == 11){
				day = day + 30;
				month1++;
				continue;
			}
			if (month1 == 2){
				if ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0){
					day = day + 29;
					month1++;
					continue;
				}
				else {
					day = day + 28;
					month1++;
					continue;
				}
			}
		}
		if(day % 7 == 0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}


int main()
{
	int rnfeb(int year);
	int n,year,month1,month2,e,i,j,day,num=0;
	scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d %d",&year,&month1,&month2);
			if(month1<month2){
				e=month1;
				month1=month2;
				month2=e;
			}
			num=0;
			for(j=month2;j<month1;j++){
				if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){
					day=31;
				}
				else if(j==4||j==6||j==9||j==11){
					day=30;
				}
				else if(j==2){
					day=rnfeb(year);
				}
				num+=day;
			}
			if(num%7==0){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}
	return 0;
}
int rnfeb(int year){
	int z;
	if((year%4==0&&year%100!=0)||(year%400==0)){
		z=29;
	}else{
		z=28;
	}
	return (z);
}


int Run(int year)
{
	if(year%400==0||(year%100!=0&&year%4==0))
	{
		return 1;
	}
	else{
		return 0;
	}
}
int Day(int year,int month1,int month2,int j,int day)
{
	if(month1>month2)
	{
		day=month1;
		month1=month2;
		month2=day;
	}
	day=0;
	for(j=month1;j<month2;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
		{
			day+=31;
		}else if((j==4||j==6||j==9||j==11)){
			day+=30;
		}else{
			if(Run(year)==0)
			{
				day+=28;
			}else{
				day+=29;
			}
		}
	}
	return day;
}

int main(int argc, char* argv[])
{

	int i,j=1,n,year,month1,month2,day;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&month1,&month2);
		day=Day(year,month1,month2,j,day);
		if(day%7==0)
		{
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}


int isrunnian(int year){
	int result;
	if(year%400==0||(year%4==0&&year%100!=0)){
		result=1;
	}
	else{
		result=0;
	}
	return result;
}
int dijitian(int year,int month,int day){
	int result=0;
	for(int i=1;i<month;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result+=31;
		}
		else if(i==4||i==6||i==9||i==11){
			result+=30;
		}
		else if(i==2){
			if(isrunnian(year)){
				result+=29;
			}
			else{
				result+=28;
			}
		}
	}
	result+=day;
	return result;
}
int main(){
	int n,i;
	int year,month1,month2,a,b,day=1;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d ",&year);
		scanf("%d ",&month1);
		scanf("%d\n",&month2);
		a=dijitian(year,month1,day);
		b=dijitian(year,month2,day);
		if((b-a)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


/*
 * Author : houchenglong
 * 2014.1.5
 *
 */
int main()
{
	int n,year,month1,month2,sum=0,i,j;
	int Mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>year>>month1>>month2;
		if(year%400==0||(year%100!=0&&year%4==0))
		{
			Mon[1]=Mon[1]+1;
			if(month1>month2)
			{
				for(j=month2;j<month1;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
			else
			{
				for(j=month1;j<month2;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
		}
		else
		{
			if(month1>month2)
			{
				for(j=month2;j<month1;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
			else
			{
				for(j=month1;j<month2;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
		}
		sum=0;
		Mon[1]=28;
	}
	return 0;
}


int normal_months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_months[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int is_leap(int year) {
	if (year % 100 == 0)
		return year % 400 == 0;

	return year % 4 == 0;
}

int day_of_year(int year, int month, int day) {
	int *months = is_leap(year) ? leap_months : normal_months;

	int days = 0;
	int i;
	for ( i = 0; i < month - 1; i++)
		days += months[i];

	days += day;

	return days;
}

int main() {
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		int year, month1, month2;
		scanf("%d%d%d", &year, &month1, &month2);
		int days1 = day_of_year(year, month1, 1);
		int days2 = day_of_year(year, month2, 1);

		if ((days1 - days2) % 7 == 0)
			printf("YES\n");
		else
			printf("NO\n");
	}
}


int isRunNian(int year){
    int result;
    if(year%400==0||year%4==0&&year%100!=0){
       result=1;
    }
    else{
       result=0;
    }
    return result;
}
int DijiTian(int year,int month,int day){
    int result=0;
    for(int i=1;i<month;i++){
        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
            result+=31;
        }else if(i==4||i==6||i==9||i==11){
            result+=30;
        }else if(i==2){
            if(isRunNian(year)){
                result+=29;
            }else{
                result+=28;
            }
        }
    }
    result+=day;
    return result;
}
void swap(int*a,int*b){
     int e;
     e=*a;
     *a=*b;
     *b=e;
}
int DijiTian(int year,int month,int day);
int isRunNian(int year);
void swap(int*a,int*b);
int main()
{
    int n,year,month1,month2;
    int a,i,sz[200];
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&year,&month1,&month2);
        if(month1>month2){
            swap(&month1,&month2);
        }
        a=DijiTian(year,month2,1)-DijiTian(year,month1,1);
        if(a%7==0){
           printf("YES\n");
        }
        else printf("NO\n");
    }
    return 0;
}


int main()
{
    int n;
    int year;
    int month1,month2;
    int pingnian[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int runnian[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int buffer;

    cin >> n;

    for (int i = 0; i< n; i++) {
        cin >> year >> month1 >> month2;
        if (month1 > month2) {
            buffer = month1;
            month1 = month2;
            month2 = buffer;
        }

        buffer = 0;
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            for (int j = month1; j < month2; j++)
                buffer = buffer + runnian[j - 1];
            if (buffer % 7 == 0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }

        else {
            for (int j = month1; j < month2; j++)
                buffer = buffer + pingnian[j - 1];
            if (buffer % 7 == 0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }

    }
    return 0;
}


int isRunNian(int year){
    int result;
    if(year%400 == 0 ||(year%4==0 &&year%100!=0)){
        result = 1;
	}
    else{
        result = 0;
	}
return result;
}
int DiJiTian(int year, int month, int day){
    int result = 0;
    for(int i = 1; i < month; i++){
        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
            result += 31;
		}
        else if (i == 4 || i ==6 || i == 9 ||i==11){
            result += 30;
		}
        else if(i == 2){
            if(isRunNian(year)){
				result += 29;
			}
			else {
				result += 28;
			}
		}
	}
	result += day;
return result;
}
int main(){
    int n,i,y,m1,m2;
	int d1,d2;
	int cha;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d%d%d",&y,&m1,&m2);
		d1=DiJiTian(y,m1,1);
		d2=DiJiTian(y,m2,1);
		if((d1-d2)<0)
			cha=d2-d1;
		else
			cha=d1-d2;
		if(cha%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
return 0;
}


int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int is_year(int x)
{

	if(x%4!=0)
	   return 0;
      else if((x%4==0)&&(x%100!=0))
		return 1;
      else
    	  if(x%400==0)
    		  return 1;
    	  else return 0;
}
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
	  int year,month1,month2,day1=1,day2=1;
      cin>>year>>month1>>month2;
      if(is_year(year))
    	  m[2]=29;
      for(int i=1;i<month1;i++)
    	  day1+=m[i];
      for(int i=1;i<month2;i++)
    	  day2+=m[i];
      m[2]=28;
      if((abs(day2-day1))%7==0)
    	  cout<<"YES"<<endl;
      else
    	  cout<<"NO"<<endl;

  }

return 0;
}


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

//#include "stdafx.h"
int main()
{
	int i,n,year,runfou,er,mon1,mon2,k,j,day;
	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		day=0;
		scanf("%d%d%d", &year,&mon1,&mon2);
		if (year%4==0)
			if (year%100==0)
				if (year%400==0)
					runfou=1;
				else
					runfou=0;
			else
				runfou=1;
		else
			runfou=0;
		if (runfou==0)
			er=28;
		else
			er=29;
		if (mon1>mon2)
		{
			k=mon2;
			j=mon1;
		}
		else if (mon1<mon2)
		{
			k=mon1;
			j=mon2;
		}
		else
			printf("YES\n");
		for (;k<j;k++)
		{
			switch (k)
			{
			case 1:day+=31;break;
			case 2:day+=er;break;
			case 3:day+=31;break;
			case 4:day+=30;break;
			case 5:day+=31;break;
			case 6:day+=30;break;
			case 7:day+=31;break;
			case 8:day+=31;break;
			case 9:day+=30;break;
			case 10:day+=31;break;
			case 11:day+=30;break;
			case 12:day+=31;break;
			}
		}
	//	printf(":%d\n", day);
		if (day%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int days[11]={31,0,31,30,31,30,31,31,30,31,30},year=0,month1=0,month2=0,i=0,j=0,n=0,mid=0,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&month1,&month2);
		if((year%400==0)||((year%4==0)&&(year%100!=0)))
			days[1]=29;
		else days[1]=28;
		if(month1>month2)
		{
			mid=month1;
			month1=month2;
			month2=mid;
		}
		total=days[month1-1];
		for(j=0;j<month2-month1-1;j++)
		{
			total+=days[month1+j];
		}
		if(i!=n-1)
		{
			if(total%7==0)
			{
				printf("YES\n");
			}
			else printf("NO\n");
		}
		if(i==n-1)
		{
			if(total%7==0)
			{
				printf("YES");
			}
			else printf("NO");
		}
	}
	return 0;
}


int main()
{
    int i,j,k,m,n;
    int *y,*m1,*m2;
    y=(int *)malloc(200*sizeof(int));
    m2=(int *)malloc(200*sizeof(int));
    m1=(int *)malloc(200*sizeof(int));
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d %d %d",y+i,m1+i,m2+i);
    }
    void judge(int x,int y,int z);
    for(i=0;i<n;i++)
    {
                    if(i>0)
                    {
                           printf("\n");
                    }
                    judge(*(y+i),*(m1+i),*(m2+i));
    }
    return 0;
}

void judge(int x,int y,int z)
{
     int i,j,a;
     int p(int x);
     int r(int x);
     if((x%4==0&&x%100!=0)||x%400==0)
     {
                                     i=r(y);
                                     j=r(z);
     }
     else
     {
         i=p(y);
         j=p(z);
     }
     if(i>j)
     {
            a=(i-j)%7;
     }
     else
     {
         a=(j-i)%7;
     }
     if(a==0)
     {
             printf("YES");
     }
     else
     {
         printf("NO");
     }
}

int p(int x)
{
     int i;
     switch(x)
     {
               case 1:i=0;break;
               case 2:i=31;break;
               case 3:i=59;break;
               case 4:i=90;break;
               case 5:i=120;break;
               case 6:i=151;break;
               case 7:i=181;break;
               case 8:i=212;break;
               case 9:i=243;break;
               case 10:i=273;break;
               case 11:i=304;break;
               case 12:i=334;break;
     }
     return i;
}

int r(int x)
{
     int i;
     switch(x)
     {
               case 1:i=0;break;
               case 2:i=31;break;
               case 3:i=59+1;break;
               case 4:i=90+1;break;
               case 5:i=120+1;break;
               case 6:i=151+1;break;
               case 7:i=181+1;break;
               case 8:i=212+1;break;
               case 9:i=243+1;break;
               case 10:i=273+1;break;
               case 11:i=304+1;break;
               case 12:i=334+1;break;
     }
     return i;
}


int main(int argc, char* argv[])
{
	int n;
	scanf("%d", &n);
	int a, b, c, l, i;
	for(i=0; i<n; i++){
		scanf("%d%d%d", &a, &b, &c);
		if((a%400==0)||(a%4==0&&a%100!=0))
			l=29;
		else
			l=28;
		if(b>c){
			int x=b;
			b=c;
			c=x;
		}
		int j, sum=0;
		for(j=b; j<c; j++){
			switch(j){
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:sum=sum+31;continue;
			case 4:
			case 6:
			case 9:
			case 11:sum=sum+30;continue;
			case 2:sum=sum+l;
			}
		}
		if(sum%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


int isRunNian(int year)
{
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
		result = 1;
	} else{
		result = 0;
	}
      return result;
}
int DiJiTian(int year,int m1,int m2){
	int result = 0;
	for(int i = m1; i < m2; i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	if(result%7==0) return 1;
	else return 0;
}

int main()
{
	int n,i,year[1000],m1[1000],m2[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++){
		if(m1[i]<m2[i]){
			if(DiJiTian(year[i],m1[i],m2[i])) printf("YES\n");
			else printf("NO\n");
		}
		else{
			if(DiJiTian(year[i],m2[i],m1[i])) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}


int main()
{
    int n,i,j,year,month1,month2,day=0;
    int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    cin>>n;
    while(n--)
    {         day=0;
              cin>>year>>month1>>month2;
              if(month1>month2)
              { i=month1;month1=month2;month2=i;}
              if((year%4==0&&year%100!=0)||year%400==0)
              {
              for(i=month1-1;i<month2-1;i++)
              day=day+a[i];
              }
              else
              {for(i=month1-1;i<month2-1;i++)
              day=day+a[i];
              if(month1<=2&&month2>2) day=day-1;}
              if(day%7==0) cout<<"YES"<<endl;
              else cout<<"NO"<<endl;
              }
              return 0;
              }


int main(){
	int n,year,month1,month2,days=0,i,detmonth,a;
	cin >> n;
	for(i=1;i<=n;i++)
	{
	cin >> year >> month1 >> month2;
	if(month1>month2)
		{a = month2;
		month2 = month1;
		month1 = a;}
	detmonth = month2 - month1;
	for(;detmonth>0;month1++,detmonth--)
		{if(month1==4||month1==6||month1==9||month1==11)
			days += 30;
		else if(month1 ==2)
		{if(((year%4 == 0) &&(year % 100 != 0 ))||(year % 400 == 0))
				days += 29;
				else days += 28;}
		else days += 31;}
	if(days % 7 == 0)
		cout <<"YES"<<endl;
	else cout <<"NO"<<endl;
	days = 0;
	}
	return 0;
}


int isRunNian(int year);
int main()
{
	int a,b,c,e,n,k,i,result;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		result=0;
		scanf("%d%d%d",&a,&b,&c);
		if(b>c)
		{
			e=b;
			b=c;
			c=e;
		}
		for(int i=b;i<c;i++)
		{
			if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			{
				result += 31;
			}
			else if (i==4||i==6||i==9||i==11)
			{
				result+=30;
			}
			else if(i==2)
			{
				if(isRunNian(a))
				{
					result+=29;
				}
				else
				{
					result+=28;
				}
			}
		}
		if(result%7==0)
		{printf("YES\n");
		}
		else
		{printf("NO\n");}

	}

	return 0;
}

         int isRunNian(int year){
	int ss;
	if(year%400==0||(year%4==0&&year%100!=0)){
		ss=1;
	} else{
		ss=0;
	}
      return ss;
}


int main(){
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		int year,month[2],dijitian=0;
		scanf("%d%d%d",&year,&month[0],&month[1]);
		int ex;
		if(month[0]>month[1]){ex=month[1];month[1]=month[0];month[0]=ex;}
		for(int k=month[0];k>=month[0]&&k<month[1];k++){
			if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)dijitian+=31;
			if(k==4||k==6||k==9||k==11)dijitian+=30;
			if(k==2){if(year%4==0&&year%100!=0||year%400==0)dijitian+=29;else dijitian+=28;}
		}
		if(dijitian%7==0)printf("YES\n");
		else printf("NO\n");

	}
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	int year,month1,month2;
	int i,j;
	int t;
	int res;

	for (i=0;i<n;i++)
	{
        scanf("%d%d%d",&year,&month1,&month2);
		res=0;
		if (month1>month2)
		{
            t=month1;
			month1=month2;
			month2=t;
		}
        for (j=month1;j<month2;j++)
		{
			if (j==2)
				continue;
			if (j==1||j==3||j==5||j==7||j==8||j==10)
				res=res+3;
			if (j==4||j==6||j==9||j==11)
				res=res+2;
		}
		if (month1<=2)
		{
			if (year%4!=0||year%100==0&&year%400!=0)
			{
				res=res;
			}
			else
			{
				res=res+1;
			}
		}
		if (res%7==0)
			printf("YES\n");
		else
			printf("NO\n");

	}

	return 0;
}


//============================================================================
// Name        : ex3.37.cpp
// Author      : Zhang Yu
// Version     :
// Copyright   : Your copyright notice
// Description : ???
//============================================================================

int main() {
	int n;
	cin >>n;
	for (int i=1;i<=n;++i)
	{
		int year,month1,month2,deltaday=0;
		cin >>year>>month1>>month2;
		if (month1>month2)
		{
			int exchange=month2;
			month2=month1;
			month1=exchange;
		}
		if (((year%400)==0)||((year%100!=0)&&(year%4==0)))
		{
			for (int j=month1;j<=month2-1;++j)
			{
				switch (j)
				{
				case 1:deltaday+=31;break;
				case 2:deltaday+=29;break;
				case 3:deltaday+=31;break;
				case 4:deltaday+=30;break;
				case 5:deltaday+=31;break;
				case 6:deltaday+=30;break;
				case 7:deltaday+=31;break;
				case 8:deltaday+=31;break;
				case 9:deltaday+=30;break;
				case 10:deltaday+=31;break;
				case 11:deltaday+=30;break;
				}
			}
		}
		else
		{
			for (int j=month1;j<=month2-1;++j)
			{
				switch (j)
				{
				case 1:deltaday+=31;break;
				case 2:deltaday+=28;break;
				case 3:deltaday+=31;break;
				case 4:deltaday+=30;break;
				case 5:deltaday+=31;break;
				case 6:deltaday+=30;break;
				case 7:deltaday+=31;break;
				case 8:deltaday+=31;break;
				case 9:deltaday+=30;break;
				case 10:deltaday+=31;break;
				case 11:deltaday+=30;break;
				}
			}
		}
		if ((deltaday)%7==0)
			cout <<"YES"<<endl;
		else
			cout <<"NO"<<endl;
	}
	return 0;
}


int main(){
	int n,i;
	int year,mon1,mon2;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year,&mon1,&mon2);
		if((year%100!=0&&year%4==0)||(year%100==0&&year%400==0))/*runnian*/{
			if(mon1>mon2){
				int t;
				t=mon1;
				mon1=mon2;
				mon2=t;
			}
			int days=0,j;
			int m;
			m=mon1;
			for(j=0;j<mon2-mon1;j++){
				if(m==1||m==3||m==5||m==7||m==8||m==10){
					days=days+31;
				}
				else if(m==2){
					days=days+29;
				}
				else{
					days=days+30;
				}
				m=m+1;
			}
			if(days%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else{
if(mon1>mon2){
				int t;
				t=mon1;
				mon1=mon2;
				mon2=t;
			}
			int days=0,j;
			int m;
			m=mon1;
			for(j=0;j<mon2-mon1;j++){
				if(m==1||m==3||m==5||m==7||m==8||m==10){
					days=days+31;
				}
				else if(m==2){
					days=days+28;
				}
				else{
					days=days+30;
				}
				m=m+1;
			}
			if(days%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
		return 0;
	}


int DiJiTian(int year,int month);
int main(int argc, char* argv[])
{
	int  n,year,m1,m2,c,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&m1,&m2);
		c=abs(DiJiTian(year,m1)-DiJiTian(year,m2));
		if(c%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
		return 0;
}
int DiJiTian(int year,int month){
	int i,result;
	result=1;
	for(i=1;i<month;i++)
	{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result+=31;
		}
		else if(i==4||i==6||i==9||i==11){
			result+=30;
		}else if(i==2){
			if(year%400==0||(year%100!=0&&year%4==0)){
				result+=29;
			}else{
				result+=28;
			}
		}
	}
			return result;
}


int main()
{
	int leap, day, i, n, y, dy, de, m, k = 0, z;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> y >> dy >> de;
		if (dy > de)
		{
			z = dy;
			dy = de;
			de = z;
		}
		leap = y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
		for (m = dy; m <= de - 1; m++)
		{
			switch (m)
			{
				case 1:
					day = 31;break;
				case 2:
					day = 28 + leap;break;
				case 3:
					day = 31;break;
				case 4:
					day = 30;break;
				case 5:
					day = 31;break;
				case 6:
					day = 30;break;
				case 7:
					day = 31;break;
				case 8:
					day = 31;break;
				case 9:
					day = 30;break;
				case 10:
					day = 31;break;
				case 11:
					day = 30;break;
				case 12:
					day = 31;break;
			}
			k = k + day;
		}
		if (k % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		k = 0;
	}
	return 0;
}


int main()
{
	int n, i, a, b, c, d, B, C;
	cin>>n;
	for ( i = 1; i <= n; i++ )
	{
		cin>>a>>b>>c;
		if ( ( a % 400 == 0 ) || ( a % 4 == 0 )
			 && ( a % 100 != 0 ) )
		{
			if ( b > c )
			{
				d = c; c = b; b = d;
			}
			switch ( b )
			{ case 1: B = 0;break;
			{ case 2: B = 31;break; }
			{ case 3: B = 60;break; }
			{ case 4: B = 91;break; }
			{ case 5: B = 121;break; }
			{ case 6: B = 152;break; }
			{ case 7: B = 182;break; }
			{ case 8: B = 213;break; }
			{ case 9: B = 244;break; }
			{ case 10: B = 274;break; }
			{ case 11: B = 305;break; }
			{ default: B = 335;break; }
			}
			switch ( c )
			{ case 1: C = 0;break;
			{ case 2: C = 31;break; }
			{ case 3: C = 60;break; }
			{ case 4: C = 91;break; }
			{ case 5: C = 121;break; }
			{ case 6: C = 152;break; }
			{ case 7: C = 182;break; }
			{ case 8: C = 213;break; }
			{ case 9: C = 244;break; }
			{ case 10: C = 274;break; }
			{ case 11: C = 305;break; }
			{ default: C = 335;break; }
			}
			if ( ( C - B ) % 7 == 0 )
				cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else
		{
			if ( b > c )
			{
				d = c; c = b; b = d;
			}
			switch ( b )
			{ case 1: B = 0;break;
			{ case 2: B = 31;break; }
			{ case 3: B = 59;break; }
			{ case 4: B = 90;break; }
			{ case 5: B = 120;break; }
			{ case 6: B = 151;break; }
			{ case 7: B = 181;break; }
			{ case 8: B = 212;break; }
			{ case 9: B = 243;break; }
			{ case 10: B = 273;break; }
			{ case 11: B = 304;break; }
			{ default: B = 334;break; }
			}
			switch ( c )
			{ case 1: C = 0;break;
			{ case 2: C = 31;break; }
			{ case 3: C = 59;break; }
			{ case 4: C = 90;break; }
			{ case 5: C = 120;break; }
			{ case 6: C = 151;break; }
			{ case 7: C = 181;break; }
			{ case 8: C = 212;break; }
			{ case 9: C = 243;break; }
			{ case 10: C = 273;break; }
			{ case 11: C = 304;break; }
			{ default: C = 334;break; }
			}
			if ( ( C - B) % 7 == 0 )
				cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}


int main()
{
	int n,year,m1,m2,x=0,m,i,a,b;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>year>>m1>>m2;
		{
			if (m1<m2) a=m1,b=m2;
			else if (m2<m1) a=m2,b=m1;
		}
		if((year%4==0 && year%100!=0)||(year%400==0))
		{
			for (m=a;m<b;m++)
			{
				switch(m)
				{
				case 1:     case 3:     case 5:     case 7:
				case 8:     case 10:     case 12:x+=31;break;
				case 2:x+=29;break;
				default :x+=30;
				}
			}
			if (x%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			x=0;

		}
		else
		{
			for (m=a;m<b;m++)
			{
				switch(m)
				{
				case 1:     case 3:     case 5:     case 7:
				case 8:     case 10:     case 12:x+=31;break;
				case 2:x+=28;break;
				default :x+=30;
				}
			}
			if (x%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			x=0;

		}
	}
	return 0;
}


int main()
{
	int n;
	cin>>n;
	int judge=0;
	int dayofmonth[13]={31,28,31,30,31,30,31,31,30,31,30,31};
  int year,month1,month2;
for(int inputtime=1;inputtime<=n;inputtime++)
{judge=0;
  cin>>year>>month1>>month2;
  dayofmonth[1]=28;
  if(year%4==0&&year%100!=0||year%400==0)
	  dayofmonth[1]=29;
 for(int i=min(month1,month2)-1;i<max(month1,month2)-1;i++)
	 judge+=dayofmonth[i];

 if(judge%7==0)
	 cout<<"YES"<<endl;
 else
	 cout<<"NO"<<endl;
}

  return 0;
}


int main(int argc, char* argv[])
{
	int year,m1,m2,date=1,n,x,day,day2;
	int a,b,c,e,g,h,j;
	int d,f,i,k;

    a=c=e=g=h=j=31;
    d=f=i=k=30;
    scanf("%d",&n);
	for(x=0;x<n;x++)
	{
	scanf("%d%d%d",&year,&m1,&m2);

	if((year%4!=0)||(year%100==0&&year%400!=0))
		b=28;
	else
		b=29;

	switch(m1){
	case 1:day=date;break;
	case 2:day=a+date;break;
	case 3:day=a+b+date;break;
	case 4:day=a+b+c+date;break;
	case 5:day=a+b+c+d+date;break;
	case 6:day=a+b+c+d+e+date;break;
	case 7:day=a+b+c+d+e+f+date;break;
	case 8:day=a+b+c+d+e+f+g+date;break;
	case 9:day=a+b+c+d+e+f+g+h+date;break;
	case 10:day=a+b+c+d+e+f+g+h+i+date;break;
	case 11:day=a+b+c+d+e+f+g+h+i+j+date;break;
	case 12:day=a+b+c+d+e+f+g+h+i+j+k+date;break;}

	switch(m2){
	case 1:day2=date;break;
	case 2:day2=a+date;break;
	case 3:day2=a+b+date;break;
	case 4:day2=a+b+c+date;break;
	case 5:day2=a+b+c+d+date;break;
	case 6:day2=a+b+c+d+e+date;break;
	case 7:day2=a+b+c+d+e+f+date;break;
	case 8:day2=a+b+c+d+e+f+g+date;break;
	case 9:day2=a+b+c+d+e+f+g+h+date;break;
	case 10:day2=a+b+c+d+e+f+g+h+i+date;break;
	case 11:day2=a+b+c+d+e+f+g+h+i+j+date;break;
	case 12:day2=a+b+c+d+e+f+g+h+i+j+k+date;break;}

	if((day-day2)%7==0)
	printf("YES\n");
	else
	printf("NO\n");}
	return 0;
}


int DiJiTian(int year,int mon);
int main(){
int i,n,mon1,mon2,year,result;
int sz[200];
   scanf("%d",&n);
   for(i=0;i<n;i++){
   sz[i]=0;
   }
   for(i=0;i<n;i++){
	scanf("%d %d %d", &year, &mon1, &mon2);
    result=DiJiTian(year,mon1)-DiJiTian(year,mon2);
	if(result<0){
		result=0-result;
	}
    if((result%7)==0){
	sz[i]=1;}
   }
   for(i=0;i<n;i++){
	   if(sz[i]==1){
   printf("YES\n");
	   }else{
		   printf("NO\n");}
   }
	   return 0;
}
int DiJiTian(int year, int mon){
	int result=0;
	int i;
	for(i=1;i<mon;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result+=31;
		} else if(i==4||i==6||i==9||i==11){
			result+= 30;
		} else if(i == 2){
			if(year%400==0||(year%4==0&&year%100!=0)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result+=1;
	return result;
}


int main()
{
	int n, i, a[200], b[200], c[200], sum=0, d, e;
     scanf("%d", &n);
     for (sum=0,i=0; i<n; i++) {
	     scanf("%d%d%d", &a[i], &b[i], &c[i]);
		 if (b[i]>c[i]) {
			 d=c[i];
			 c[i]=b[i];
			 b[i]=d;
		 }
		 if (a[i]%4==0&&a[i]%100!=0||a[i]%400==0) {
			 for (sum=0,e=b[i]; e<c[i]; e++) {
				 switch(e){
					case 1:
				    case 3:
				    case 5:
			        case 7:
				    case 8:
				    case 10:
			    	case 12:
						sum+=31;
						break;
					case 2:
						sum+=29;
						break;

					case 4:
			     	case 6:
			    	case 9:
				    case 11:
				     	sum+=30;
					    break;
				}
			 }
				 if(sum%7==0) {
					 printf("YES\n");
				 }
					 else {
						 printf("NO\n");
					 }

		 }
			 else  {

                   for (sum=0,e=b[i]; e<c[i]; e++) {
				 switch(e){
					case 1:
				    case 3:
				    case 5:
			        case 7:
				    case 8:
				    case 10:
			    	case 12:
						sum+=31;
						break;
					case 2:
						sum+=28;
						break;

					case 4:
			     	case 6:
			    	case 9:
				    case 11:
				     	sum+=30;
					    break;
				}
				   }
				 if(sum%7==0) {
					 printf("YES\n");
				 }
					 else {
						 printf("NO\n");
					 }

			 }
	 }
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	int i,j,year,month1,month2,result=0;

	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&year,&month1,&month2);
		int t;
		if(month1>month2)
		{
			t=month1;
			month1=month2;
			month2=t;
		}
		for(j=month1;j<month2;j++)
		{
			if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			{
				result+=31;
			}
			else if(j==4||j==6||j==9||j==11)
			{
				result+=30;
			}
			else if(j==2)
			{
				if(year%4==0&&year%100!=0||year%100==0&&year%400==0)
				{
					result+=29;
				}
				else
				{
					result+=28;
				}
			}
		}
		if(result%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		result=0;
	}
	return 0;

}


int main()
{
	int month1,month2,year,i,n,j;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
        int monthday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	    int days1=0,days2=0;
		scanf("%d%d%d",&year,&month1,&month2);
	    if((year%4==0&&year%100!=0)||year%400==0)
		    monthday[2]=29;
	    for(j=0;j<month1;j++)
		{
		   days1=days1+monthday[j];
		}
	    for(j=0;j<month2;j++)
		{
		   days2=days2+monthday[j];
		}
		if(abs(days2-days1)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		days1=0;
		days2=0;
	}
	return 0;
}


int main()
{
	int n, i, j, year, month1, month2;
	cin>>n;
	int commonyear[]={0,0,3,3,6,1,4,6,2,5,0,3,5},
		leapyear[]={0,0,3,4,0,2,5,0,3,6,1,4,6};
	for (i=0;i<n;i++)
	{
		cin>>year>>month1>>month2;
		if ((year%4==0&&year%100!=0)||(year%400==0))
		{
			if (leapyear[month1]==leapyear[month2]) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else
		{
			if (commonyear[month1]==commonyear[month2]) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}


int main()
{
    int day(int m,int leap);
    int i,n,year[200][3],leap=0,day1,day2,d;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d %d %d",&year[i][0],&year[i][1],&year[i][2]);
    for(i=0;i<n;i++)
    {
        if( (year[i][0]%4==0&&year[i][0]%100!=0) ||year[i][0]%400==0 )
            leap=1;
        else
            leap=0;
        day1=day(year[i][1],leap);
        day2=day(year[i][2],leap);
        d=day1-day2;
        d=(int)fabs( (double)d );
        if(d%7==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return(0);
}

int day(int m,int leap)
{
    int sum;
    switch(m)
    {
        case 1:sum=1;break;
        case 2:sum=32;break;
        case 3:sum=60;break;
        case 4:sum=91;break;
        case 5:sum=121;break;
        case 6:sum=152;break;
        case 7:sum=182;break;
        case 8:sum=213;break;
        case 9:sum=244;break;
        case 10:sum=274;break;
        case 11:sum=305;break;
        case 12:sum=335;break;
        default:break;
    }
    if(m>=3)
        sum=sum+leap;
    return(sum);
}


int fc(int year,int mon1,int mon2);
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		int year,mon1,mon2;
	    scanf("%d%d%d",&year,&mon1,&mon2);
    	if(mon1>mon2)
		{
		    int tmp;
		    tmp=mon1;
		    mon1=mon2;
	    	mon2=tmp;
		}
	    if(fc(year,mon1,mon2)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

int fc(int year,int mon1,int mon2)
{
	int delta=0;
	int i;
	int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	for(i=mon1;i<mon2;i++)
	{
		delta+=month[i];
	}
	if(mon1==2||(mon1==1&&mon2>2))
	{
		if(year%4==0&&year>=4&&year%100!=0)
		    delta+=1;
	    else if(year%100==0&&year>=100&&year%400==0)
		    delta+=1;
	}
	return delta;
}


int main(int argc, char* argv[])
{
	int n,i;
	int y,m1,m2;
	int d1,d2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		d1=0;
		d2=0;
		scanf("%d%d%d",&y,&m1,&m2);
		if(y%100==0&&y%40==0||y%100!=0&&y%4==0)//leap
		{
			switch (m1)
			{
			case 1:d1+=0;break;
			case 2:d1+=31;break;
			case 3:d1+=60;break;
			case 4:d1+=91;break;
			case 5:d1+=121;break;
			case 6:d1+=152;break;
			case 7:d1+=182;break;
			case 8:d1+=213;break;
			case 9:d1+=244;break;
			case 10:d1+=274;break;
			case 11:d1+=305;break;
			case 12:d1+=335;break;
			}
            switch (m2)
			{
			case 1:d2+=0;break;
			case 2:d2+=31;break;
			case 3:d2+=60;break;
			case 4:d2+=91;break;
			case 5:d2+=121;break;
			case 6:d2+=152;break;
			case 7:d2+=182;break;
			case 8:d2+=213;break;
			case 9:d2+=244;break;
			case 10:d2+=274;break;
			case 11:d2+=305;break;
			case 12:d2+=335;break;
			}
			if((d1-d2)%7==0){printf("YES\n");}
			else printf("NO\n");
		}
		else
		{
			switch (m1)
			{
			case 1:d1+=0;break;
			case 2:d1+=31;break;
			case 3:d1+=59;break;
			case 4:d1+=90;break;
			case 5:d1+=120;break;
			case 6:d1+=151;break;
			case 7:d1+=181;break;
			case 8:d1+=212;break;
			case 9:d1+=243;break;
			case 10:d1+=273;break;
			case 11:d1+=304;break;
			case 12:d1+=334;break;
			}
            switch (m2)
			{
			case 1:d2+=0;break;
			case 2:d2+=31;break;
			case 3:d2+=59;break;
			case 4:d2+=90;break;
			case 5:d2+=120;break;
			case 6:d2+=151;break;
			case 7:d2+=181;break;
			case 8:d2+=212;break;
			case 9:d2+=243;break;
			case 10:d2+=273;break;
			case 11:d2+=304;break;
			case 12:d2+=334;break;
			}

			if((d1-d2)%7==0){printf("YES\n");}
			else printf("NO\n");

		}
	}

	return 0;
}


int main()
{
    int i,n,year,month1,month2,sum=0,day,p;
    cin >> n;
    for(i=1;i<=n;i++)
    {
         sum=0;
         cin >> year >> month1 >> month2;
         if(month1>month2)
         {
            p=month1;
            month1=month2;
            month2=p;
         }
        if(year%400==0||(year%4==0&&year%100!=0))
        {
         for(1;month1<month2;month1++)
        {
              if(month1==1||month1==3||month1==5||month1==7||month1==8||month1==10||month1==12)
              {
                day=31;
              }
              if(month1==4||month1==6||month1==9||month1==11)
              {
                day=30;
              }
              if(month1==2)
              {
                day=29;
              }
                 sum=sum+day;
        }
              if(sum%7==0)
              cout << "YES" << endl;
              else
              cout << "NO" << endl;
        }
        if(year%4!=0||(year%100==0&&year%400!=0))
        {
            for(1;month1<month2;month1++)
            {
              if(month1==1||month1==3||month1==5||month1==7||month1==8||month1==10||month1==12)
              {
                day=31;
              }
              if(month1==4||month1==6||month1==9||month1==11)
              {
                day=30;
              }
              if(month1==2)
              {
                day=28;
              }

                   sum=sum+day;
            }
              if(sum%7==0)
              cout << "YES" << endl;
              else
              cout << "NO" << endl;
        }
    }
return 0;
}


int checkrun(int a) {
	if (a % 4 != 0) {
		return 0;
	} else {
		if (a % 100 == 0) {
			if (a % 400 == 0)
				return 1;
			else
				return 0;
		} else {
			return 1;
		}
	}
}
int main() {
	int n, month1, month2, i, year, temp, day, j;
	int a1[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int a2[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	cin >> n;
	for (j = 0; j < n; j++) {
		cin >> year >> month1 >> month2;
		if (month1 < month2)
			;
		else {
			temp = month1;
			month1 = month2;
			month2 = temp;
		}
		if (checkrun(year) != 1) {
			day = 0;
			for (i = month1; i < month2; i++) {
				day = day + a1[i];
			}
			if (day % 7 == 0) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else {
			day = 0;
			for (i = month1; i < month2; i++) {
				day = day + a2[i];
			}
			if (day % 7 == 0) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}


int main()
{
    int runnian(int year);
    int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
    int b[]={31,29,31,30,31,30,31,31,30,31,30,31};
    int n,i,j,year,x,y,boolean,sum,temp;
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {scanf("%d %d %d",&year,&x,&y);
     boolean=runnian(year);
     if (x>y) {temp=x;x=y;y=temp;}
     sum=0;
     if (boolean!=0)
       for (j=x;j<y;j++) sum=sum+a[j-1];
     if (boolean==0)
       for (j=x;j<y;j++) sum=sum+b[j-1];

     if (sum%7==0) printf("YES\n");
     else printf("NO\n");

    }
    return 0;

}
int runnian(int year)
{int b;
 if (year%400==0) return(0);
 if (year%4==0 && year%100!=0) return(0);
 return(1);

}


int judge(int x)
{
if(x%400==0) return 1;
if(x%100==0 && x%400!=0) return 0;
if(x%4==0) return 1;
else return 0;
}
int main()
{
    int n,year,month0,month1,mark;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    mark=0;
    cin>>year>>month0>>month1;
    if(month0>month1){int temp;temp=month0;month0=month1;month1=temp;}
    if(judge(year)==0)
    {
     if(month0==1&&month1==10) mark=1;
     if(month0==2&&month1==3) mark=1;
     if(month0==2&&month1==11) mark=1;
     if(month0==3&&month1==11) mark=1;
     if(month0==4&&month1==7) mark=1;
     if(month0==9&&month1==12) mark=1;
     }
     else
     {
     if(month0==1&&month1==4) mark=1;
     if(month0==1&&month1==7) mark=1;
     if(month0==2&&month1==8) mark=1;
     if(month0==3&&month1==11) mark=1;
     if(month0==4&&month1==7) mark=1;
     if(month0==9&&month1==12) mark=1;
     }
     if(mark==1) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      }
    return 0;
    }


int main(){
	int n,year,month1,month2,i,day1,day2;
	int isRunNian(int year);
	int DiJiTian(int year, int month);
	int sz[200],jg;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&year,&month1,&month2);
		if((DiJiTian(year,month2)-DiJiTian(year,month1))<0){
			jg=-(DiJiTian(year,month2)-DiJiTian(year,month1));
		}
		else jg=(DiJiTian(year,month2)-DiJiTian(year,month1));
		if(jg%7==0){
			sz[i]=1;
		}
		else{
			sz[i]=0;
		}
	}
	for(i=0;i<n;i++){
		if(sz[i]==1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}
int isRunNian(int year){
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
		result = 1;
	} else{
		result = 0;
	}
      return result;
}
int DiJiTian(int year, int month){
	int result = 0;
	for(int i = 1; i < month; i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}

	return result;
}


int isRunNian(int year);
int DiJiTian(int year, int month, int day);
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int year,m1,m2,chazhi;
		scanf("%d%d%d", &year,&m1,&m2);
		chazhi=DiJiTian(year,m2,1)-DiJiTian(year,m1,1);
		if (chazhi%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}
int isRunNian(int year)
{
	int result;
	if(year%400==0||(year%4==0 && year%100!=0))
	{
		result=1;
	}
	else
	{
		result=0;
	}
	return result;
}
int DiJiTian(int year, int month, int day)
{
	int result=0,i;
	for(i=1;i<month;i++)
	{
		if((i==1)||(i==3)||(i==5)||(i==7)||(i==8)||(i==10)||(i==12))
		{
			result+=31;
		}
		else if(i==4||i==6||i==9||i==11)
		{
			result+=30;
		}
		else if(i==2)
		{
			if(isRunNian(year))
			{
				result+=29;
			}
			else
			{
				result+=28;
			}
		}
	}
	result+=day;
	return result;
}


int main()
{
	int n, i, j, t, leap, day, year, m1, m2;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> year >> m1 >> m2;
		day = 0;
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
			leap = 1;
		else
			leap = 0;
		if (m1 > m2)
		{
			t = m2;
			m2 = m1;
			m1 = t;
		}
		for (j = m1; j < m2; j++)
		{
			switch (j)
			{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				day += 31;
				break;
			case 2:
				day += 28 + leap;
				break;
			default:
				day += 30;
				break;
			}
		}
		if ( day % 7 == 0)
			cout << "YES" <<endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


int day0[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int day1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
void judge(int i,int x,int y){
	if(x==y) cout<<"Data Error"<<endl;
	int ds=0;
	if(i==1){
		if(x<y){
			for(int j=x;j<y;j++)
				ds=ds+day1[j];
		}
		else{
			for(int j=y;j<x;j++)
				ds=ds+day1[j];
		}
		if(ds%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	else{
		if(x<y){
			for(int j=x;j<y;j++)
				ds=ds+day0[j];
			}
		else{
			for(int j=y;j<x;j++)
				ds=ds+day0[j];
		}
		if(ds%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}
int main(){
	int n,year,month1,month2;
	cin>>n;
	while(n!=0){
		cin>>year>>month1>>month2;
		if((year%4==0&&year%100!=0)||year%400==0) judge(1,month1,month2);
		else judge(0,month1,month2);
		n--;
	}
	return 0;
}


/*
 *  ???:???
 *  ??: 2010-12-17
 *  ??: ???
 *  ??: ???????????????YES?
			?????NO?
 */

int is_Runnian(int year){				//??????
	if(year%4 != 0) return 0;
	else{
		if(year%100 == 0 && year%400 != 0)
			return 0;
	}
	return 1;
}

int main(){
	int monthday[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int n;
	cin >> n;

	int i=0;
	while(i < n){
		int year, month1, month2, month1day=0, month2day=0;
		cin >> year >> month1 >> month2;

		if(is_Runnian(year)) monthday[1] = 29;		//????? ????29?
		for(int j=0; j<month1-1; j++){
			month1day += monthday[j];
		}
		for(int j=0; j<month2-1; j++){
			month2day += monthday[j];
		}

		int p = (month2day-month1day>0 ? (month2day-month1day) : (month1day-month2day));

		if(p%7 == 0)				//??7??
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

		if(monthday[1] == 29)
			monthday[1] = 28;
		i++;
	}
}


int dijitian(int Y,int M,int D);
int main(){
	int n;
	scanf("%d",&n);
	int Y[200];
	int M[200];
	int m[200];
	int i;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&Y[i],&M[i],&m[i]);
	}
	for(i=0;i<n;i++){
		if((dijitian(Y[i],M[i],1)-dijitian(Y[i],m[i],1))%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

		}

	return 0;
}
int dijitian(int Y,int M,int D){
	int run(int Y);
	int i;
	int result=0;
	for(i=1;i<M;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10){
			result+=31;
		}if(i==4||i==6||i==9||i==11){
			result+=30;
		}if(i==2){
			if(run(Y)){
				result+=29;
			}else{
				result+=28;
			}
		}
	}result=result+D;
	return result;
}
int run(int Y){
	int Q;
	if(Y%400==0||(Y%4==0&&Y%100!=0)){
		Q=1;
	}else {
		Q=0;
	}
return Q;
}


int main()
{
	int n,i;
	int year,month1,month2;
	int day(int year,int month);
	scanf("%d\n",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d%d",&year,&month1,&month2);
		if((day(year,month1)-day(year,month2))%7==0){printf("YES\n");}
		else{printf("NO\n");}
	}

	return 0;

}
int day(int year,int month)
{
	int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int i,c;
	if(year%4==0&&(year%100!=0)||(year%400==0)){days[2]++;}
	c=0;
	for(i=1;i<month;i++){c+=days[i];}
	return c;
}


int mon;
int day(),month[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int i,j,n,year,month1,month2,days1,days2,daysbetween;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
         scanf("%d %d %d",&year,&month1,&month2);
         if((year%4==0 && year%100!=0) || year%400==0)
               month[1]++;
         days1=day(month1);
         days2=day(month2);
         daysbetween=days1-days2;
         if(daysbetween%7==0)
               printf("YES\n");
         else
               printf("NO\n");
         month[1]=28;
    }
    return 0;
}

int day(int mon){
    int k,days=0;
    for(k=0;k<mon-1;k++)
       days+=month[k];
    return days;
}


int runnian(int nian){
	if(nian%100==0){
		if(nian%400==0){
			return 1;
		}
		else return 0;
	}
	else {
		if(nian%4==0){
			return 1;
		}
		else return 0;
	}
}
int main(){
	int n;
	int s1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int s2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(int i=0;i<n;i++){
		int nian,yue1,yue2,days=0;
		cin>>nian>>yue1>>yue2;
		if(yue1>yue2){
			int temp;
			temp=yue1;
			yue1=yue2;
			yue2=temp;
		}
		if(runnian(nian)==0){
			for(int j=yue1-1;j<yue2-1;j++){
				days+=s1[j];
			}
			if(days%7==0){
				cout<<"YES"<<endl;
			}
			else cout<<"NO"<<endl;
		}
		else if(runnian(nian)==1){
			for(int j=yue1-1;j<yue2-1;j++){
							days+=s2[j];
						}
						if(days%7==0){
							cout<<"YES"<<endl;
						}
						else cout<<"NO"<<endl;
		}
		}
	return 0;
}


/*
 * month.cpp
 *
 *  Created on: 2010-12-25
 *      Author: ???
 *      Function: ???
 */
int day1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//????????
int day2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//???????
int bissextile(int year){//???????????????1?????0
	if(year%400==0||(year%4==0&&year%100!=0)) return 1;
	else return 0;
}
int relative(int month1,int month2,int year){
	int days=0;
	if(bissextile(year))//??????????????????
		for(int i=month1;i<month2;i++)
			days=days+day2[i];
	else//???????????????????
		for(int i=month1;i<month2;i++)
			days=days+day1[i];
	if(days%7==0) return 1;//??????1?????0
	else return 0;
}
int main()
{
	int n,year,month1,month2,relation;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>year>>month1>>month2;
		if(month1<month2) relation=relative(month1,month2,year);
		else if(month1>month2) relation=relative(month2,month1,year);
		else relation=1;
		if(relation) cout<<"YES"<<endl;//??????YES?????NO
		else cout<<"NO"<<endl;
	}
	return 0;
}


int main()
{
	int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int n,year,month1,month2,i,j,sum,begin,end;

	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&year,&month1,&month2);

		if( (year%4==0 && year%100!=0)||(year%400==0) )
		{
			days[2]=29;
		}
		else
		{
			days[2]=28;
		}

		if (month1>month2)
		{
			begin=month2;
			end=month1;
		}
		else
		{
			begin=month1;
			end=month2;
		}

        sum=0;
		for (j=begin;j<end;j++)
		{
			sum=sum+days[j];
		}

		if(sum%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}

	return 0;
}


int isRunNian(int year){
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
		result = 1;
	} else{
		result = 0;
	}
      return result;
}

int DiJiTian(int year, int month, int day){
	int result = 0;
	for(int i = 1; i < month; i++){ 	//step1
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result += day;	//step2
	return result;
}

int main(int argc, char* argv[])
{int n;
   int sz[200][3];
   scanf("%d",&n);
   int a=0;
   int b=0;

   for(int i=0;i<n;i++){
	   scanf("%d %d %d",&sz[i][0],&sz[i][1],&sz[i][2]);
	   a=DiJiTian(sz[i][0],sz[i][1],1)-DiJiTian(sz[i][0],sz[i][2],1);
       b=a%7;
	   if(b==0){
		   printf("YES\n");
	   }
	   else{
		   printf("NO\n");
	   }

   }
	return 0;
}


int main()
{
int year, mo1, mo2, i, j, n, temp, specialY, day, dayinMonth;
cin >> n;
for(i = 0; i < n; i++)
{
cin >> year >> mo1 >> mo2;
specialY = 0;
day = 0;
if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
specialY = 1;
if(mo1 > mo2)
{
temp = mo1;
mo1 = mo2;
mo2 = temp;
}
for(j = mo1; j < mo2; j++)
{
switch(j)
{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12: dayinMonth = 31; break;
	case 2: if (specialY == 1) dayinMonth = 29;
		    else dayinMonth = 28; break;
	case 4:
	case 6:
	case 9:
	case 11: dayinMonth = 30; break;
	default:;
}
day += dayinMonth;
}
if(day % 7 == 0)
cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}


int main()
{
	int m,n,i,j;
	int altitude[21][21]={0};
	cin >>m>>n;
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			cin >>altitude[i][j];
		}
	}
	i=0;
	if ((altitude[0][0]>=altitude[0][1])&&(altitude[0][0]>=altitude[1][0]))
		cout <<"0 0"<<endl;
	for (j=1;j<n;j++)
	{
		if ((altitude[i][j]>=altitude[i][j-1])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
			cout <<i<<" "<<j<<endl;
	}
	for (i=1;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			if (j==0)
			{
				if ((altitude[i][j]>=altitude[i-1][j])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
					cout <<i<<" "<<j<<endl;
			}
			if (j>0)
			{
				if ((altitude[i][j]>=altitude[i-1][j])&&(altitude[i][j]>=altitude[i][j-1])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
					cout <<i<<" "<<j<<endl;
			}
		}
	}
	return 0;
}


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

int main()
{
	int m = 0;
	int n = 0;
	int high[21][21] = {0};
	int i = 0;
	int t = 0;

	cin >> m;
	cin >> n;

	for( i = 1;i <= m;i++ )
		for( t = 1;t <= n;t++ )
		{
			cin >> high[i][t];
		}

	for( i = 1;i <= m;i++ )
		for( t = 1;t <= n;t++ )
		{
			if( high[i][t] >= high[i - 1][t] && high[i][t] >= high[i + 1][t] && high[i][t] >= high[i][t + 1] && high[i][t] >= high[i][t - 1] )
				cout << i - 1 << " "  << t - 1 << endl;
		}

	cin >> i;

	return 0;
}


int main()
{
 	int m,n;
 	int sz[ROW][COL];
 	int row,col;
	scanf("%d %d",&m,&n);
 	for(row=0;row<m;row++){
			for(col=0;col<n;col++){
				scanf("%d",&sz[row][col]);
				}
			}
	for(row=0;row<m;row++){
		for(col=0;col<n;col++){
			if(row==0&&col==0){
				if(sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col+1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row==0&&col==n-1){
				if(sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row==m-1&&col==0){
				if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col+1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row==m-1&&col==n-1){
				if(sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row-1][col]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row==0){
				if(sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row==m-1){
				if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){
				    printf("%d %d\n",row,col);
				    }
				}
			else if(col==0){
				if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col+1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(col==n-1){
				if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]){
					printf("%d %d\n",row,col);
					}
				}
			else if(row!=0&&row!=m-1&&col!=0&&col!=n-1){
			if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){
				printf("%d %d\n",row,col);
				}
		    }
			}
		}

    return 0;
}


int main(){
    int m,n;
    scanf("%d %d",&m,&n);
    char mtn[m][n];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&mtn[i][j]);
        }
    }
    for(int row=0;row<m;row++){
        for(int col=0;col<n;col++){
            if(row==0&&col==0&&mtn[row][col]>=mtn[row+1][col]&&mtn[row][col]>=mtn[row][col+1]){printf("%d %d\n",row,col);}
            else if((row==m-1)&&(col==0)&&(mtn[row][col]>=mtn[row-1][col])&&(mtn[row][col]>=mtn[row][col+1])){printf("%d %d\n",row,col);}
            else if((row==0)&&(col==n-1)&&(mtn[row][col]>=mtn[row][col-1])&&(mtn[row][col]>=mtn[row+1][col])){printf("%d %d\n",row,col);}
            else if((row==m-1)&&(col==n-1)&&(mtn[row][col]>=mtn[row-1][col])&&(mtn[row][col]>=mtn[row][col-1])){printf("%d %d\n",row,col);}
            else if((row==0)&&(mtn[row][col]>=mtn[row][col+1])&&(mtn[row][col]>=mtn[row][col-1])&&(mtn[row][col]>=mtn[row+1][col])){printf("%d %d\n",row,col);}
            else if((row==m-1)&&(mtn[row][col]>=mtn[row][col-1])&&(mtn[row][col]>=mtn[row][col+1])&&(mtn[row][col]>=mtn[row-1][col])){printf("%d %d\n",row,col);}
            else if((col==0)&&(row!=m-1)&&(row!=0)&&(mtn[row][col]>=mtn[row-1][col])&&(mtn[row][col]>=mtn[row+1][col])&&(mtn[row][col]>=mtn[row][col+1])){printf("%d %d\n",row,col);}
            else if((col==n-1)&&(row!=m-1)&&(row!=0)&&(mtn[row][col]>=mtn[row-1][col])&&(mtn[row][col]>=mtn[row+1][col])&&(mtn[row][col]>=mtn[row][col-1])){printf("%d %d\n",row,col);}
            else if((row!=0)&&(row!=m-1)&&(col!=0)&&(col!=n-1)&&(mtn[row][col]>=mtn[row-1][col])&&(mtn[row][col]>=mtn[row+1][col])&&(mtn[row][col]>=mtn[row][col-1])&&(mtn[row][col]>=mtn[row][col+1])){printf("%d %d\n",row,col);}

        }
        }
return 0;

}


int main()
{  int height[20][20]={0},m,n;
   cin>>m>>n;
   int i,j;
   for(i=0;i<m;i++)
   {
	   for(j=0;j<n;j++) cin>>height[i][j];
   }
   int judge,piece;
   for(i=0;i<m;i++)
   {
	   for(j=0;j<n;j++)
	   {
		   piece=0;
		   judge=0;
		   if(i>=1) { judge+=(height[i][j]>=height[i-1][j]);piece++;}
		   if(i<m-1) { judge+=(height[i][j]>=height[i+1][j]);piece++;}
		   if(j>=1) { judge+=(height[i][j]>=height[i][j-1]); piece++;}
		   if(j<n-1){ judge+=(height[i][j]>=height[i][j+1]);piece++;}
		   if(judge==piece)
		   {
			   cout<<i<<" "<<j<<endl;
		   }

	   }
   }
   cin.get();
   cin.get();
   cin.get();

	return 0;
}


int shan[max][max]={0};
int main()
{
	int h,l;
	cin>>h>>l;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=l;j++)
			cin>>shan[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=l;j++)
			if(shan[i][j]>=shan[i-1][j]&&shan[i][j]>=shan[i+1][j]&&shan[i][j]>=shan[i][j-1]&&shan[i][j]>=shan[i][j+1])
				cout << i-1 <<" "<<j-1<<endl;

}


/*
 * ????
 * Created on: 2013-1-13
 * ??
 * Author: ???
 */
int main() {
	int r = 0, c = 0;
	cin >> r >> c;
	int mountain[r + 2][c + 2];
	for (int i = 0; i < r + 2; i++)
		for (int j = 0; j < c + 2; j++) {
			if (i == 0 || j == 0 || i == r + 1 || j == c + 1)
				mountain[i][j] = 0;
			else
				cin >> mountain[i][j];
		}
	for (int i = 1; i < r + 1; i++)
		for (int j = 1; j < c + 1; j++) {
			if ((mountain[i][j] >= mountain[i - 1][j]) && (mountain[i][j]
					>= mountain[i + 1][j]) && (mountain[i][j] >= mountain[i][j
					- 1]) && (mountain[i][j] >= mountain[i][j + 1]))
			cout << i-1 << " " << j-1 << endl;
		}
	return 0;
}