#include <stdio.h>
#include <stdlib.h>

int main()
{

  int year,day,month;

  while(scanf("%d %d",&year,&day)!=EOF){
        month=1;
  int A[]={31,29,31,30,31,30,31,31,30,31,30,31};
  if( (year%4==0&&year%100!=0)||(year%400==0) ){//闰年条件:整除400||整除4不整除100
    A[1]=29;
  }else{
  A[1]=28;
  }
  while(A[month-1]<day){
    day-=A[month-1];
    month++;

  }
    printf("%4d-%02d-%02d\n",year,month,day);//格式P19页
  }

}