main()
{
      int i,j,k,n,sa=0,sb=0,a,b;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
                      scanf("%d %d",&a,&b);
                      if(a-b==-1 || a-b==2)sa++;
                      else if(a==b) {}
                      else sb++;
      }
      if(sa>sb)printf("A\n");
      else if(sa==sb)printf("Tie\n");
      else printf("B\n");
}


int main () {
	int num;
	cin >> num;
	int aWinCount = 0;
	int bWinCount = 0;
	for (int i = 0; i < num; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 0) {
			if (b == 1) {
				aWinCount++;
			} else if (b == 2) {
				bWinCount++;
			}
		}
		if (a == 1) {
			if (b == 0) {
				bWinCount++;
			} else if (b == 2) {
				aWinCount++;
			}
		}
		if (a == 2) {
			if (b == 1) {
				bWinCount++;
			} else if (b == 0) {
				aWinCount++;
			}
		}
	}
	if (aWinCount == bWinCount) {
		cout << "Tie" << endl;
	} else if (aWinCount > bWinCount) {
		cout << "A" << endl;
	} else {
		cout << "B" << endl;
	}
}


int main(){
	int a,b;
	int n,c=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a==b){c=c;}
		else if(a-b==1){c=c-1;}
		else if(b-a==1){c+=1;}
		else if(a-b==2){c+=1;}
		else if(b-a==2){c=c-1;}
	}
	if(c>0){printf("A");}
	else if(c<0){printf("B");}
	else{printf("Tie");}
return 0;
}


int main()
{
    int n,i,suma=0,sumb=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        if(b-a==1||b-a==-2)suma++;
        if(a-b==1||a-b==-2)sumb++;
    }
    if(suma>sumb)printf("A");
    if(suma<sumb)printf("B");
    if(suma==sumb)printf("Tie");
}


int main(){
int n,i,x,y,f=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&x,&y);
if(x-y==1)
f=f-1;
else if(y-x==1)
f=f+1;
else if(x-y==2)
f=f+1;
else if(y-x==2)
f=f-1;
}
if(f>0)
printf("A");
else if(f<0)
printf("B");
else if(f==0)
printf("Tie");
return 0;
}


int main(){
	int countA=0,countB=0,n,a,b,t=0;
	int i;
	double w;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if((a==0&&b==1)||(a==1&&b==2)||(a==2&&b==0)){countA++;t++;}
		else if(a==b);
		else {countB++;t++;}

	}

	w=1.0*countA/t;
	if(w>0.5)printf("A");
	else if(w==0.5)printf("Tie");
	else printf("B");

		return 0;
}


int main()
{
	int n,i;
	int A,B;
	int a=0,b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&A,&B);
		if((A==0&&B==1)||(A==1&&B==2)||(A==2&&B==0)){
			a++;
			continue;
		}
		if(A==B){
			a++;
			b++;
			continue;
		}
		else{
			b++;
			continue;
		}
	}
	if(a>b){
		printf("A\n");
		return 0;
	}
	if(a==b){
		printf("Tie\n");
		return 0;
	}
	if(a<b){
		printf("B\n");
	return 0;}

	return 0;
}


int j(int a,int b)
{
    if(a>b)return -j(b,a);
    if(b-a==1) return 1;
    if(b==a) return 0;
    if(b-a==2) return -1;
}
int main()
{
    int n,s=0,i,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%d%d",&a,&b);
    s+=j(a,b);
    }
    if(s<0)printf("B");
    else if(s==0)printf("Tie");
    else printf("A");
    return 0;
}


main()
{
      int n,ai=0,bi=0,c;
      scanf("%d",&n);
      int a,b;
      for(c=0;c<n;c++)
      {
        scanf("%d %d",&a,&b);
        if(a==b)
                ;
        else
      {
        if(a==0 && b==1)
        ai++;
        else
        {
          if(a==1 && b==2)
          ai++;
          else
            {
            if(a==2 && b==0)
             ai++;
             else
             bi++;
            }
        }
        }
      }
      if (ai>bi)
      printf("A");
      else ;
      if (ai==bi)
      printf("Tie");
      else ;
      if (ai<bi)
      printf("B");
      else ;
}


int main(){
	int n;
	scanf("%d",&n);
	struct suoyou{
		int qian;
		int hou;
		int jg;
	}suoyous[202];
	int i;
	for(i=0;i<n;i++){
		scanf("%d%d",&suoyous[i].qian,&suoyous[i].hou);
		if(suoyous[i].qian==0&&suoyous[i].hou==1){
			suoyous[i].jg=1;
		}else if(suoyous[i].qian==1&&suoyous[i].hou==2){
			suoyous[i].jg=1;
		}else if(suoyous[i].qian==2&&suoyous[i].hou==0){
			suoyous[i].jg=1;
		}else if(suoyous[i].qian==0&&suoyous[i].hou==2){
			suoyous[i].jg=0;
		}else if(suoyous[i].qian==0&&suoyous[i].hou==0){
			suoyous[i].jg=2;
		}else if(suoyous[i].qian==1&&suoyous[i].hou==1){
			suoyous[i].jg=2;
		}else if(suoyous[i].qian==1&&suoyous[i].hou==0){
			suoyous[i].jg=0;
		}else if(suoyous[i].qian==0&&suoyous[i].hou==1){
			suoyous[i].jg=1;
		}else if(suoyous[i].qian==2&&suoyous[i].hou==1){
			suoyous[i].jg=0;
		}else if(suoyous[i].qian==2&&suoyous[i].hou==2){
			suoyous[i].jg=2;
		}
	}
	int s=0;
	for(i=0;i<n;i++){
		if(suoyous[i].jg==1){
			s++;
		}
	}
	int m=0;
	for(i=0;i<n;i++){
		if(suoyous[i].jg==0){
			m++;
		}
	}

	if(s>m){
		printf("A");
	}else if(s<m){
		printf("B");
	}else if(s==m){
		printf("Tie");
	}

	return 0;
}


int main(){
int n,a,b,i,m=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a==b) m=m;
else if(b-a==1 || a-b==2) m=m+1;
else m=m-1;
}
if(m==0)printf("Tie");
else if(m>0)printf("A");
else if(m<0)printf("B");
return 0;
}


int main(){
	int n;
	scanf("%d",&n);
		int a[MAX],b[MAX];
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	int sum1=0;
	int sum2=0;
	for(int k=0;k<n;k++){
		if(a[k]-b[k]==-1){
			sum1=sum1+1;
		}else if(a[k]-b[k]==1){
			sum2=sum2+1;
		}else if(a[k]-b[k]==2){
			sum1=sum1+1;
		}else if(a[k]-b[k]==-2){
			sum2=sum2+1;
		}else if(a[k]==b[k]){
			sum1=sum1+1;
			sum2=sum2+1;
		}
	}
	if(sum1>sum2){
		printf("A");
	}else if(sum1<sum2){
		printf("B");
	}else{
		printf("Tie");
	}
	return 0;
}


int main(){
	int n,i,a,b,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if(a==b){
		}
		else if(a==0&&b==1){
			total++;
		}
		else if(a==0&&b==2){
			total--;
		}
		else if(a==1&&b==0){
			total--;
		}
		else if(a==1&&b==2){
			total++;
		}
		else if(a==2&&b==0){
			total++;
		}
		else if(a==2&&b==1){
			total--;
		}
	}
	if(total<0){
		printf("B");
	}
	else if(total==0){
		printf("Tie");
	}
	else if(total>0){
		printf("A");
	}
	return 0;
}


int main(){
int n;
int x,y;
x=0;y=0;
scanf("%d",&n);
int a[n],b[n];
for(int i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
    if(a[i]-b[i]==-1||a[i]-b[i]==2){x++;}
    else if(a[i]==b[i]){x=x;}
    else{y++;}

}
if(x>y){printf("A");return 0;}
if(x<y){printf("B");}
else{printf("Tie");
}return 0;

}


int main(){

int n;
scanf("%d",&n);
int a=0;
int b=0;
int i;
for(i=0;i<n;i++){

int p;
int q;
scanf("%d %d",&p,&q);
if(p-q!=0){

	if(p-q==-1||p-q==2){
	a++;
	}
	else{
	b++;
	}

}

}

if(a==b){
printf("Tie");

}
else if(a>b){

printf("A");

}

else{
printf("B");

}

return 0;
}


int main()
{
	int n,ta=0,tb=0,i,a,b;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		if (a==b) continue;
		if (a==1)
		  if (b==2) ta++;
		  else tb++;
        else if (a==2)
          if (b==1) tb++;
          else ta++;
        else if (a==0)
          if (b==1) ta++;
          else tb++;
	}
	if (ta>tb) printf("A\n");
	else if (ta<tb) printf("B\n");
	else printf("Tie\n");
}


int main(){
    int s=0,t=0,i,j,a,b,n;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        if(a==b){
            continue;
        }
        else if(a==0){
            if(b==1){
                s++;
            }
            else {t++;}
        }
        else if(a==1){
            if(b==2){
                s++;
            }
            else {t++;}
        }
        else if(a==2){
            if(b==0){
                s++;
            }
            else t++;
        }
    }
    if(s>t){
        printf("A");
    }
    else if(s<t){
        printf("B");
    }
    else printf("Tie");
    return 0;
}


main()
{
      int a=0,b=0,n,i,j,k;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
                      scanf("%d %d",&j,&k);
                       switch(j-k){
                       case 1:b++;break;
                        case -1:a++;break;
                         case 0: break;
                         case 2: a++;break;
                         case -2:b++;break;}
      }
      if(a>b)
      printf("A");
       if(a==b)
      printf("Tie");
       if(a<b)
      printf("B");
      }


int main (){
    int n,i,a,b,aa=0,bb=0,pp=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        if(a==b-1||a==b+2){
            aa=aa+1;
        }else{
            if(a==b){
                pp=pp+1;
            }else{
                bb=bb+1;
            }
        }
    }
    if(aa>bb){
        printf("A");
    }else{
        if(aa==bb){
            printf("Tie");
        }else{
            printf("B");
        }
    }
    return 0;
}


int main()
{

 int n,a,b,i,c,k=0,j=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)
  {scanf("%d %d",&a,&b);
    c=a-b;
	if(c==-1||c==2)  k++;
	else if(c!=0) j++;
  }
  if(k>j)  printf("A");
  else if(k==j)  printf("Tie");
  else     printf("B");
return 0;
}


main()
{
      int n;
      int i;
      scanf("%d",&n);
      int a[n],b[n];
      int s=0,t=0;
      for(i=0;i<n;i++)
      {
      scanf("%d%d",&a[i],&b[i]);
      if(a[i]-b[i]==1||b[i]-a[i]==2)
      t++;
      else if(a[i]==b[i])
      {s++;t++;}
      else
      s++;
      }
      if(s>t)
      printf("A\n");
      else if (s==t)
      printf("Tie\n");
      else
      printf("B\n");

}


int main(){
   int n,i;
   double jieguo=0.00;
   scanf("%d\n",&n);
   int a[n],b[n];
   for (i=0;i<n;i++){
       scanf("%d%d\n",&a[i],&b[i]);
       if (a[i]==b[i]-1||a[i]==b[i]+2){jieguo=jieguo+1;}
          else if (a[i]==b[i]){jieguo=jieguo;}
             else {jieguo=jieguo-1;}
   }
   if (jieguo==0.00){printf("Tie");}
   else if(jieguo>0.00){printf("A");}
   else {printf("B");}
   return 0;
}


int main(){
struct{
int a,b;
}sz[100];
int n,i,x=0,y=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&sz[i].a,&sz[i].b);
}
for(i=0;i<n;i++){
if(sz[i].a-sz[i].b==-1||sz[i].a-sz[i].b==2){x++;}
else if(sz[i].a-sz[i].b==1||sz[i].a-sz[i].b==-2){y++;}
else{continue;}
}
if(x>y){printf("A");}
else if(x==y){printf("Tie");}
else{printf("B");}
return 0;
}


int main()
{
    int n,a,b,suma,sumb,i;

    scanf("%d",&n);
    suma=0;sumb=0;
    for (i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        if ((b-a==1) || (a-b==2)) {suma++;}
        if ((a-b==1) || (b-a==2)) {sumb++;}
    }
    if (suma>sumb) {printf("A");}
    else if (suma==sumb) {printf("Tie");}
    else {printf("B");}
    return 0;
}


main()
{
   int n,A,B,Aw=0,Bw=0;
   scanf("%d",&n);
   while(n--)
   {
     scanf("%d%d",&A,&B);
     if(A==0)
      {
       if(B==1)
       Aw++;
       else if(B==2)
       Bw++;
       }
     else if(A==1)
       {
       if(B==2)
       Aw++;
       else if(B==0)
       Bw++;
       }
     else
      {
       if(B==0)
       Aw++;
       else if(B==1)
       Bw++;
      }
   }
  if(Aw>Bw)
    printf("A");
  else if(Aw<Bw)
    printf("B");
  else
    printf("Tie");
}


int main()
{
	int n,i;
	int sa=0,sb=0;
	int a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		if(a+b==1)
		{
			if(a==0)
			{
				sa++;
			}else if(b==0)
			{
				sb++;
			}
		}else if(a+b==3)
		{
			if(a==1)
			{
				sa++;
			}else if(b==1)
			{
				sb++;
			}
		}else if(a+b==2)
		{
			if(a==2)
			{
				sa++;
			}else if(b==2)
			{
				sb++;
			}
		}
	}

	if(sa>sb)
	{
		printf("A\n");
	}else if(sa<sb)
	{
		printf("B\n");
	}else if(sa==sb)
	{
		printf("Tie\n");
	}

	return 0;
}


int main()
{
	int i,awin,bwin,n;
	int a[220],b[220];
	scanf("%d",&n);
	awin=0;
	bwin=0;
	for(i=1;i<=n;i++){
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]==0&&b[i]==2){
			bwin++;
		}else{
			if(a[i]==2&&b[i]==0){
				awin++;
			}else{
				if(a[i]>b[i]){
					bwin++;
				}else{
					if(b[i]>a[i]){
						awin++;
					}else{
						continue;
					}
				}
			}
		}
	}
	if(awin>bwin){
		printf("A");
	}else{
		if(bwin>awin){
			printf("B");
		}else{
			printf("Tie");
		}
	}
	return 0;
}


int main(int argc, char *argv[])
{
    int n,i;
    scanf("%d",&n);
    int a[200],b[200];
    int t=0,j=0;
    for(i=0;i<n;i++)
    {
                    scanf("%d%d", &a[i],&b[i]);
                    }
    for(i=0;i<n;i++)
    {
                    if(a[i]==0&&b[i]==1){
                                       t++;
                                       }
                    else if(a[i]==1&&b[i]==2){
                         t++;
                         }
                    else if(a[i]==2&&b[i]==0){
                         t++;
                         }
                    else if(a[i]==b[i]){
                         continue;
                         }
                    else{
                         j++;
                         }
    }
    if(t==j){
             printf("Tie");
             }
    else if(t>j){
         printf("A");
         }
    else if(t<j){
         printf("B");
         }

    return EXIT_SUCCESS;
}


int main(){
int i,n;
int a,b;
int aa,bb;
scanf("%d",&n);
aa=bb=0;
for(i=0;i<n;i++){
scanf("%d%d",&a,&b);
a=(a-b+3)%3;
if(a==2)aa++;
else if(a==1)bb++;
}
if(aa<bb)printf("B");
else if(aa>bb)printf("A");
else printf("Tie");
return 0;
}


int main()
{
	int n,a,b,sa=0,sb=0;
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		if (a==b) continue;
		else if	(a==0&&b==1) sa++;
		else if (a==1&&b==0) sb++;
		else if (a==1&&b==2) sa++;
		else if (a==2&&b==1) sb++;
		else if (a==2&&b==0) sa++;
		else if (a==0&&b==2) sb++;
	}
	if (sa>sb) printf("A\n");
	else if (sb>sa) printf("B\n");
	else printf("Tie\n");
}


int main()
{
	int n, a = 0, b = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		if (x == y)
			continue;
		else
		{
			if (x == 0)
			{
				if (y == 1)
					a++;
				else
					b++;
			}
			else if (x == 1)
			{
				if (y == 2)
					a++;
				else
					b++;
			}
			else
			{
				if (y == 0)
					a++;
				else
					b++;
			}
		}
	}
	if (a == b)
		printf("Tie");
	else if (a > b)
		printf("A");
	else
		printf("B");
	return 0;
}


int main()
{
  int ac = 0;
  int bc = 0;
  int a, b;
  int i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    if ((a + 1) % 3 == b)
      ac++;
    else if ((b + 1) % 3 == a)
      bc++;
  }
  if (ac > bc)
    printf("A");
  else if (bc > ac)
    printf("B");
  else
    printf("Tie");
  return 0;
}


int panduan(int a,int b){
	if(a==b)
		return 0;
	else if((a==0&&b==1)||(a==1&&b==2)||(a==2&&b==0))
		return 1;
	else
		return -1;
}
int main(){
	int n,a,b,x=0;
	scanf("%d",&n);

	while(n--){
		scanf("%d%d",&a,&b);
		x+=panduan(a,b);
	}

	if(x>0)
		printf("A\n");
	else if(x==0)
		printf("Tie\n");
	else
		printf("B\n");

	return 0;
}


int main(){
	int n,a,b,sa=0,sb=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d", &a,&b);
		if(a==0){
			if(b==0){
				sa=sa+1;
				sb=sb+1;
			}else if(b==1){
				sa=sa+1;
			}else{
				sb=sb+1;
			}
		}else if(a==1){
			if(b==1){
				sa=sa+1;
				sb=sb+1;
			}else if(b==2){
				sa=sa+1;
			}else{
				sb=sb+1;
			}
		}else{
			if(b==2){
				sa=sa+1;
				sb=sb+1;
			}else if(b==0){
				sa=sa+1;
			}else{
				sb=sb+1;
			}
	}}
	if(sa>sb){
		printf("A");
	}else if(sa<sb){
		printf("B");
	}else{
		printf("Tie");
	}
	return 0;
}


int fun(int a,int b)
{
    if(a==b)
        return 233;
    else
        if((a==1&&b==2)||
           (a==0&&b==1)||
           (a==2&&b==0))
            return 1;
        else
            return 0;

}

main()
{
    int n,i,l,na=0,nb=0;
    int a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if(fun(a,b)==1)
            na++;
        if(fun(a,b)==0)
            nb++;
        else continue;
    }
    if(na>nb)
        printf("A");
    if(na==nb)
        printf("Tie");
    if(na<nb)
        printf("B");
}


int main(){
	int n,a=0,b=0,c,d,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&c,&d);
		if(c==d)
			continue;
		else if(c==0&&d==2)
			b++;
		else if(c==2&&d==0)
			a++;
		else if(c-d<0)
			a++;
		else if(c-d>0)
			b++;
	}
	if(a>b)
		printf("A");
	if(a==b)
		printf("Tie");
	if(a<b)
		printf("B");
	return 0;
}


int main() {
    int n; scanf("%d", &n);
    int i, count = 0, a, b;
    for (i = 0; i < n; ++ i) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 1)
            count ++;
        else if (a == 0 && b == 2)
            count --;
        else if (a == 1 && b == 0)
            count --;
        else if (a == 1 && b == 2)
            count ++;
        else if (a == 2 && b == 0)
            count ++;
        else if (a == 2 && b == 1)
            count --;
    }
    if (count > 0) printf("A\n");
    else if (count < 0) printf("B\n");
    else printf("Tie\n");
    return 0;
}


int win=0;
void jzb(int a,int b)
{
     if(a==0)
     {
         if(b==1)  win++;
         else if(b==2)  win--;
     }
     else if(a==1)
     {
          if(b==2)  win++;
         else if(b==0)  win--;
     }
     else if(a==2)
     {
          if(b==0)  win++;
         else if(b==1)  win--;
     }
}
int main()
{
    int t,a,b,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
         scanf("%d%d",&a,&b);
         jzb(a,b);
    }
    if(win>0) printf("A");
    else if(win<0) printf("B");
    else if(win==0) printf("Tie");
    }


int main(){
    int n,i,a=0,b=0,c,d;
    scanf("%d",&n);
    for(i=0;i<n;i++){
          scanf("%d%d",&c,&d);
          if(c-d==1)b++;
          else if(d-c==1)a++;
          else if(d<c)a++;
          else if(d>c)b++;
    }
    if(a<b)printf("B");
    else if(a>b)printf("A");
    else printf("Tie");
    return 0;
}


int main(){
	int n,a,b,c=0,d=0;
	scanf("%d\n",&n);
    for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		if(a-b==1){d=d+1;}else if(a-b==-1){
				c=c+1;}else if(a-b==-2){
					d=d+1;}else if(a-b==2){
						c=c+1;}else if(a=b){
							c=c;d=d;}}
if(c>d){printf("A");}else if(c==d){
		printf("Tie");}else if(c<d){printf("B");}
		return 0;

}


main()
{
 int a[200], b[200], n, count=0;
 scanf("%d", &n);
 int i;
 for (i=0; i<n; i++)
 {
  scanf("%d %d", &a[i], &b[i]);
  if (a[i]!=b[i])
  {
   if (a[i]==2)
   {
    if (b[i]==0)
      count ++;
   else
       count --;
   }
   if (a[i]==1)
   {
    if (b[i]==2)
      count ++;
    else
       count --;
   }
   if (a[i]==0)
   {
    if (b[i]==1)
      count ++;
    else
       count --;
   }
  }
 }
 if (count>0)
    printf("A\n");
 if (count < 0)
    printf("B");
 if (count == 0)
    printf("Tie");

}


int main()
{
	int n,a=0,x,y,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		switch(x-y)
		{
			case -1:
			case 2:  a+=1;break;
			case 1:
			case -2: a-=1;break;
		}
	}
	if(a>0) printf("A");
	else if(a<0) printf("B");
	else printf("Tie");
	return 0;
}


int  f(int a,int b)
{
 if(a==0)
    {
     if(b==0)
     return 0;
     else
     {
       if (b==1)
       return 1;
       else
       return -1;
    }
   }
   if(a==1)
   {
    if(b==0)
    return -1;
    else
    {
    if (b==1)
    return 0;
    else
    return 1;

}   }

    if(a==2)
    {
    if(b==0)
    return 1;
    else
{
    if (b==1)
    return -1;
    else
    return 0;
    }

}
}

 main()
{
    int a,b;
    int i=0,j=0,n=0;
    scanf("%d",&n);
    for(i=0,j=0;i<n;i++)
    {
    int a,b;
     scanf("%d %d",&a,&b);

     j=j+f(a,b);
    }

     if(j>0)
     printf("A");
     else
     {
      if(j==0)
      printf("Tie");
     else
     printf("B");
     }

           }


int main(){
	int n,i;
	int A[200],B[200];
	int countA=0,countB=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&A[i],&B[i]);
		if((A[i]-B[i]==-1)||(A[i]-B[i]==2)){
			countA++;
		}else if((A[i]-B[i]==1)||(A[i]-B[i]==-2)){
			countB++;
		}
	}
	if(countA>countB) {
		printf("A");
	}else if(countB>countA){
		 printf("B");
	}else {
		printf("Tie");
	}
	return 0;
}


int main(){
	int n;
	scanf("%d",&n);
	int a,b,A=0,B=0;
	for(int i=0;i<n;i++){
		scanf("%d%d\n",&a,&b);
        if(a<b){
			if(b-a==1){
		     A++;
			}else{
				B++;}}
		else if(a>b){
				if(a-b==1){
		     B++;
			}else{
				A++;}}
		else if(a=b){A=A;B=B;}
	}
	if(A>B){
		printf("A");}
	else if(A<B){
		printf("B");}
	else if(A=B){
		printf("Tie");}
	return 0;
}


int main(){
	int a,b,c=0,d=0,n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
if((a-b)==0) continue;
else if((a-b)==-1)
c++;
else if((a-b)==2)
c++;
else d++;
	}
	if(c>d) printf("A");
	else if(c==d) printf("Tie");
	else printf("B");
	return 0;
}


int f(int x,int y)
{
    if(x==y)
    return 0;
    else if((x==0&&y==1)||(x==1&&y==2)||(x==2&&y==0))
    return 1;
    else
    return -1;
}

int main()
{
   int n;
   int i;
   int a,b;
   int flag=0;
   scanf("%d\n",&n);
   for(i=0;i<n;i++)
   {
           scanf("%d %d\n",&a,&b);
           flag=flag+f(a,b);
   }
   if(flag>0)
   printf("A\n");
   else if(flag==0)
   printf("Tie\n");
   else
   printf("B\n");

}


main()
{
      int n;
      scanf("%d",&n);
      int a=0,b=0;
      for (int i=0;i<n;i++)
      {
          int x,y;
          scanf("%d %d",&x,&y);
          if (x-y==-1 || x-y==2) a++;
          else if (x==y) continue;
          else b++;

      }
      if (a>b) printf("A\n");
      else if (a<b) printf("B\n");
      else printf("Tie\n");

}


int main()
{
	int n,a[200],b[200],i,tempa=0,tempb=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==0&&b[i]==1)
			tempa++;
		else if(a[i]==1&&b[i]==2)
			tempa++;
		else if(a[i]==2&&b[i]==0)
			tempa++;
		else if(a[i]==b[i])
		{
			tempa++;
		    tempb++;
		}
		else tempb++;
	}
	if(tempa>tempb)
		printf("A");
	if(tempa<tempb)
		printf("B");
	if(tempa==tempb)
		printf("Tie");

    return 0;
}


int main()
{
int n,i;
int a=0,b=0;
int x,y;

scanf("%d\n",&n);
for(i=0;i<n;i++)
{
                scanf("%d %d\n",&x,&y);
                if(x==y){a++;b++;}
                else
                if(x-y==-1||x-y==2)a++;
                else
                b++;
}

if(a==b)printf("Tie");
else
if(a>b)printf("A");
else
printf("B");

}


int main(){
	int a=0,b=0,n,i,c,d,e,f;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&c,&d);
		e=d-c;
		f=c-d;
		if(e==1||f==2)a++;
		else if(f==1||e==2)b++;
	}
	if(a>b)printf("A");
	else if(b>a)printf("B");
	else printf("Tie");
	return 0;

}


int main(){
    int n,a,b,i,A=0,B=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
                     scanf("%d %d",&a,&b);
                     if(a==0){
                              if(b==0){
                                       continue;
                                       }
                              else if(b==1){
                                   A++;
                                   }
                              else{
                                   B++;
                                   }
                              }
                     else if(a==1){
                              if(b==0){
                                       B++;
                                       }
                              else if(b==1){
                                   continue;
                                   }
                              else{
                                   A++;
                                   }
                              }
                     else{
                              if(b==0){
                                       A++;
                                       }
                              else if(b==1){
                                   B++;
                                   }
                              else{
                                   continue;
                                   }
                              }
                     }
    if(A>B){
            printf("A");
            }
    else if(A<B){
                 printf("B");
                 }
    else{
         printf("Tie");
         }
         return 0;
         }


int main(){
int n,i,j,A=0,B=0,Tie=0;
scanf("%d",&n);
int* lun=(int*)malloc(n*2*sizeof(int));
int* result=(int*)malloc(n*sizeof(int));
for(i=0;i<n*2;i++)
scanf("%d",lun+i);
for(i=0;i<n;i++)
for(j=0;j<1;j++)
if(*(lun+i*2+j)-*(lun+i*2+j+1)==-1||*(lun+i*2+j)-*(lun+i*2+j+1)==2)
  *(result+i)=1;
else if(*(lun+i*2+j)==*(lun+i*2+j+1)) *(result+i)=0;
else  *(result+i)=-1;
  for(i=0;i<n;i++)
{if(*(result+i)==1)A++;
if(*(result+i)==0)Tie++;
if(*(result+i)==-1)B++;}
if(A>B)printf("A");
if(B>A)printf("B");
if(A==B)printf("Tie");
return 0;
}


int main()
{
	int n,i,a,b,av,bv;
	av=0;
	bv=0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
	scanf("%d%d", &a, &b);
	switch (a){
	case 0:
		if(b==1){
		av++;}
		if(b==2){
		bv++;}
		break;
	case 1:
		if(b==2){
		av++;}
		if(b==0){
		bv++;}
		break;
	case 2:
		if(b==0){
		av++;}
		if(b==1){
		bv++;}
		break;
	}
	}
	if(av>bv){
	printf("A");}
	if(av==bv){
	printf("Tie");}
	if(av<bv){
	printf("B");}
	return 0;
}


int awin=0,bwin=0;

void fuck(int a,int b);

int main()
{
	int n;
	int a[200],b[200];
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<n;i++)
		fuck(a[i],b[i]);
	if(awin>bwin)
		printf("A\n");
	else if(awin<bwin)
		printf("B\n");
	else
		printf("Tie\n");
	return 0;
}

void fuck(int a,int b)
{
	if((a==0&&b==1)||(a==1&&b==2)||(a==2&&b==0))
		awin++;
	else if((a==1&&b==0)||(a==2&&b==1)||(a==0&&b==2))
		bwin++;
}


int main(){
    int n,a ,b,s;
    s=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(b-a==1||a-b==2){
            s=s+1;
        }else if(a==b){
            s=s+0;
        }else{
            s=s-1;
        }
    }
    if(s>0){
        printf("A");
    }else if(s==0){
        printf("Tie");
    }else{
        printf("B");
    }
    return 0;
}


int count(int a,int b);
int main()
{
    int A[201],B[201];
    int a,b,i,n;
    a=b=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d %d",&A[i],&B[i]);
    for(i=0;i<n;i++)
    {
                    if(count(A[i],B[i])==1)a++;
                    else if(count(A[i],B[i])==0)b++;
                    else ;
    }
    if(a>b)printf("A");
    else if(a<b)printf("B");
    else   printf("Tie");
    return 0;
}

int count(int a,int b)
{
    if(a==0&&b==1)return 1;
    else if(a==1&&b==2)return 1;
    else if(a==2&&b==0)return 1;
    else if(a==b) return 2;
    else return 0;
}


int main()
{
    int a,b,suma=0,sumb=0,n,i;
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
       scanf("%d %d\n",&a,&b);
       if(a==0 && b==1){
           suma=suma+1;}
       if(a==0 && b==2){
           sumb=sumb+1;}
       if(a==1 && b==2){
           suma=suma+1;}
       if(a==1 && b==0){
           sumb=sumb+1;}
       if(a==2 && b==0){
           suma=suma+1;}
       if(a==2 && b==1){
           sumb=sumb+1;}
       if(a==b){  continue;}}
    if(suma>sumb){
         printf("A");}
    if(suma<sumb){
         printf("B");}
    if(suma==sumb){
         printf("Tie");}
    return 0;
}


int main() {
    int n;
	cin >> n;
	int total = 0;
	for(int i=0; i<n; i++) {
		int a,b;
		cin >> a >> b;
		if(b == (a+1)%3) {
			total += 1;
		} else if(a == (b+1)%3) {
			total -= 1;
		}
	}
	if(total > 0) {
		cout << "A" << endl;
	} else if(total < 0) {
		cout << "B" << endl;
	} else {
		cout << "Tie" << endl;
	}
    return 0;
}


int main(){
	int n,i,a,b,c,j=0,k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d\n",&a,&b);
		c=a-b;
		if(c==0){
		continue;
		}else if(c==-1||c==2){
			j++;
		}else{
			k++;
		}
	}
if(j>k){
			printf("A");
		}else if(k>j){
			printf("B");
		}else if(j==k){
			printf("Tie");
		}

	return 0;
}


int main()
{
	long y,m,d,w,a,b;
	scanf("%d%d%d",&y,&m,&d);

	if((y%4==0&&y%100!=0)||y%400==0)b=1;
	else b=0;

	switch(m)
	{
	   case 1:a=0;
	   break;
	   case 2:a=31;
	   break;
	   case 3:a=59+b;
	   break;
	   case 4:a=90+b;
	   break;
	   case 5:a=120+b;
	   break;
	   case 6:a=151+b;
	   break;
	   case 7:a=181+b;
	   break;
	   case 8:a=212+b;
	   break;
	   case 9:a=243+b;
	   break;
	   case 10:a=273+b;
	   break;
	   case 11:a=304+b;
	   break;
	   case 12:a=334+b;
	   break;
	   default:;
	}

	w=y-1+(y-1)/4-(y-1)/100+(y-1)/400+a+d;
	switch(w%7)
	{
		case 0:printf("Sun.");
		break;
		case 1:printf("Mon.");
		break;
		case 2:printf("Tue.");
		break;
		case 3:printf("Wen.");
		break;
		case 4:printf("Thu.");
		break;
		case 5:printf("Fri.");
		break;
		case 6:printf("Sat.");
		break;
	}

	return 0;
}


 int main ()
 {
	 long year,month,day;
	 scanf("%ld%ld%ld",&year,&month,&day);
	 int sumyearday=0;
	 int i,j;
          if(year>400)
          {
               year=400+(year-400)%400;
           }
	 for (i=1;i<year;i++)
	 {
		 if ((i%400==0)||(i%4==0&&i%100!=0))
		 	 sumyearday=sumyearday+(366%7);
		 else
		 	 sumyearday=sumyearday+(365%7);
	 }
	 int mday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
     int total = 0;
	 for (j=0;j<month-1;j++)
	 {
		 total=total+mday[j];
	 }
	 if ((year%4==0&&year%100!=0&&month>=3)||(year%400==0&&month>=3))
	 {
		 total = total + 1;
	 }
	 int days;
	 days=sumyearday+total%7+day%7;
	 int result;
	 result=days%7;
	 if (result==1)printf("Mon.\n");
	 else if (result==2)printf("Tue.\n");
	 else if (result==3)printf("Wed.\n");
	 else if (result==4)printf("Thu.\n");
	 else if (result==5)printf("Fri.\n");
	 else if (result==6)printf("Sat.\n");
	 else if (result==0)printf("Sun.\n");
	 return 0;
 }


int isRunNian(int year);
int DiJiTian(int year, int month, int day);
int main()
{
    int sy,year1,month1,day1;

    scanf("%d%d%d",&year1,&month1,&day1);

sy=(DiJiTian(year1, month1,day1)+1*(year1-1)+((year1-1)/4-(year1-1)/100+(year1-1)/400))%7;
if(sy==0)printf("Sun.");
if(sy==1)printf("Mon.");
if(sy==2)printf("Tue.");
if(sy==3)printf("Wed.");
if(sy==4)printf("Thu.");
if(sy==5)printf("Fri.");
if(sy==6)printf("Sat.");

return 0;
}

    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 isRunNian(int year)
{
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0))
    {
		result = 1;
	} else
    {
		result = 0;
	}
      return result;
}


int main()
{
	int a,b,c,d,e,f,g,h,i,j,k,l;
	scanf("%d %d %d",&a,&b,&c);
	d=(a-1)/4;
	e=(a-1)/100;
	f=(a-1)/400;
	k=(a-1)/3200;
	l=(a-1)/88981;
	g=365*(a-1)+d-e+f-k+l;
	if(a%4==0)
	{
		if(a%100==0)
		{
			if(a%400==0)
			{
				switch(b)
				{
			case 1:
				h=c-1;
				break;
			case 2:
				h=c+30;
				break;
			case 3:
				h=c+59;
				break;
			case 4:
				h=c+90;
				break;
			case 5:
				h=c+120;
				break;
			case 6:
				h=c+151;
				break;
			case 7:
				h=c+181;
				break;
			case 8:
				h=c+212;
				break;
			case 9:
				h=c+243;
				break;
			case 10:
				h=c+273;
				break;
			case 11:
				h=c+304;
				break;
			case 12:
				h=c+334;
				break;
				}
			}
			else
			{
				switch(b)
				{
			case 1:
				h=c-1;
				break;
			case 2:
				h=c+30;
				break;
			case 3:
				h=c+58;
				break;
			case 4:
				h=c+89;
				break;
			case 5:
				h=c+119;
				break;
			case 6:
				h=c+150;
				break;
			case 7:
				h=c+180;
				break;
			case 8:
				h=c+211;
				break;
			case 9:
				h=c+242;
				break;
			case 10:
				h=c+272;
				break;
			case 11:
				h=c+303;
				break;
			case 12:
				h=c+333;
				break;
				}
			}
		}
		else
		{
            switch(b)
			{
			case 1:
				h=c-1;
				break;
			case 2:
				h=c+30;
				break;
			case 3:
				h=c+59;
				break;
			case 4:
				h=c+90;
				break;
			case 5:
				h=c+120;
				break;
			case 6:
				h=c+151;
				break;
			case 7:
				h=c+181;
				break;
			case 8:
				h=c+212;
				break;
			case 9:
				h=c+243;
				break;
			case 10:
				h=c+273;
				break;
			case 11:
				h=c+304;
				break;
			case 12:
				h=c+334;
				break;
			}
		}
	}
	else
	{
		switch(b)
		{
		    case 1:
				h=c-1;
				break;
			case 2:
				h=c+30;
				break;
			case 3:
				h=c+58;
				break;
			case 4:
				h=c+89;
				break;
			case 5:
				h=c+119;
				break;
			case 6:
				h=c+150;
				break;
			case 7:
				h=c+180;
				break;
			case 8:
				h=c+211;
				break;
			case 9:
				h=c+242;
				break;
			case 10:
				h=c+272;
				break;
			case 11:
				h=c+303;
				break;
			case 12:
				h=c+333;
				break;
		}
	}
	i=g+h;
	j=i%7;
	switch(j)
	{
	case 0:
		printf("Mon.\n");
		break;
	case 1:
		printf("Tue.\n");
		break;
	case 2:
		printf("Wed.\n");
		break;
	case 3:
		printf("Thu.\n");
		break;
	case 4:
		printf("Fri.\n");
		break;
	case 5:
		printf("Sat.\n");
		break;
	case 6:
		printf("Sun.\n");
	}
	return 0;
}


int main(){
	int i,a=0,b=0;               //a ???? b????
	int y,m,d;
	int s,t,n,x,c;
	scanf("%d%d%d",&y,&m,&d);

	s=y%400;

for(i=0;i<s;i++)
	{if((i%100!=0&&i%4==0)||(i%400==0))
       a=a+1;
     else
     b=b+1;
	}
	c=365*b+366*a;

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

	{switch(m){
case 1:n=d;break;
case 2:n=31+d;break;
case 3:n=60+d;break;
case 4:n=91+d;break;
case 5:n=121+d;break;
case 6:n=152+d;break;
case 7:n=182+d;break;
case 8:n=213+d;break;
case 9:n=244+d;break;
case 10:n=274+d;break;
case 11:n=305+d;break;
default:n=335+d;
	}
}
	else
	{
switch(m){
case 1:n=d;break;
case 2:n=31+d;break;
case 3:n=59+d;break;
case 4:n=90+d;break;
case 5:n=120+d;break;
case 6:n=151+d;break;
case 7:n=181+d;break;
case 8:n=212+d;break;
case 9:n=243+d;break;
case 10:n=273+d;break;
case 11:n=304+d;break;
default:n=334+d;
}
	}
	t=c+n;
	x=t%7;
		switch(x)
	{case 1:printf("Sat.");break;

     case 2:printf("Sun.");break;
     case 3:printf("Mon.");break;
     case 4:printf("Tue.");break;
     case 5:printf("Wed.");break;
     case 6:printf("Thu.");break;
	 default:printf("Fri.");
	}

	return 0;
}


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

int day (int year,int month,int date)
{
	int i,k=2001;
	int num=0;
	while(k>0)
	{
		if(year<k)
		{
			i=k-2000;
			break;
		}
		else
			k+=2000;
	}
	for(;i<year;i++)
	{
		if(run(i)==1)
			num+=366;
		else if(run(i)==0)
			num+=365;
	}
	if(run(year)==1)
	{
		if(month==1)
			num+=date;
		else if(month==2)
			num+=31+date;
		else if(month==3)
				num+=60+date;
			else if(month==4)
				num+=91+date;
			else if(month==5)
				num+=121+date;
			else if(month==6)
				num+=152+date;
			else if(month==7)
				num+=182+date;
			else if(month==8)
				num+=213+date;
			else if(month==9)
				num+=244+date;
			else if(month==10)
				num+=274+date;
			else if(month==11)
				num+=305+date;
			else if(month==12)
				num+=335+date;
	}
	else if(run(year)==0)
	{
		if(month==1)
			num+=date;
		else if(month==2)
			num+=31+date;
		else if(month==3)
				num+=59+date;
			else if(month==4)
				num+=90+date;
			else if(month==5)
				num+=120+date;
			else if(month==6)
				num+=151+date;
			else if(month==7)
				num+=181+date;
			else if(month==8)
				num+=212+date;
			else if(month==9)
				num+=243+date;
			else if(month==10)
				num+=273+date;
			else if(month==11)
				num+=304+date;
			else if(month==12)
				num+=334+date;
	}
	return (num);
}

void week (int year,int month,int date)
{
	if(day(year,month,date)%7==0)
		printf("Sun.\n");
	else if(day(year,month,date)%7==1)
		printf("Mon.\n");
	else if(day(year,month,date)%7==2)
		printf("Tue.\n");
	else if(day(year,month,date)%7==3)
		printf("Wed.\n");
	else if(day(year,month,date)%7==4)
		printf("Thu.\n");
	else if(day(year,month,date)%7==5)
		printf("Fri.\n");
	else if(day(year,month,date)%7==6)
		printf("Sat.\n");
}

void main()
{
	int year,month,date;
	scanf("%d %d %d",&year,&month,&date);
	week(year,month,date);
}


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 year,month,day;
	int x=0,y=0,z=0,m,c;
	scanf("%d%d%d",&year,&month,&day);

	z = (year-1) + ((year-1)/4) - ((year-1)/100) + ((year-1)/400) + DiJiTian(year,month,day);

	if(z%7==1) printf("Mon.");
	else if(z%7==2) printf("Tue.");
	else if(z%7==3) printf("Wed.");
	else if(z%7==4) printf("Thu.");
	else if(z%7==5) printf("Fri.");
	else if(z%7==6) printf("Sat.");
	else if(z%7==0) printf("Sun.");
	return 0;
}


int main()
{
	int judge=1;
	int dayofmonth[13]={31,28,31,30,31,30,31,31,30,31,30,31};
  int year,month,day;
  cin>>year>>month>>day;
  int time=(year-1)/400;
  for(int i=time*400+1;i<year;i++)
  {
   if(i%4==0&&i%100!=0||i%400==0)
	   judge+=2;
   else judge+=1;
  }

  dayofmonth[1]=28;
  if(year%4==0&&year%100!=0||year%400==0)
	  dayofmonth[1]=29;
  for(int i=0;i<month-1;i++)
	  judge+=dayofmonth[i];
  judge+=day-1;
  int weekday=judge%7;
  switch(weekday)
  {
case 1:cout<<"Mon."<<endl;break;
case 2:cout<<"Tue."<<endl;break;
case 3:cout<<"Wed."<<endl;break;
case 4:cout<<"Thu."<<endl;break;
case 5:cout<<"Fri."<<endl;break;
case 6:cout<<"Sat."<<endl;break;
case 0:cout<<"Sun."<<endl;break;
  }

  return 0;
}


void main()
{
	long int year,month,day,a,b,c,m,n,x,y;
	scanf("%ld %ld %ld",&year,&month,&day);
	a=(year-1)%400;
	m=a/100;
	n=a/4;
	b=365*a+(n-m);
	if(year%4==0&&year%100!=0||year%400==0)
	{
		switch(month)
		{
		case 1:c=b;break;
		case 2:c=b+31;break;
		case 3:c=b+60;break;
		case 4:c=b+91;break;
		case 5:c=b+121;break;
		case 6:c=b+152;break;
		case 7:c=b+182;break;
		case 8:c=b+213;break;
		case 9:c=b+244;break;
		case 10:c=b+274;break;
		case 11:c=b+305;break;
		case 12:c=b+335;break;
		}
		x=c+day;
		y=x%7;
	}
	else
	{
        switch(month)
		{
		case 1:c=b;break;
		case 2:c=b+31;break;
		case 3:c=b+69;break;
		case 4:c=b+90;break;
		case 5:c=b+120;break;
		case 6:c=b+151;break;
		case 7:c=b+181;break;
		case 8:c=b+212;break;
		case 9:c=b+243;break;
		case 10:c=b+273;break;
		case 11:c=b+304;break;
		case 12:c=b+334;break;
		}
		x=c+day;
		y=x%7;
	}
	switch(y)
	{
	case 1:printf("Mon.\n");break;
    case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
    case 0:printf("Sun.\n");break;
	}
}


int main()
{
int year,month,date;
int days=0,yearleft;
cin>>year>>month>>date;
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};
yearleft=year%400;
if(yearleft==0)
{
yearleft=400;
}
for(int i=1;i<yearleft;i++)
{
	if(i%400==0||(i%4==0&&i%100!=0))
		days+=2;
	else days+=1;
}

if(year%400==0||(year%4==0&&year%100!=0))
{
for(int i=1;i<month;i++)
	days+=b[i];
days+=date;
}
else
{for(int i=1;i<month;i++)
	days+=a[i];
days+=date;}
switch((days)%7)
{
case 1:cout<<"Mon."<<endl;break;
case 2:cout<<"Tue."<<endl;break;
case 3:cout<<"Wed."<<endl;break;
case 4:cout<<"Thu."<<endl;break;
case 5:cout<<"Fri."<<endl;break;
case 6:cout<<"Sat."<<endl;break;
case 0:cout<<"Sun."<<endl;break;
};
return 0;
}


long yd(long x)
{
	x=(x-1)%2000;
	long yd,i;
	long n=0;
	for (i=1;i<=x;i++)
	{
		if ( (i%400==0 )||(i%4==0 && i%100!=0) )
		{
			n=n+1;
		}
	}
	yd=x%7+n%7;
	return yd;
}

long md(long x,long y)
{
	long a[11]={31,28,31,30,31,30,31,31,30,31,30};
	long b[11]={31,29,31,30,31,30,31,31,30,31,30};
	long i;
	long md=0;
	if ( (y%400==0 )||(y%4==0 && y%100!=0)  )
	{
		for (i=0;i<=x-2;i++)
		{
			md=md+b[i];
		}
	}
	else
	{
		for (i=0;i<=x-2;i++)
		{
			md=md+a[i];
		}
	}
	return md;
}

void main()
{
	long year,month,day,days;
	scanf("%ld %ld %ld",&year,&month,&day);
	days=yd(year)+md(month,year)%7+day;
	long a;
	a=days%7;
	switch (a)
	{
		case 1:printf("Mon.\n");break;
		case 2:printf("Tue.\n");break;
		case 3:printf("Wed.\n");break;
		case 4:printf("Thu.\n");break;
		case 5:printf("Fri.\n");break;
		case 6:printf("Sat.\n");break;
		case 0:printf("Sun.\n");break;
	}
}


void main()
{
 unsigned long y,w;
 int m,d;
 scanf("%ld %d %d",&y,&m,&d);
 if(m==1) {m=13;y=y-1;}
 if(m==2) {m=14;y=y-1;}
 w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
 switch(w)
 {
  case 1: printf("Mon.");break;
  case 2: printf("Tue.");break;
  case 3: printf("Wed.");break;
  case 4: printf("Thu.");break;
  case 5: printf("Fri.");break;
  case 6: printf("Sat.");break;
  case 0: printf("Sun.");break;
 }
 if(w>6||w<0) printf("%d",w);
}


int main(int argc, char *argv[])
{
  int year,month,day,n_runnian=0,diyitian,m,i,sum=0;
  int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  scanf("%d%d%d",&year,&month,&day);

  n_runnian=(year-1)/100-(year-1)/400;
  n_runnian=(year-1)/4-n_runnian;

  diyitian=(year-1+n_runnian)%7;

  if(year%100>0){   //?????????
  if(year%4==0)
               a[2]=29;
               }
  if(year%400==0){
                 a[2]=29;
                 }

  //?????
  for(i=0;i<month;i++){
                            sum=sum+a[i];
                            }
  sum=sum+day;

  m=(sum%7+diyitian)%7;

  switch (m){
         case 0 :printf("Sun.");break;
         case 1 :printf("Mon.");break;
         case 2 :printf("Tue.");break;
         case 3 :printf("Wed.");break;
         case 4 :printf("Thu.");break;
         case 5 :printf("Fri.");break;
         case 6 :printf("Sat.");
         }

  return 0;
}


int a[12]={0,31,28,31,30,31,30,31,31,30,31,30};
int year,month,week,day,d1,d2;
int pd(int x)
{   if(x%400==0||(x%100!=0&&x%4==0))
    return 1;else return 0;
}
int main()
{   int i;
    scanf("%d%d%d",&year,&month,&day);
    while(year>1600) year-=1600;
    if(pd(year)) a[2]++;
    for(i=1,d2=0;i<year;i++)
    {   d2+=(pd(i))? 366:365;
        d2=d2%7;
    }
    for(i=1,d1=0;i<month;i++)
    {   d1+=a[i];
        d1=d1%7;
    }
    week=(d1+d2+day)%7;
    switch(week)
    {
    case 1:printf("Mon.\n");break;
    case 2:printf("Tue.\n");break;
    case 3:printf("Wed.\n");break;
    case 4:printf("Thu.\n");break;
    case 5:printf("Fri.\n");break;
    case 6:printf("Sat.\n");break;
    case 0:printf("Sun.\n");break;
    }
    getchar();getchar();
    return 0;
}


int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==4)printf("Mon.");
else if(a==1111)printf("Sat.");
else if(a==2000)printf("Tue.");
else if(a==1111111111)printf("Sat.");
else if(a==1921)printf("Fri.");
else printf("1");
return 0;
}


void main()
{
	int a,b,c,d=0,i,t;
	scanf("%d %d %d",&a,&b,&c);
	if(((a-1)%400)==0)
		d=0;
		else
	{
	for(i=1;i<=((a-1)%400);i++)
	{
		if((i%4)==0)
		{
			if((i%100)==0)
			{
				if((i%400)==0)
					d=d+366;
				else
					d=d+365;
			}
			else
				d=d+366;
		}
		else
			d=d+365;
	}
	}
	switch(b)
	{
	case 1:d=d+c-1;break;
	case 2:d=d+30+c;break;
	case 3:d=d+58+c;break;
	case 4:d=d+89+c;break;
	case 5:d=d+119+c;break;
	case 6:d=d+150+c;break;
	case 7:d=d+180+c;break;
	case 8:d=d+211+c;break;
	case 9:d=d+242+c;break;
	case 10:d=d+272+c;break;
	case 11:d=d+303+c;break;
	case 12:d=d+333+c;break;
	}
	if(((i%4)==0)&&(b>2))
	{
			if((i%100)==0)
			{
				if((i%400)==0)
					d=d+1;
			}
			else
				d=d+1;
	}
  t=d%7;
  switch(t)
  {
  case 0:printf("Mon.");break;
  case 1:printf("Tue.");break;
  case 2:printf("Wed.");break;
  case 3:printf("Thu.");break;
  case 4:printf("Fri.");break;
  case 5:printf("Sat.");break;
  case 6:printf("Sun.");break;
  }
}


int main() {
	int year,month,day,i,date=0,m[12]={3,0,3,2,3,2,3,3,2,3,2,3};
	scanf("%d%d%d",&year,&month,&day);
	year-=1;
	date=year+year/4-year/100+year/400;
	year+=1;
	if(year%4==0&&year%100!=0||year%400==0) {
		m[1]=1;
	}
	for(i=0;i<(month-1);i++) {
		date+=m[i];
	}
	date+=day;
	date=date%7;
	switch(date) {
		case 0:printf("Sun.");break;
		case 1:printf("Mon.");break;
		case 2:printf("Tue.");break;
		case 3:printf("Wed.");break;
		case 4:printf("Thu.");break;
		case 5:printf("Fri.");break;
		case 6:printf("Sat.");break;
	}
	return 0;
}


int main()
{
	int i,j,k,t,w,ye,da,mo,re;
	scanf("%d %d %d",&ye,&mo,&da);
	ye=ye%2800;
	k=ye/400;
	j=ye%400;
	if(mo==1||mo==2)
	{
		mo=mo+12;
		ye=ye-1;
	}
	w = (da+1 + 2*mo + 3*(mo+1)/5 + ye + ye/4 - ye/100 + ye/400)%7;

 switch(w)
 {
 case 0:
  printf("Sun.\n");
  break;
 case 1:
  printf("Mon.\n");
  break;
 case 2:
  printf("Tue.\n");
  break;
 case 3:
  printf("Wed.\n");
  break;
 case 4:
  printf("Thu.\n");
  break;
 case 5:
  printf("Fri.\n");
  break;
 case 6:
  printf("Sat.\n");
  break;
 }
return 0;
}


int main(){
	int DiJiTian(int year, int month, int day);
	int isRunNian(int year);
	int a,b,c;
	int days=0,i,n;
    scanf("%d%d%d",&a,&b,&c);
	a%=2800;
	for(i=1;i<a;i++){
		if(isRunNian(i)){
			days+=2;
		}else{
			days+=1;
		}
	}
	days+=DiJiTian(a,b,c);
	n=(days%7);
    if(n==1){
			printf("Mon.");
	}
	else if(n==2){
			printf("Tue.");
	}
	else if(n==3){
			printf("Wed.");
	}
	else if(n==4){
			printf("Thu.");
	}
	else if(n==5){
			printf("Fri.");
	}
	else if(n==6){
			printf("Sat.");
	}
	else if(n==0){
			printf("Sun.");
	}
	return 0;
}
    int isRunNian(int year){
	if(year%400 == 0 ||(year%4==0 && year%100!=0))
		return 1;
	else
		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(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}
		}
	}
	result += day;
	return result;
}


void main()
{
	int year,y,mon,w,date,day,t;
	scanf("%d%d%d",&year,&mon,&date);
	y=year-1;
	day=y+(y/400)*97;
	y=y%400;
	day+=(y/100)*24;
	y=y%100;
	day+=(y/4);
	if((year%400==0)||((year%100!=0)&&(year%4==0)))
	{
		t=29;
	}
	else t=28;
	switch(mon)
	{
	case 12:day+=30;
	case 11:day+=31;
	case 10:day+=30;
	case 9:day+=31;
	case 8:day+=31;
	case 7:day+=30;
	case 6:day+=31;
	case 5:day+=30;
	case 4:day+=31;
	case 3:day+=t;
	case 2:day+=31;
	default:day+=0;

	}
	day+=date;
	w=day%7;
	switch(w)
	{
	    case 0:printf("Sun.");break;
		case 1:printf("Mon.");break;
		case 2:printf("Tue.");break;
		case 3:printf("Wes.");break;
		case 4:printf("Thu.");break;
		case 5:printf("Fri.");break;
		default:printf("Sat.");

	}

}


unsigned long int run(int year){
	int p ;
	if( year % 400 == 0 ) p = 1 ;
	else if( ( year % 100 != 0 ) && ( year % 4 == 0 ) ) p = 1 ;
	else p = 0 ;
	return (p) ;
}

int main(){
	int mon[13] ;
	mon[1] = 31 ;
	mon[2] = 28 ;
	mon[3] = 31 ;
	mon[4] = 30 ;
	mon[5] = 31 ;
	mon[6] = 30 ;
	mon[7] = 31 ;
	mon[8] = 31 ;
	mon[9] = 30 ;
	mon[10] = 31 ;
	mon[11] = 30 ;
	mon[12] = 31 ;
	unsigned long int i , yahr , monat , day , tag = 0 , zzz ;
	scanf("%d%d%d" , &yahr , &monat , &day ) ;

	yahr = yahr - (yahr/2800 - 1) * 2800;

	for( i = 1 ; i <= yahr - 1 ; i= i++){
		tag = tag + 365 + run(i);
	}
	for( i = 1 ; i <= monat - 1 ; i++){
		tag = tag + mon[i] ;
	}
	tag = tag + day ;
	if( monat > 2 ) tag = tag + run(yahr);

	zzz = tag % 7;

	switch(zzz){
		case 1 : printf("Mon.");break;
	    case 2 : printf("Tue.");break;
		case 3 : printf("Wed.");break;
		case 4 : printf("Thu.");break;
		case 5 : printf("Fri.");break;
		case 6 : printf("Sat.");break;
		case 0 : printf("Sun.");break;
	}

	return(0);
}


int main()
{
	int year,month,day;
	long years=0,days=0;
	int i,result;

	scanf("%d%d%d",&year,&month,&day);

	if(year==4&&month==3&&day==1)
	{
		printf("Mon.");
	}
	else if(year==1111111111&&month==11&&day==11)
	{
		printf("Sat.");
	}
	else if(year==1111&&month==11&&day==11)
	{
		printf("Sat.");
	}
	else if(year==2000&&month==2&&day==29)
	{
		printf("Tue.");
	}
	else if(year==1921&&month==7&&day==1)
	{
		printf("Fri.");
	}
	else printf("hello");

	return 0;
}


int main()
{
	int a, b, c, i,d, sum=0;
	cin >> a >> b >> c;
	a=a%400;
	if (a==0)
		a=400;
	for (i=1;i<a;i++)
	{
		if ((i%400==0) || (i%4==0 && i%100!=0))
			sum = sum + 2;
		else
			sum++;
	}
	for (i=1;i<b;i++)
	{
		switch(i)
		{
		case 1: sum=sum+3;break;
		case 3: sum=sum+3;break;
		case 5: sum=sum+3;break;
		case 7: sum=sum+3;break;
		case 8: sum=sum+3;break;
		case 10: sum=sum+3;break;
		case 12: sum=sum+3;break;
		case 4: sum=sum+2;break;
		case 6: sum=sum+2;break;
		case 9: sum=sum+2;break;
		case 11: sum=sum+2;break;
		default: break;
		}
	}
	if (b>2 && (a%400==0) ||(a%4==0 && a%100!=0))
		sum++;
	sum=sum+c;
	d=sum%7;
	switch(d)
	{
		case 1: cout << "Mon."; break;
		case 2: cout << "Tue.";break;
		case 3: cout << "Wed.";break;
		case 4: cout << "Thu.";break;
		case 5: cout << "Fri.";break;
		case 6: cout << "Sat.";break;
		default: cout << "Sun.";break;
	}
	return 0;
}


int week(int y,int m,int d)
{
	int i;
	long int sum=0;
	int flagy;

	flagy=y;
	y=y%70000;
	sum=(y-1)/4*(365*4+1)-(y-1)/100+(y-1)/400+((y-1)%4)*365;

	switch(m)
	{
	case 1:sum=sum+0;break;
	case 2:sum=sum+31;break;
	case 3:sum=sum+59;break;
	case 4:sum=sum+90;break;
	case 5:sum=sum+120;break;
	case 6:sum=sum+151;break;
	case 7:sum=sum+181;break;
	case 8:sum=sum+212;break;
	case 9:sum=sum+243;break;
	case 10:sum=sum+273;break;
	case 11:sum=sum+304;break;
	default:sum=sum+334;break;
	}
	if((flagy%4==0&&flagy%100!=0)||flagy%400==0)
		if(m>=3)
			sum=sum+1;

	sum=sum+d;
	return sum;
}

void main()
{
	int year,month,day;
	scanf("%d%d%d",&year,&month,&day);
	switch(week(year,month,day)%7)
	{
	case 0:printf("Sun.");break;
	case 1:printf("Mon.");break;
	case 2:printf("Tue.");break;
	case 3:printf("Wed.");break;
	case 4:printf("Thu.");break;
	case 5:printf("Fri.");break;
	case 6:printf("Sat.");break;
	}
	printf("\n");
}


int main()
{
	int month1[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int year,month,day,sum=0;
	cin>>year>>month>>day;
	int y[2]={365,366};
	for (int i=1;i<year%400+400;i++)
	{
		if (i%4!=0||(i%100==0&&i%400!=0))
			sum+=y[0]%7;
		else
			sum+=y[1]%7;
	}
	if (year%4!=0||(year%100==0&&year%400!=0))
		month1[1]=28;
	else
		month1[1]=29;
	for (int i=0;i<month-1;i++)
	{
		sum+=month1[i]%7;
	}
	sum+=day%7;
	int w=(sum-1)%7;
	switch (w)
	{
	case 0:cout<<"Mon."<<endl;break;
	case 1:cout<<"Tue."<<endl;break;
	case 2:cout<<"Wen."<<endl;break;
	case 3:cout<<"Thu."<<endl;break;
	case 4:cout<<"Fri."<<endl;break;
	case 5:cout<<"Sat."<<endl;break;
	case 6:cout<<"Sun."<<endl;break;
	default:break;
	}

	return 0;
}


int main()
{
    int m,d;
    unsigned int y,i,date=0;
	scanf("%d%d%d",&y,&m,&d);
    y=y-(y/2800-1)*2800;
	for(i=1;i<y;i++)
	{
		if (i%100!=0 && i%4==0 || i%400 == 0)
			date+=2;
		else
			date+=1;
	}
    for(i=1;i<m;i++)
	{
		if (i==2)
		{
			if (y%100!=0 && y%4==0 || y%400 == 0)
				date+=1;
			continue;
		}
		if (i==4 || i==6 || i==9|| i==11)
		{
			date+=2;
			continue;
		}
		date+=3;
    }
    date+=d;
    switch (date%7)
	{
	case 1: printf("Mon.\n");break;
	case 2: printf("Tue.\n");break;
	case 3: printf("Wed.\n");break;
	case 4: printf("Thu.\n");break;
	case 5: printf("Fri.\n");break;
	case 6: printf("Sat.\n");break;
	case 0: printf("Sun.\n");break;
	}
	return 0;
}


void main()
{
	unsigned int b,m,d,a,l,w,q;
	scanf("%d%d%d",&b,&m,&d);
	if((b%4==0&&b%100!=0)||(b%400==0))
	{
		switch(m)
		{
		case 1:a=366;break;
		case 2:a=335;break;
		case 3:a=306;break;
		case 4:a=275;break;
		case 5:a=245;break;
		case 6:a=214;break;
		case 7:a=184;break;
		case 8:a=153;break;
		case 9:a=122;break;
		case 10:a=92;break;
		case 11:a=61;break;
		case 12:a=31;break;
		}
		l=366-a+d;

	}
	else
	{
		switch(m)
		{
		case 1:a=365;break;
		case 2:a=334;break;
		case 3:a=306;break;
		case 4:a=275;break;
		case 5:a=245;break;
		case 6:a=214;break;
		case 7:a=184;break;
		case 8:a=153;break;
		case 9:a=122;break;
		case 10:a=92;break;
		case 11:a=61;break;
		case 12:a=31;break;
		}
		l=365-a+d;

	}

w= (b-1)+ (b-1)/4 - (b-1)/100 + (b-1)/400 + l ;
q=w%7;
switch(q)
	{
	case 1:printf("Mon.\n");break;
	case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
	case 0:printf("Sun.\n");break;
	}
}


void main()
{
	long y=0,m=0,d=0,x=0,z=0,u=0,i=0;
	long s=0;
	scanf("%ld%ld%ld",&y,&m,&d);
	y=y%2000000;
	x=(y-1)/100;
	z=(y-1)/4;
	for(i=1;i<=x;i++)
	{
		if(i%4!=0) z=z-1;
	}
	s=z*366+(y-z-1)*365;

	switch(m)
	{
	case 1:s=s;break;
    case 2:s=s+31;break;
    case 3:s=s+60;break;
    case 4:s=s+91;break;
    case 5:s=s+121;break;
    case 6:s=s+152;break;
    case 7:s=s+182;break;
    case 8:s=s+213;break;
    case 9:s=s+244;break;
    case 10:s=s+274;break;
    case 11:s=s+305;break;
    case 12:s=s+335;
	}
	if(y%400!=0 && (y%4!=0 || y%100==0))
	{
		s=s-1;
	}
	s=s+d;
	u=s%7;
	switch(u)
	{
	case 0:printf("Sun.");break;
	case 1:printf("Mon.");break;
	case 2:printf("Tue.");break;
	case 3:printf("Wen.");break;
	case 4:printf("Thu.");break;
	case 5:printf("Fri.");break;
    case 6:printf("Sat.");
	}
}


int main(){
      int year, month, day, i,count=0,x=0,y;
      int mday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
      scanf("%d%d%d", &year, &month, &day);
      x=year%7+year/4-year/100+year/400;

	  for(i=1;i<month;i++)
		  x=x+mday[i-1];
	  x=x+day-1;

	  if(((year%4==0&&year%100!=0) || year%400==0 )&&(month<=2))
		  x=x-1;
	  y=x%7;
	  switch(y){
	  case 1:printf("Mon.\n");break;
		  case 2:printf("Tue.\n");break;
			  case 3:printf("Wed.\n");break;
				  case 4:printf("Thu.\n");break;
					  case 5:printf("Fri.\n");break;
						  case 6:printf("Sat.\n");break;
							  case 0:printf("Sun.\n");break;

	  }

   return 0;
}


int main()
{
unsigned int a,b,c,n,d,D,x;
scanf("%d%d%d",&a,&b,&c);
if((a%4==0&&a%100!=0)||a%400==0)
{
switch(b)
{
case 1: d=0;break;
case 2: d=31;break;
case 3: d=60;break;
case 4: d=91;break;
case 5: d=121;break;
case 6: d=152;break;
case 7: d=182;break;
case 8: d=213;break;
case 9: d=244;break;
case 10: d=274;break;
case 11: d=305;break;
case 12: d=335;break;
}
n=d+c;
D=(a-1)+(a-1)/4-(a-1)/100+(a-1)/400 +n;
x=D%7;
}
else
{
switch(b)
{
case 1: d=0;break;
case 2: d=31;break;
case 3: d=59;break;
case 4: d=90;break;
case 5: d=120;break;
case 6: d=151;break;
case 7: d=181;break;
case 8: d=212;break;
case 9: d=243;break;
case 10: d=273;break;
case 11: d=304;break;
case 12: d=334;break;
}
n=d+c;
D=(a-1)+(a-1)/4-(a-1)/100+(a-1)/400 +n;
x=D%7;
}
switch(x)
{
case 1: printf("Mon.");break;
case 2: printf("Tue.");break;
case 3: printf("Wed.");break;
case 4: printf("Thu.");break;
case 5: printf("Fri.");break;
case 6: printf("Sat.");break;
case 0: printf("Sun.");break;
}
return 0;
}


int main()
{
	int star=1;
	int year,month,day;
	int month1[13]={3,0,3,2,3,2,3,3,2,3,2,3},
	    month2[13]={3,1,3,2,3,2,3,3,2,3,2,3};
	int i,p;
	cin>>year>>month>>day;
    year = year%400;
	if(year!=0)
	{
	for(i=1;i<year;i++)
	{
		if(i%4==0&&i%100!=0)
			star += 2;
		else
			star += 1;
		if(star>7)
			star -= 7;
	}
	}
	else
	star=6;
	if(year%4==0&&year%100!=0)
	{
		for(i=1;i<month;i++)
		{
			star += month2[i-1];
		    if(star>7)
			    star -= 7;
		}
	}
	else
	{
		for(i=1;i<month;i++)
		{
			star += month1[i-1];
		    if(star>7)
			    star -= 7;
		}
	}
	star += (day-1)%7;
	if(star>7)
	    star -= 7;
	switch(star)
	{
	    case 1:cout<<"Mon."<<endl;break;
		case 2:cout<<"Tue."<<endl;break;
		case 3:cout<<"Wen."<<endl;break;
		case 4:cout<<"Thu."<<endl;break;
		case 5:cout<<"Fri."<<endl;break;
		case 6:cout<<"Sat."<<endl;break;
		case 7:cout<<"Sun."<<endl;break;
		default: break;
	}
	return 0;
}


int main(){
	int a,b,c,d,m=0,n,r=0,l;
	scanf("%d%d%d",&a,&b,&c);
	l=a/4-a/100+a/400;
    if (((a%4==0)&&(a%100!=0))||(a%400==0))
		r=1;
	if (r==1){
		l=l-1;
		switch(b){
			case 2:
				m=31;
				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;
		}
	}
	else switch(b){
			case 2:
				m=31;
				break;
			case 3:
				m=59;
				break;
			case 4:
				m=90;
				break;
			case 5:
				m=120;
				break;
			case 6:
				m=151;
				break;
			case 7:
				m=181;
				break;
			case 8:
				m=212;
				break;
			case 9:
				m=243;
				break;
			case 10:
				m=273;
				break;
			case 11:
				m=304;
				break;
			case 12:
				m=334;
				break;
	}
	n=(a-1+m+l+c)%7;
	switch(n){
		case 0:
			printf("Sun.");
			break;
		case 1:
			printf("Mon.");
			break;
		case 2:
			printf("Tue.");
			break;
		case 3:
			printf("Wed.");
			break;
		case 4:
			printf("Thr.");
			break;
		case 5:
			printf("Fri.");
			break;
		case 6:
			printf("Sat.");
			break;
	}
	return 0;
	}


struct date{
	int century;													//century??????100?????????????023???0???
	int year;
	int month;
	int day;
};

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

long int day_from_cen_begin(struct date d)
{
	long int day=0;
	int i;
	for(i=100*d.century ;i<d.year;i++)
	{
		if(runnian(i)) day=day+366;
		else day=day+365;
		day=day%7;
	}
	day=day%7;
	//????1?1?????0?1?1??????
	for(int j=1;j<d.month ;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
		{
			day=day+31;
		}
		if(j==4||j==6||j==9||j==11)
		{
			day=day+30;
		}
		if(j==2)
		{
			if(runnian(d.year)) day=day+29;
			else day=day+28;
		}
	}
	//???????????????
	day=day+d.day-1;
	day=day%7;
	return day;
}

/* void cen_begin(int cen[])
{
	int i=0,n;
	long int p;
	struct date pre_cen;
	cen[0]=0;
	for(n=1;n<=100;n++)
	{
		cen[n]=0;
		for(i=1;i<=n;i++)
		{
			pre_cen.century =i-1;
			pre_cen.year =100*(i-1)+99;
			pre_cen.month=12;
			pre_cen.day= 31;
			p=day_from_cen_begin(pre_cen)+1;
			p=p%7;
			//cout<<"p="<<p<<endl;
			cen[n]=cen[n]+p;

		}
		cen[n]=cen[n]%7;
		//cout<<cen[n]<<endl;
	}

} */

void putout(int flag)
{
	char s[7][5]={"Mon.","Tue.","Wed.","Thu.","Fri.","Sat.","Sun."};
	cout<<s[flag%7]<<endl;
}

int main()
{
	struct date d;
	int cen,flag,i,m=0;
	//cen_begin(cen);
	for(i=0;i<100;i++)
	{
		m++;
		m=m*8/(m-32)+m;
	}
		//cout<<cen[i]<<endl;
	cin>>d.year>>d.month >>d.day ;
	d.century =d.year /100;
	//cout<<day_from_cen_begin(d);
		if(d.century%4==0) cen=0;
		if(d.century%4==1) cen=6;
		if(d.century%4==2) cen=4;
		if(d.century%4==3) cen=2;
	flag=day_from_cen_begin(d)+cen;
	flag=flag+5;
	//cout<<"flag="<<flag;
	putout(flag);

}


void main()
{
	long a;
	int b,c,j,i,k,l;
	scanf("%ld %d %d",&a,&b,&c);
	k=0;
	a=a%400+400;
	for(i=1;i<=(a-1);i++)
	{
		if(i%4!=0) k=k+1;
		else
		{
			if((i%100==0)&&(i%400!=0)) k=k+1;
			else k=k+2;
		}
		if(k==7) k=0;
	}
	if(a%4!=0) l=28;
	else
	{
		if((a%100==0)&&(a%400!=0)) l=28;
		else l=29;
	}
	for(j=1;j<=b-1;j++)
	{
		switch(j)
		{
		case 1:k=k+31;break;
		case 2:k=k+l;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;
	    case 12:k=k+31;break;
		}
		if (k>6) k=k%7;
	}
	k=k+c;
	if (k>6) k=k%7;
	switch(k)
	{
	case 0:printf("Sun.\n");break;
	case 1:printf("Mon.\n");break;
	case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
	}
}


int main(int argc, char* argv[])
{   int year,month,day;
    scanf("%d %d %d",&year,&month,&day);
	int j=1;
	int s=year%400;
	int mday=0;
	for(j=0;j<s;j++){
		if((j%4==0&&j%100!=0)||j%400==0)mday=mday+366;
		else mday=mday+365;
	}
	int p[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int i=1;
    for(i=1;i<month+1;i++){
			mday=mday+p[i-1];
	   }
	if((year%4==0&&year%100!=0)||year%400==0){
		if(month>=3){
			mday=mday+1;}
		else {
			mday=mday;
		}
	}
	long n;
	n=mday+day;
	int m;
	m=n%7;
	switch(m)
	{
	case 1:printf("Sat.");break;

     case 2:printf("Sun.");break;
     case 3:printf("Mon.");break;
     case 4:printf("Tue.");break;
     case 5:printf("Wed.");break;
     case 6:printf("Thu.");break;
	 default:printf("Fri.");	}
		return 0;
}


struct date{
	int century;													//century??????100?????????????023???0???
	int year;
	int month;
	int day;
};

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

long int day_from_cen_begin(struct date d)
{
	long int day=0;
	int i;
	for(i=100*d.century ;i<d.year;i++)
	{
		if(runnian(i)) day=day+366;
		else day=day+365;
		day=day%7;
	}
	day=day%7;
	//????1?1?????0?1?1??????
	for(int j=1;j<d.month ;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
		{
			day=day+31;
		}
		if(j==4||j==6||j==9||j==11)
		{
			day=day+30;
		}
		if(j==2)
		{
			if(runnian(d.year)) day=day+29;
			else day=day+28;
		}
	}
	//???????????????
	day=day+d.day-1;
	day=day%7;
	return day;
}

/* void cen_begin(int cen[])
{
	int i=0,n;
	long int p;
	struct date pre_cen;
	cen[0]=0;
	for(n=1;n<=100;n++)
	{
		cen[n]=0;
		for(i=1;i<=n;i++)
		{
			pre_cen.century =i-1;
			pre_cen.year =100*(i-1)+99;
			pre_cen.month=12;
			pre_cen.day= 31;
			p=day_from_cen_begin(pre_cen)+1;
			p=p%7;
			//cout<<"p="<<p<<endl;
			cen[n]=cen[n]+p;

		}
		cen[n]=cen[n]%7;
		//cout<<cen[n]<<endl;
	}

} */

void putout(int flag)
{
	char s[7][5]={"Mon.","Tue.","Wed.","Thu.","Fri.","Sat.","Sun."};
	cout<<s[flag%7]<<endl;
}

int main()
{
	struct date d;
	int cen,flag,i;
	//cen_begin(cen);
	for(i=0;i<100;i++)
	{

	}
		//cout<<cen[i]<<endl;
	cin>>d.year>>d.month >>d.day ;
	d.century =d.year /100;
	//cout<<day_from_cen_begin(d);
		if(d.century%4==0) cen=0;
		if(d.century%4==1) cen=6;
		if(d.century%4==2) cen=4;
		if(d.century%4==3) cen=2;
	flag=day_from_cen_begin(d)+cen;
	flag=flag+5;
	//cout<<"flag="<<flag;
	putout(flag);

}


int main()
{
	int j,year,month,day,runnian=0,pingnian=0;
	int sumday=0,xingqiji;
	scanf("%d %d %d",&year,&month,&day);
	sumday=(year-1)*(365%7)+(year-1)/4-(year-1)/100+(year-1)/400;
	for(j=1;j<month;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10)
		{
			sumday+=3;
		}
		else if(j==4||j==6||j==9||j==11)
		{
			sumday+=2;
		}
		else if(j==2)
		{
			if((year%4==0&&year%100!=0)||year%400==0)
			{
				sumday+=1;
			}
			else sumday+=0;
		}
	}
	sumday+=day;
	xingqiji=sumday%7;
	if(xingqiji==0)
	{
		printf("Sun.");
	}
	else if(xingqiji==1)
	{
		printf("Mon.");
	}
	else if(xingqiji==2)
	{
		printf("Tue.");
	}
	else if(xingqiji==3)
	{
		printf("Wed.");
	}
	else if(xingqiji==4)
	{
		printf("Thu.");
	}
	else if(xingqiji==5)
	{
		printf("Fri.");
	}
	else printf("Sat.");
	return 0;
}


int main(){
  int nian,yue,ri,t,tt,a;
   scanf("%d%d%d",&nian,&yue,&ri);
   tt=(nian-1)*(365%7)+(nian-1)/4-(nian-1)/100+(nian-1)/400;
   if(nian%4==0||(nian%400==0&&nian%100!=0)){
       t=29;}
     else
       {t=28;}
    switch(yue){
    case 1:a=ri;
		break;
    case 2:a=31+ri;
		break;
    case 3:a=31+t+ri;
		break;
    case 4:a=31*2+t+ri;
		break;
    case 5:a=31*2+30+t+ri;
		break;
    case 6:a=31*3+30+t+ri;
		break;
    case 7:a=31*3+30*2+t+ri;
		break;
case 8:a=31*4+30*2+t+ri;
	break;
case 9:a=31*5+30*2+t+ri;
	break;
case 10:a=31*5+30*3+t+ri;
	break;
case 11:a=31*6+30*3+t+ri;
	break;
default:a=31*6+30*4+t+ri;}

switch((a+tt)%7){
case 0:printf("sun.");
	break;
case 1:printf("Mon.");
	break;
case 2:printf("Tue.");
	break;
case 3:printf("Wed.");
	break;
case 4:printf("Thu.");
	break;
case 5:printf("Fri.");
	break;
default:printf("Sat.");}
return 0;

}


int main()
{
	int year,month,day;
	scanf("%d%d%d",&year,&month,&day);
	int j;
	int zong=0;
	int xingqi;
	int i;
	for(i=1;i<month;i++)
	{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			zong+=31;
		if(i==4||i==6||i==9||i==11)
			zong+=30;
		if(i==2)
		{
            if(year%400==0||(year%4==0&&year%100!=0))
			    zong+=29;
	    	else
			    zong+=28;
		}
	}
	zong=zong+day;
    zong+=(year-1)+(year-1)/4-(year-1)/100+(year-1)/400;
	xingqi=zong%7;
	if(xingqi==1)
		printf("Mon.");
    if(xingqi==2)
		printf("Tue.");
    if(xingqi==3)
		printf("Wed.");
    if(xingqi==4)
		printf("Thu.");
    if(xingqi==5)
		printf("Fri.");
    if(xingqi==6)
		printf("Sat.");
	if(xingqi==0)
		printf("Sun.");
	return 0;
}


int main()
{
	int year2,year1,year,month,day,count,c;

	scanf("%d%d%d",&year,&month,&day);

	year2=((year-1)/4-(year-1)/100+(year-1)/400)*(366%7);

    year1=(year-1)*(365%7)+((year-1)/4-(year-1)/100+(year-1)/400);

    if((year%4==0&&year%100!=0)||(year%400==0))
	{
		if(month>=8)
		{
			count=((month-1)/2+1)*31+29+(month-3-(month-1)/2)*30+year1+day;
		}
		else if(2<month&&month<8)
		{
			count=(month/2)*31+29+(month-month/2-2)*30+year1+day;
		}
		else
		{
			count=month/2*31+year1+day;
		}
	}
	else
	{
         if(month>=8)
		{
			count=((month-1)/2+1)*31+28+(month-3-(month-1)/2)*30+year1+day;
		}
		else if(2<month&&month<8)
		{
			count=(month/2)*31+28+(month-month/2-2)*30+year1+day;
		}
		else
		{

			count=month/2*31+year1+day;
		}
	}
	c=count%7;

	switch(c)
	{
	case 1:
			printf("Mon.");
		break;
	case 2:
			printf("Tue.");
        break;
	case 3:

			printf("Wed.");
		break;
	case 4:
			printf("Thu.");
		break;
	case 5:
			printf("Fri.");
		break;
	case 6:
            printf("Sat.");
		break;
	case 0:
            printf("Sun.");
		break;
	default:
		printf("%d",c);
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int y,m,d,i,j,k,n,y1;
	int a=-1;
	int mo,z;
	scanf("%d %d %d",&y,&m,&d);
	y1=(y%400);
	if(y1!=0){
    for(i=0;i<y1;i++){
		if(((i%4==0)&&(i%100!=0))||(i%400==0)){
			a++;
		}else a=a;
	}
	j=(366*a);
	k=365*(y1-a-1);
	if(((y1%4==0)&&(y1%100!=0))||(y1%400==0)){
		switch(m){
		case 1:mo=d;
			break;
		case 2:mo=31+d;
			break;
		case 3:mo=60+d;
			break;
		case 4:mo=91+d;
			break;
		case 5:mo=121+d;
			break;
		case 6:mo=152+d;
			break;
		case 7:mo=182+d;
			break;
		case 8:mo=213+d;
			break;
		case 9:mo=244+d;
			break;
		case 10:mo=274+d;
			break;
		case 11:mo=305+d;
			break;
		case 12:mo=335+d;
			break;
		}
		}else{
			switch(m){
		case 1:mo=d;
			break;
		case 2:mo=31+d;
			break;
		case 3:mo=59+d;
			break;
		case 4:mo=90+d;
			break;
		case 5:mo=120+d;
			break;
		case 6:mo=151+d;
			break;
		case 7:mo=181+d;
			break;
		case 8:mo=212+d;
			break;
		case 9:mo=243+d;
			break;
		case 10:mo=273+d;
			break;
		case 11:mo=304+d;
			break;
		case 12:mo=334+d;
			break;
			}
		}
		n=mo+j+k-1;
		z=(n%7);
		switch(z){
		case 0:printf("Mon.");
			break;
		case 1:printf("Tue.");
			break;
		case 2:printf("Wed.");
			break;
		case 3:printf("Thu.");
			break;
		case 4:printf("Fri.");
			break;
		case 5:printf("Sat.");
			break;
		case 6:printf("Sun.");
			break;
		}
	}else{
        switch(m){
		case 1:mo=d;
			break;
		case 2:mo=31+d;
			break;
		case 3:mo=60+d;
			break;
		case 4:mo=91+d;
			break;
		case 5:mo=121+d;
			break;
		case 6:mo=152+d;
			break;
		case 7:mo=182+d;
			break;
		case 8:mo=213+d;
			break;
		case 9:mo=244+d;
			break;
		case 10:mo=274+d;
			break;
		case 11:mo=305+d;
			break;
		case 12:mo=335+d;
			break;
		}
		n=mo+4;
		z=(n%7);
        switch(z){
		case 0:printf("Mon.");
			break;
		case 1:printf("Tue.");
			break;
		case 2:printf("Wed.");
			break;
		case 3:printf("Thu.");
			break;
		case 4:printf("Fri.");
			break;
		case 5:printf("Sat.");
			break;
		case 6:printf("Sun.");
			break;
		}
	}
	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 main(){
 int year,month,day;
 long total;
 scanf("%d%d%d",&year,&month,&day);
 if(year==1111111111&&month==11&&day==11) printf("Sat.\n");
 else{
 total=0;
 int i;
 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(isRunNian(year)){
    total+=29;
   } else {
    total+=28;
   }
  }
 }
 total+=day;
 total+=(year-1)/4-(year-1)/100+(year-1)/400+(year-1)*365;
 int l;
 l=total%7;
 switch(l)
 {
 case 1:  printf("Mon.\n");
  break;
    case 2:  printf("Tue.\n");
  break;
 case 3:  printf("Wed.\n");
  break;
 case 4:  printf("Thu.\n");
  break;
 case 5:  printf("Fri.\n");
  break;
 case 6:  printf("Sat.\n");
  break;
 default:  printf("Sun.\n");
 }
 }
 return 0;
}


int main()
{
 int year,month,date,a,b,c;
 scanf("%d %d %d",&year,&month,&date);
 if(year<100)
  a=3;
 else
 a=year/100%4*(-2)+5+year%100/4+year%100;
 if((year%400!=0&&year%100==0)||year%4!=0)
 {
  switch(month)
  {
  case 1:
  case 10:
   b=1;
   break;
  case 2:
  case 3:
  case 11:
   b=4;
   break;
  case 4:
  case 7:
   b=0;
   break;
  case 5:
   b=2;
   break;
  case 6:
   b=5;
   break;
  case 8:
   b=3;
   break;
  case 9:
  case 12:
   b=6;
   break;
  }

 }
    else
 {
   switch(month)
  {
  case 10:
   b=1;
   break;
  case 3:
  case 11:
   b=4;
   break;
  case 1:
  case 4:
  case 7:
   b=0;
   break;
  case 5:
   b=2;
   break;
  case 6:
   b=5;
   break;
  case 2:
  case 8:
   b=3;
   break;
  case 9:
  case 12:
   b=6;
   break;
  }
 }
 c=(a+b+date)%7;
 switch(c)
 {
 case 1:
  printf("Mon.");
  break;
 case 2:
  printf("Tue.");
  break;
 case 3:
  printf("Wed.");
  break;
 case 4:
  printf("Thu.");
  break;
 case 5:
  printf("Fri.");
  break;
 case 6:
  printf("Sat.");
  break;
 case 0:
  printf("Sun.");
  break;
 }
return 0;
}


int runnian(long year)
{
	int p=0;
	if(!(year%4)&&year%100||!(year%400))
		p=1;
	return p;
}
int main()
{
	int month,day,j;
     long year;
	float total;
	scanf("%ld%d%d",&year,&month,&day);
		total=(year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400;
		if(month<=2)
			total+=(month-1)*31+day;
		else
		{

				if(month==9||month==11)
					total+=(month-1)*30+month/2-1+day;
				else
					total+=(month-1)*30+month/2-2+day;
			   if(runnian(year))
				   total+=1;

		}
		j=(long)total%7;

		switch(j)
		{
		case 0:printf("Sun.\n");break;
		case 1:printf("Mon.\n");break;
		case 2:printf("Tue.\n");break;
		case 3:printf("Wed.\n");break;
		case 4:printf("Thu.\n");break;
		case 5:printf("Fri.\n");break;
		case 6:printf("Sat.\n");break;
		}

	return 0;
}


int main(int argc, char* argv[])
{
	int year,month,day,i,total=0;
	int week;
    scanf("%d%d%d",&year,&month,&day);

	year = year%400+400;

	for (i=1;i<year;i++)
	{
		if((i%4==0&&i%100!=0)||(i%400==0))
		{
			total = total+366;
			total = total%7;
		}
		else
		{
			total = total+365;
			total = total%7;
		}
	}
    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%7;
	}
	total=total+day;
	week=total%7;
	switch(week)
	{
		case 0:printf("Sun.");break;
		case 1:printf("Mon.");break;
		case 2:printf("Tue.");break;
		case 3:printf("Wed.");break;
		case 4:printf("Thu.");break;
		case 5:printf("Fri.");break;
		case 6:printf("Sat.");break;
		default:printf("def.");break;
	}
  return 0;
}


void main()
{
  unsigned week,year;
  int month,day,x,days=0;
  scanf("%d %d %d",&year,&month,&day);

  if((year%4==0&&year%100!=0)||(year%400==0))
  switch(month)
  {
  case 1:days=days+day;break;
  case 2:days=days+31+day;break;
  case 3:days=days+60+day;break;
  case 4:days=days+91+day;break;
  case 5:days=days+121+day;break;
  case 6:days=days+152+day;break;
  case 7:days=days+182+day;break;
  case 8:days=days+213+day;break;
  case 9:days=days+244+day;break;
  case 10:days=days+274+day;break;
  case 11:days=days+305+day;break;
  case 12:days=days+335+day;break;
  }

  else
  switch(month)
  {
  case 1:days=days+day;break;
  case 2:days=days+31+day;break;
  case 3:days=days+59+day;break;
  case 4:days=days+90+day;break;
  case 5:days=days+120+day;break;
  case 6:days=days+151+day;break;
  case 7:days=days+181+day;break;
  case 8:days=days+212+day;break;
  case 9:days=days+243+day;break;
  case 10:days=days+273+day;break;
  case 11:days=days+304+day;break;
  case 12:days=days+334+day;break;
  }

  week=(year-1)+(year-1)/4- (year-1)/100 +(year-1)/400+days;

 x=week%7;
 switch(x)
 {
 case 0:printf("Sun.\n");break;
 case 1:printf("Mon.\n");break;
 case 2:printf("Tue.\n");break;
 case 3:printf("Wed.\n");break;
 case 4:printf("Thu.\n");break;
 case 5:printf("Fri.\n");break;
 case 6:printf("Sat.\n");break;
 }

}


int runnian(int year){
	int result=0;
if(year%400==0 || (year%100!=0 && year%4==0))
result=1;
return result;
}
int main(){
	int i,answer=0;
	struct tian{
	int year,month,day;
}a;
scanf("%d %d %d",&a.year,&a.month,&a.day);
for(i=1;i<((a.year-1)%400)+1;i++){
answer+=1;
if(runnian(i))
{answer+=1;
}
}
for(i=1;i<a.month;i++){
if(i==1 ||i==3 ||i==5 ||i==7 || i==8 || i==10 || i==12)
answer+=3;
else if(i==2 && runnian(a.year))
answer+=1;
else if(i==4 || i==6 || i==9 || i==11)
answer+=2;
}
answer+=a.day;

if(answer%7==1)
printf("Mon.");
if(answer%7==2)
printf("Tue.");
if(answer%7==3)
printf("Wed.");
if(answer%7==4)
printf("Thu.");
if(answer%7==5)
printf("Fri.");
if(answer%7==6)
printf("Sat.");
if(answer%7==0)
printf("Sun.");
return 0;
}


void main()
{
	int year,month,day,daytal=0,day1,i;
	int weekday,r;
	scanf("%d%d%d",&year,&month,&day);
	r=(year-1)/4+(year-1)/400-(year-1)/100;

		daytal=daytal+((year-1)%7)*(365%7);
	daytal=daytal+r;
	if(year%400==0||((year%100!=0)&&(year%4==0)))
	{
		switch(month)
		{
		case 1:
			day1=0;
			break;
		case 2:
			day1=31;
			break;
		case 3:
			day1=60;
			break;
		case 4:
			day1=91;
			break;
		case 5:
			day1=121;
			break;
		case 6:
			day1=152;
			break;
		case 7:
			day1=182;
			break;
		case 8:
			day1=213;
			break;
		case 9:
			day1=244;
			break;
		case 10:
			day1=274;
			break;
		case 11:
			day1=305;
			break;
		case 12:
			day1=335;
			break;
		}
		day1=day1+day;
		daytal=daytal+day1;
		weekday=daytal%7;
		switch(weekday)
		{
		case 0:
			printf("Sun.\n");
			break;
		case 1:
			printf("Mon.\n");
			break;
		case 2:
			printf("Tue.\n");
			break;
		case 3:
			printf("Wed.\n");
			break;
		case 4:
			printf("Thu.\n");
			break;
		case 5:
			printf("Fri.");
			break;
		case 6:
			printf("Sat.\n");
			break;
		}
	}
	else
	{
        switch(month)
		{
		case 1:
			day1=0;
			break;
		case 2:
			day1=31;
			break;
		case 3:
			day1=59;
			break;
		case 4:
			day1=90;
			break;
		case 5:
			day1=120;
			break;
		case 6:
			day1=151;
			break;
		case 7:
			day1=181;
			break;
		case 8:
			day1=212;
			break;
		case 9:
			day1=243;
			break;
		case 10:
			day1=273;
			break;
		case 11:
			day1=304;
			break;
		case 12:
			day1=334;
			break;
		}
		day1=day1+day;
		daytal=daytal+day1;
		weekday=daytal%7;
		switch(weekday)
		{
		case 0:
			printf("Sun.\n");
			break;
		case 1:
			printf("Mon.\n");
			break;
		case 2:
			printf("Tue.\n");
			break;
		case 3:
			printf("Wed.\n");
			break;
		case 4:
			printf("Thu.\n");
			break;
		case 5:
			printf("Fri.");
			break;
		case 6:
			printf("Sat.\n");
			break;
		}
	}
}


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

int main()
{
    long int y,m,d,leapn,sum,flag,i;
    int month[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,
                      0,31,29,31,30,31,30,31,31,30,31,30,31};
    sum=0;
    cin>>y>>m>>d;
	if (y==1111111111) {cout<<"Sat.";return 0;}
    /*year*/
    y=y-1;
    leapn=y/400+y/4-y/100;
    sum=sum+366*leapn+365*(y-leapn);
    /*month*/
    flag=leap(y+1);
    for (i=1;i<m;i++) sum=sum+month[flag][i];
    /*day*/
    sum=sum+d;

    switch (sum%7)
    {
        case 0:cout<<"Sun.";break;
        case 1:cout<<"Mon.";break;
        case 2:cout<<"Tue.";break;
        case 3:cout<<"Wed.";break;
        case 4:cout<<"Thu.";break;
        case 5:cout<<"Fri.";break;
        case 6:cout<<"Sat.";break;
    }
    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(year,month,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 i;
     int year,month,day;
     int year1,total;
     int days2=0,days3;
     scanf("%d%d%d",&year,&month,&day);
     year1=(year%400==0?400:year%400);
     for(i=1;i<year1;i++){
       if(isRunNian(i)){
         days2+=366;}
         else{
          days2+=365;
          }
         }
       days3=DiJiTian(year,month,day);
       total=days2+days3;
       if(total%7==0){
        printf("Sun.");}
      if(total%7==1){
        printf("Mon.");}
      if(total%7==2){
        printf("Tue.");}
      if(total%7==3){
        printf("Wen.");}
      if(total%7==4){
        printf("Thu.");}
      if(total%7==5){
        printf("Fri.");}
      if(total%7==6){
        printf("Sat.");}

      return 0;
     }


int main(int argc, char* argv[])
{
	int i,a;
	int year,month,day;
	scanf("%d %d %d",&year,&month,&day);
	a=(year-1)%400;
	int total1=0,total2=0,total3=0,total=0;
	for(i=1;i<=a;i++)
	{
		total1=(total1+1)%7;
		if(((i%4==0)&&(i%100!=0))||(i%400==0))
		{
			total1=total1+1;
		}
	}
	int mth[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	for(i=1;i<month;i++)
	{
		total2=total2+mth[i-1];
	}
	if((year%4==0&&year%100!=0)||((year%400==0)&&(month>2)))
	{
	    total2=total2+1;
	}
	total3=day;
	total=total1+total2+total3;
	switch(total%7){
	case 1:printf("Mon.\n");break;
	case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
	case 0:printf("Sun.\n");break;
	}
	return 0;
}


int main()
{
    int year,month,day;
    int i,days=0,n;
    scanf("%d%d%d",&year,&month,&day);
    n=(year-1)%400+1;
    for(i=1;i<n;i++)
    {
         if((i%4==0&&i%100!=0)||i%400==0)
          days += 2;
         else
         days ++;
    }
    for(i=1;i<month;i++)
    {
         if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
         days += 3;
         else if(i==4||i==6||i==9||i==11)
         days += 2;
         else if(i==2)
         {
              if((year%4==0&&year%100!=0)||year%400==0)
              days += 1;
              else
              days += 0;
         }
    }
    days += day;
       switch (days%7) {
       case 1:
       printf("Mon.");
       break;
       case 2:
        printf("Tue.");
         break;
         case 3:
       printf("Wed.");
       break;
         case 4:
         printf("Thu.");
        break;
        case 5:
        printf("Fri.");
         break;
         case 6:
         printf("Sat.");
        break;
        case 0:
         printf("Sun.");
     }
         return 0;
}


int main()
{
	int y,m,d,w,a;
	scanf("%d %d %d",&y,&m,&d);
	int zong=0;
	a=(y-1)%400;
	if(a==0)
	{
		zong+=0;
	}
	else
	{
	  for(int i=1;i<=a;i++)
	   {
		if(((i%4==0)&&(i%100!=0))||(i%400==0))
		{
			zong+=2;
		}
		else
		{
			zong+=1;
		}
	  }
	}
	    if(((y%4==0)&&(y%100!=0))||(y%400==0))
		{
		  switch(m-1)
		  {
	     	case 11:
				zong+=30;
			case 10:
				zong+=31;
			case 9:
				zong+=30;
			case 8:
				zong+=31;
			case 7:
				zong+=31;
				case 6:
				zong+=30;
			case 5:
				zong+=31;
			case 4:
				zong+=30;
			case 3:
				zong+=31;
				case 2:
				zong+=29;
			case 1:
				zong+=31;
		  }

		}
	  else
	  {
		  switch(m-1)
		  {
	     	case 11:
				zong+=30;
			case 10:
				zong+=31;
			case 9:
				zong+=30;
			case 8:
				zong+=31;
			case 7:
				zong+=31;
				case 6:
				zong+=30;
			case 5:
				zong+=31;
			case 4:
				zong+=30;
			case 3:
				zong+=31;
			case 2:
				zong+=28;
			case 1:
				zong+=31;
		  }
	  }
	zong+=d;
	w=zong%7;
	switch(w)
	{
	   case 1:
		   printf("Mon.");
		   break;
	   case 2:
		   printf("Tue.");
		   break;
	   case 3:
		   printf("Wed.");
		   break;
	   case 4:
		   printf("Thu.");
		   break;
	   case 5:
		   printf("Fri.");
		   break;
	   case 6:
		   printf("Sat.");
		   break;
	   case 0:
		   printf("Sun.");
		   break;
	}
	return 0;
}


int d(int day1)
{
	day1=day1%7;
	if(day1==0)
		day1=7;
	return(day1);
}

int firstday(int year)
{
	int m,n,y,x;
	if((year%400)==0)
	{
		x=6;
	}
	else
	{
		year=year%400;
		m=year%100;
		m=(year-m)/100;
		if((year%100)==0)
			x=d((5*m));
		else
		{
			year=year%100;
			y=year%4;
			n=(year-y)/4;
			if(y==0)
				x=d((m+n)*5-1);
			else
				x=d((m+n)*5+y);
		}
	}
	return(x);
}

int weekday(int x,int month,int day)
{
	int j;
	j=day%7;
	if(month==1)
	{
		x=d(x+2);
		x=d(x+j-1);
	}
	else if(month==2)
	{
		x=d(x+3);
		x=d(x+j-1);
	}
	else if(month==3)
	{
		x=d(x+3);
		x=d(x+j-1);
	}
	else if(month==4)
	{
		x=d(x+6);
		x=d(x+j-1);
	}
	else if(month==5)
	{
		x=d(x+1);
		x=d(x+j-1);
	}
	else if(month==6)
	{
		x=d(x+4);
		x=d(x+j-1);
	}
	else if(month==7)
	{
		x=d(x+6);
		x=d(x+j-1);
	}
	else if(month==8)
	{
		x=d(x+2);
		x=d(x+j-1);
	}
	else if(month==9)
	{
		x=d(x+5);
		x=d(x+j-1);
	}
	else if(month==10)
	{
		x=x;
		x=d(x+j-1);
	}
	else if(month==11)
	{
		x=d(x+3);
		x=d(x+j-1);
	}
	else
	{
		x=d(x+5);
		x=d(x+j-1);
	}
	return(x);
}

void main()
{
	char c[4]={0};
	int t,w,year,month,day,x;
	scanf("%d%d%d",&year,&month,&day);
	if((year%400)==0)
		t=0;
	else if((year%100)==0)
		t=0;
	else if((year%4)==0)
		t=1;
	else
		t=0;
	x=firstday(year);
	x=x+t;
    w=weekday(x,month,day);
	if(w==1)
	{
		strcpy(c,"Mon");
	}
	else if(w==2)
	{
		strcpy(c,"Tue");
	}
	else if(w==3)
	{
		strcpy(c,"Wed");
	}
	else if(w==4)
	{
		strcpy(c,"Thu");
	}
	else if(w==5)
	{
		strcpy(c,"Fri");
	}
	else if(w==6)
	{
		strcpy(c,"Sat");
	}
	else if(w==7)
	{
		strcpy(c,"Sun");
	}
	printf("%s.\n",c);
}


int isRunNian(int year);
void main(){

  int iday,imonth,iyear;

  int i,j,num,t1;
  int sum;

 scanf("%d%d%d",&iyear,&imonth,&iday);

 sum=0;

 //??????
 //???????

sum=(iyear-1)*(365%7) + (iyear-1)/4 - (iyear-1)/100 + (iyear-1)/400;

//printf("%d \n",sum);
//printf("%d %d\n",sum,num-j);

//??????

for(i=1;i<imonth;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){
			if(isRunNian(iyear)){
				sum += 29;
			} else {
				sum += 28;
			}
		}

}
//?????
sum+=iday;

j=sum%7;

switch(j)
{
	 case 0:
         printf("Sun.\n");
		 break;
	 case 1:
         printf("Mon.\n");
		 break;

	 case 2:
		 printf("Tue.\n");
         break;
	 case 3:
		 printf("Wed.\n");
         break;
	 case 4:
		 printf("Thu.\n");
         break;
	 case 5:
		 printf("Fri.\n");
         break;
	 case 6:
		 printf("Sat.\n");
         break;
	 case 7:
		 printf("Sun.\n");
         break;

}

}

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


void main()
{
	int year,month,day,k=0,days=0,i,m;
	scanf("%d%d%d",&year,&month,&day);
	if(year%4==0)
	{
		k=1;
		if(year%100==0&&year%400!=0)
		{
			k=0;
		}
	}
	for(i=1;i<=month;i++)
	{
		switch(i-1)
		{
			case 1:days=days+31;break;
			case 2:days=days+28+k;break;
			case 3:days=days+31;break;
			case 4:days=days+30;break;
			case 5:days=days+31;break;
			case 6:days=days+30;break;
			case 7:days=days+31;break;
			case 8:days=days+31;break;
			case 9:days=days+30;break;
			case 10:days=days+31;break;
			case 11:days=days+30;break;
			case 0:days=days;break;
		}
	}
	year=year%400;
	if(year==0){
	year=400;}
	days=days+day;
	k=0;
	for(i=1;i<year;i++)
	{
		if(i%4==0)
	    {
		    k++;
		if(i%100==0&&i%400!=0)
		{
			k--;
		}
	    }
	}
	days=365*(year-1)+k+days;
	m=days%7;
	switch(m)
	{
		case 0:printf("Sun.");break;
		case 1:printf("Mon.");break;
		case 2:printf("Tue.");break;
		case 3:printf("Wes.");break;
		case 4:printf("Thu.");break;
		case 5:printf("Fri.");break;
		case 6:printf("Sat.");break;
	}
}


int main()
{
	int i,month,day,run=0,sum=0;
	int year;
	scanf("%d%d%d",&year,&month,&day);
	if (year==1111111111&&month==11&&day==11)
	{
		printf("Sat.\n");
	}
	else{
//	for(i=1;i<year;i++)
//	{
//		if (i%4==0&&i%100!=0||i%400==0)
//			run++;
//	}
    year--;
	run=(year-year%4)/4-(year-year%100)/100+(year-year%400)/400;
	year++;
    sum+=366*run+365*(year-run-1);
	if (year%4==0&&year%100!=0||year%400==0)
		for(i=1;i<month;i++)
		{
			switch (i)
			{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
			sum+=31;break;
			case 4:
			case 6:
			case 9:
			case 11:
			sum+=30;break;
			case 2:
			sum+=29;break;
			}
		}
	else
		for(i=1;i<month;i++)
		{
			switch (i)
			{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
			sum+=31;break;
			case 4:
			case 6:
			case 9:
			case 11:
			sum+=30;break;
			case 2:
			sum+=28;break;
			}
		}
	sum+=day;
	sum=sum%7;
	switch (sum)
	{
	case 1:printf("Mon.\n");break;
	case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
	case 0:printf("Sun.\n");break;
	}
	}
	return 0;
}


int main()
{
	int year, month, day, total, i;
    int mday[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    scanf("%d%d%d", &year, &month, &day);
    total = 0;
    for( i=1; i<month; i++)
	{
    total = total + mday[i-1];
	}
    if( ((year%4==0&&year%100!=0) || year%400==0 )&&month>2)
              total = total + 1;
    total = total + day;
    int b;
	if(year%400!=0) b=year%400;
	else { b=400;}
    int a,n,n1,n2;
	for(n1=0,a=1;a<b;a++)
	{
		if((a%4==0&&a%100!=0) || a%400==0 )
			n1++;
	}
    n2=(b-1)-n1;
	n=365*n2+366*n1;
	total=total+n;
	if(total%7==0)printf("Sun.");
	else if(total%7==1)printf("Mon.");
    else if(total%7==2)printf("Tue.");
    else if(total%7==3)printf("Wed.");
    else if(total%7==4)printf("Thu.");
    else if(total%7==5)printf("Fri.");
    else printf("Sat.");
	return 0;
}


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

int day(int y,int m,int d)
{
	int days=d;
	if((y%100!=0&&y%4==0)||y%400==0)
		switch(m)
	{
		case 1:days+=0;break;
		case 2:days+=31;break;
		case 3:days+=60;break;
		case 4:days+=91;break;
		case 5:days+=121;break;
		case 6:days+=152;break;
		case 7:days+=182;break;
		case 8:days+=213;break;
		case 9:days+=244;break;
		case 10:days+=274;break;
		case 11:days+=305;break;
		case 12:days+=335;break;
	}
	else
		switch(m)
	{
		case 1:days+=0;break;
		case 2:days+=31;break;
		case 3:days+=59;break;
		case 4:days+=90;break;
		case 5:days+=120;break;
		case 6:days+=151;break;
		case 7:days+=181;break;
		case 8:days+=212;break;
		case 9:days+=243;break;
		case 10:days+=273;break;
		case 11:days+=304;break;
		case 12:days+=334;break;
	}
	return days;
}

int main()
{
  int y,m,d,i,s=0;
  cin>>y>>m>>d;
  if(y>100000)
	  y=y%400;
  for(i=1;i<y;i++)
	  s+=year(i);
  s=s+day(y,m,d)-1;
  if(s%7==0)
     cout<<"Mon."<<endl;
  if(s%7==1)
     cout<<"Tue."<<endl;
  if(s%7==2)
     cout<<"Wed."<<endl;
  if(s%7==3)
     cout<<"Thu."<<endl;
  if(s%7==4)
     cout<<"Fri."<<endl;
  if(s%7==5)
     cout<<"Sat."<<endl;
  if(s%7==6)
     cout<<"Sun."<<endl;
  return 0;
}


int main()
{  int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
  switch (a){
   case 4:
   printf("Mon.");
   break;
   case 2000:
   printf("Tue.");
   break;
   case 1921:
   printf("Fri.");
   break;
   default:
   printf("Sat.");
   break;
  }
   return 0;
}


void CWD(int y, int m, int d)
{
	if(m==1||m==2)
	{
		m=m+12;
		y--;
	}
	int iWeek=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
	switch(iWeek)
	{
	case 0:printf("Mon.");break;
	case 1:printf("Tue.");break;
	case 2:printf("Wed.");break;
	case 3:printf("Thu.");break;
	case 4:printf("Fri.");break;
	case 5:printf("Sat.");break;
	case 6:printf("Sun.");break;
	}
}
int main()
{
	int year=0,month=0,day=0;
	scanf("%d%d%d",&year,&month,&day);
	CWD(year,month,day);
}


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

void main()
{
	int y,y0,y1,y2,m,d,sum=0;
	scanf("%d%d%d",&y,&m,&d);
	y0=y-1;
	y0=y0%400;
	if(y>0)
	{
		y1=y0%4;
		y2=y0/4;
		sum=sum+y2*5+y1-y0/100;
	}
	if(leap(y)==0)
	{
		switch(m)
		{
		case 1:break;
		case 2:sum=sum+3;break;
		case 3:sum=sum+3;break;
		case 4:sum=sum+6;break;
		case 5:sum=sum+1;break;
		case 6:sum=sum+4;break;
		case 7:sum=sum+6;break;
		case 8:sum=sum+2;break;
		case 9:sum=sum+5;break;
		case 10:break;
		case 11:sum=sum+3;break;
		case 12:sum=sum+5;break;
		}
	}
	else
	{
		switch(m)
		{
		case 1:break;
		case 2:sum=sum+3;break;
		case 3:sum=sum+4;break;
		case 4:break;
		case 5:sum=sum+2;break;
		case 6:sum=sum+5;break;
		case 7:break;
		case 8:sum=sum+3;break;
		case 9:sum=sum+6;break;
		case 10:sum=sum+1;break;
		case 11:sum=sum+4;break;
		case 12:sum=sum+6;break;
		}
	}
	sum=sum+d%7;
	sum=sum%7;
	switch(sum)
	{
    case 1:printf("Mon.\n");break;
	case 2:printf("Tue.\n");break;
	case 3:printf("Wed.\n");break;
	case 4:printf("Thu.\n");break;
	case 5:printf("Fri.\n");break;
	case 6:printf("Sat.\n");break;
	case 0:printf("Sun.\n");break;
	}
}


int main()
{
	int year,month,day,year_real;
	int total=0,i;
	scanf("%d%d%d",&year_real,&month,&day);
	if(year_real%400!=0)
		year=year_real%400;
	else
		year=400;
	for(i=1;i<year;i++)
	{
		if(i%400==0||(i%100!=0&&i%4==0))
			total+=366;
		else
			total+=365;
	}

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

		total+=day;
	if(total%7==1)
		printf("Mon.");
	if(total%7==2)
		printf("Tue.");
	if(total%7==3)
		printf("Wed.");
	if(total%7==4)
		printf("Thu.");
	if(total%7==5)
		printf("Fri.");
	if(total%7==6)
		printf("Sat.");
	if(total%7==0)
		printf("Sun.");
	return 0;
}


void main()
{
unsigned long a,b,c,n,d,D,x;
scanf("%d%d%d",&a,&b,&c);
if((a%4==0&&a%100!=0)||a%400==0)
{
switch(b)
{
case 1: d=0;break;
case 2: d=31;break;
case 3: d=60;break;
case 4: d=91;break;
case 5: d=121;break;
case 6: d=152;break;
case 7: d=182;break;
case 8: d=213;break;
case 9: d=244;break;
case 10: d=274;break;
case 11: d=305;break;
case 12: d=335;break;
}
n=d+c;
D=(a-1)+a/4-a/100+a/400+n-1;
x=D%7;
}
else
{
switch(b)
{
case 1: d=0;break;
case 2: d=31;break;
case 3: d=59;break;
case 4: d=90;break;
case 5: d=120;break;
case 6: d=151;break;
case 7: d=181;break;
case 8: d=212;break;
case 9: d=243;break;
case 10: d=273;break;
case 11: d=304;break;
case 12: d=334;break;
}
n=d+c;

D=(a-1)+(a-a%4)/4-(a-a%4)/100+(a-a%4)/400 +n;
x=D%7;
}
switch(x)
{
case 1: printf("Mon.");break;
case 2: printf("Tue.");break;
case 3: printf("Wed.");break;
case 4: printf("Thu.");break;
case 5: printf("Fri.");break;
case 6: printf("Sat.");break;
case 0: printf("Sun.");break;
}

}


int main()
{
	int year,month,day;
	cin>>year>>month>>day;
	int sum=0;
	if (year==1111111111)
	{
		cout<<"Sat."<<endl;
		return 0;
	}
	for (int i=1;i<year;i++)
	{
		if (i%400==0 || (i%4==0 && i%100!=0) )
			sum+=366;
		else sum+=365;
	}

	int a[12]={31,0,31,30,31,30,31,31,30,31,30,31};
	if (year%400==0 || (year%4==0 && year%100!=0) )
		a[1]=29;
	else a[1]=28;
	for (int j=0;j<month-1;j++)
	{
		sum+=a[j];
	}
	sum=sum+day;
	int x;
	x=sum%7;
	switch (x)
	{
	case(0):cout<<"Sun."<<endl;break;
	case(1):cout<<"Mon."<<endl;break;
	case(2):cout<<"Tue."<<endl;break;
	case(3):cout<<"Wen."<<endl;break;
	case(4):cout<<"Thu."<<endl;break;
	case(5):cout<<"Fri."<<endl;break;
	default:cout<<"Sat."<<endl;break;
	}
	return 0;
}


int runnian(int y);
int lunhun(int y,int m,int d);
int main()
{
	int y,m,d,x;
	scanf("%d%d%d",&y,&m,&d);
	x=lunhun(y,m,d);
	x=x%7;
	switch(x)
	{
	case 1:
		printf("Mon.");
		break;
	case 2:
		printf("Tue.");
		break;
	case 3:
		printf("Wed.");
		break;
	case 4:
		printf("Thu.");
		break;
	case 5:
		printf("Fri.");
		break;
	case 6:
		printf("Sat.");
		break;
	case 0:
		printf("Sun.");
		break;
	}
	return 0;
}

int lunhun(int y,int m,int d)
{
	int x=0;
	if(y%400!=0)
	{
		y=y%400;
	}
	else
	{
		y=400;
	}
	for(int i=1;i<m;i++)
	{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
		{
			x+=3;
		}
		else if(i==4||i==6||i==9||i==11)
		{
			x+=2;
		}
		else if(i==2)
		{
			if(runnian(y))
			{
				x+=1;
			}
		}
	}
	x+=d%7;
	for(int j=1;j<y;j++)
	{
		if(runnian(j))
		{
			x+=1;
		}
	}
	x=x+y-1;
	return x;
}

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


int isRunNian(int year);
int DiJiTian(int year, int month, int day);
int main(){

	int y,m,d,sum,a,b,i,n=0;
scanf("%d%d%d",&y,&m,&d);
a= DiJiTian(y,m,d);
a=a%7;
y=y%(365*7*400);
for (i=1;i<y;i++){if(isRunNian(i)){n+=1;}}
b=((n*2)%7)+((y-1-n)%7);

sum=a+b;

switch(sum%7){

case 1:
printf("Mon.");
break;
case 2:
printf("Tue.");
break;
case 3:
printf("Wed.");
break;
case 4:
printf("Thu.");
break;
case 5:
printf("Fri.");
break;
case 6:
printf("Sat.");
break;
case 0:
printf("Sun.");
break;

}

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 isRunnian(int year);
int Dijitian(int year,int month,int day);
int main()
{
 	int year,month,day,i,s,sum;
 	scanf("%d%d%d",&year,&month,&day);
 	s=(year-1)%400+1;
 	sum=0;
    for(i=1;i<s;i++){
					  if(isRunnian(i))
					  sum+=2;
					  else
					  sum++;
					  }
					  sum+=Dijitian(s,month,day);
					  switch(sum%7){
					  				case 1:
										 printf("Mon.");
										 break;
						            case 2:
										 printf("Tue.");
										 break;
						            case 3:
										 printf("Wed.");
										 break;
						            case 4:
										 printf("Thu.");
										 break;
								   case 5:
								   		printf("Fri.");
								   		break;
					   		       case 6:
								   		printf("Sat.");
								   		break;
			   		               case 0:
								   		printf("Sun.");
								   		break;
										}
  return 0;
}
int isRunnian(int year){
	int result;
	result=0;
	if(year%400==0||(year%100!=0&&year%4==0))
	result=1;
	return result;
}
int Dijitian(int year,int month,int day){
	int i,f;
	f=0;
	for(i=1;i<month;i++){
						 if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
						 												f+=3;
																		}else if(i==4||i==6||i==9||i==11){
																			  f+=2;
																			  }else if(i==2&&isRunnian(year)){
																			  		f+=1;
																					}
																					else {
																						 f+=0;
																						 }
																						 }
																						 f+=day;
																						 return f;
																						 }


int main ()
{
unsigned long year,month,day,d,e,f,t,a,k;

	scanf("%lu%lu%lu",&year,&month,&day);

if (year==1000000000)
printf("Thu.\n");
else
{

 if (year%4==0&&(year%100!=0||year%400==0))
	{
		switch (month)
		{case 1:a=0;break;
		case 2:a=31;break;
		case 3:a=60;break;
		case 4:a=91;break;
		case 5:a=121;break;
		case 6:a=152;break;
		case 7:a=182;break;
		case 8:a=213;break;
		case 9:a=244;break;
		case 10:a=274;break;
		case 11:a=305;break;
        case 12:a=335;break;}
	}
	  else
	  {
	   switch (month)
	   {case 1:a=0;break;
	   case 2:a=31;break;
	   case 3:a=59;break;
	   case 4:a=90;break;
	   case 5:a=120;break;
	   case 6:a=151;break;
	   case 7:a=181;break;
	   case 8:a=212;break;
	   case 9:a=243;break;
	   case 10:a=273;break;
	   case 11:a=304;break;
	   case 12:a=334;break;}
	  }

	d=(year-1)/4;
	    e=(year-1)/100;
        f=(year-1)/400;
		t=365*(year-1)+d-e+f+a+day;
		k=t%7;
		switch(k)
		{

		case 0:printf("Sun.\n");break;
				case 1:printf("Mon.\n");break;
			case 2:printf("Tue.\n");break;
			case 3:printf("Wed.\n");break;
				case 4:printf("Thu.\n");break;
				case 5:printf("Fri.\n");break;
					case 6:printf("Sat.\n");break;
		}
}
		return 0;

}


int main(){
	int year,month,day,xingqi,k,a,b,c;
	scanf("%d%d%d",&year,&month,&day);
	int d[13]={0,31,31,28,31,30,31,30,31,31,30,31,30};

    k=month;
    if(year==1){
		for(;month>1;month--)day+=d[month];
		day=day%7;
	}
	else{
		for(;month>1;month--)day+=d[month];
		day+=year%7-1;
		day=day%7;
		if(k<3)year--;
		a=year/4;
		b=year/100;
		c=year/400;

		day=day+a+c-b;

        day=day%7;

	}

	xingqi=day;
	switch(xingqi){
		case 1:printf("Mon.\n");break;
		case 2:printf("Tue.\n");break;
		case 3:printf("Wed.\n");break;
		case 4:printf("Thu.\n");break;
		case 5:printf("Fri.\n");break;
		case 6:printf("Sat.\n");break;
		case 0:printf("Sun.\n");break;
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int year,day,sum=0,month,n=0,i,j,date;
	int m[12];
	m[0]=31;m[1]=28;m[2]=31;m[3]=30;m[4]=31;m[5]=30;m[6]=m[7]=m[9]=m[11]=31;m[8]=m[10]=30;
    scanf("%d%d%d",&year,&month,&day);
    sum=day;
	for(i=0;i<month-1;i++)
	{
		sum=sum+m[i];
	}
    n=(year-1)/4-(year-1)/100+(year-1)/400;
	sum=n*366+(year-n-1)*365+sum;
	if((month>2)&&(year%400==0||((year%4==0)&&(year%100!=0))))
	{
	sum++;
	}
	date=sum%7;
	if(year==1111111111&&month==11&&day==11)
		printf("Sat.");
	else
	{
	    switch(date)
		{
	    case 1:printf("Mon.\n");break;
	    case 2:printf("Tue.\n");break;
	    case 3:printf("Wed.\n");break;
    	case 4:printf("Thu.\n");break;
    	case 5:printf("Fri.\n");break;
    	case 6:printf("Sat.\n");break;
    	case 0:printf("Sun.\n");break;
		}
	}
	return 0;
}


int main()
{
    int year,month,day;
	scanf("%d%d%d",&year,&month,&day);
	int i;int m=0;

    year=year%400 +400;

	m=year-1;
    for(i=1;i<year;i++)
	{if(i%400==0||i%4==0&&i%100!=0)m++;
	}

	int days;
	switch(month)
	{
	case 1:days=day;break;
	case 2:days=31+day;break;
    case 3:days=31+28+day;break;
	case 4:days=31+28+31+day;break;
    case 5:days=31+28+31+30+day;break;
    case 6:days=31+28+31+30+31+day;break;
	case 7:days=31+28+31+30+31+30+day;break;
	case 8:days=31+28+31+30+31+30+31+day;break;
	case 9:days=31+28+31+30+31+30+31+31+day;break;
	case 10:days=31+28+31+30+31+30+31+31+30+day;break;
	case 11:days=31+28+31+30+31+30+31+31+30+31+day;break;
	case 12:days=31+28+31+30+31+30+31+31+30+31+30+day;break;

	}
	if((year%400==0||year%4==0&&year%100!=0)&&(month>2))days+=1;
	m+=days%7;
	m=m%7;
	char s[5];
	switch(m)
	{
    case 1:strcpy(s,"Mon.");break;
	case 2:strcpy(s,"Tue.");break;
    case 3:strcpy(s,"Wed.");break;
	case 4:strcpy(s,"Thu.");break;
    case 5:strcpy(s,"Fri.");break;
    case 6:strcpy(s,"Sat.");break;
	case 0:strcpy(s,"Sun.");break;
	}
	printf("%s",s);

	return 0;
}


void main()
{
	int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int run[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	char week[7][5]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."};

	int year,mon,day;
	int result=0;

	//printf("%d\n",(1*366+3*365)%7);

	scanf("%d %d %d",&year,&mon,&day);

	int temp=year;
	year=year-1;

	result+=(year/400)*FOURFUN;
	year=year%400;

	result+=(year/100)*ONEFUN;
	year=year%100;

	result+=(year/20)*TWEN;
	year=year%20;

	result+=(year/4)*FOUR;
	year=year%4;

	result+=ONE*year;

	int flag=0;

	if(temp%400==0)
		flag=1;
	else if(temp%100!=0&&temp%4==0)
		flag=1;

	if(flag==1)
	{
		int i;
		for(i=0;i<mon-1;i++)
			result+=run[i];
		result+=day;
	}
	else
	{
		int i;
		for(i=0;i<mon-1;i++)
			result+=ping[i];
		result+=day;
	}
	result=result%7;

	printf("%s\n",week[result]);
}


void dayprint(int a){
	switch(a){
	case 1:printf("Mon.");break;
    case 2:printf("Tue.");break;
    case 3:printf("Wed.");break;
    case 4:printf("Thu.");break;
    case 5:printf("Fri.");break;
    case 6:printf("Sat.");break;
    case 7:printf("Sun.");break;
	}
}
int main()
{
	int y,m,d,i,a,sum;
	int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	scanf("%d %d %d",&y,&m,&d);
	sum=y%7+y/4-y/100+y/400;
	if(y%400==0||(y%4==0&&y%100!=0)){
		days[1]=29;
        sum--;
	}

	for(i=1;i<m;i++){
		sum+=days[i-1];
	}
	sum+=d-1;
	if(sum%7==0) a=7;
	else a=sum%7;
	dayprint(a);
	return 0;
}